-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
196 lines (167 loc) · 6.58 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Top Level CMake file for XTOOLS.
cmake_minimum_required(VERSION 2.8.12.2)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to MinSizeRel")
set(CMAKE_BUILD_TYPE MinSizeRel)
set(XTOOLS_ENABLE_ASSERTIONS 1)
endif()
if (POLICY CMP0051)
# CMake 3.1 and higher include generator expressions of the form
# $<TARGETLIB:obj> in the SOURCES property. These need to be
# stripped everywhere that access the SOURCES property, so we just
# defer to the OLD behavior of not including generator expressions
# in the output for now.
cmake_policy(SET CMP0051 OLD)
endif()
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()
project(XTOOLS)
include(CTest)
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
# Keep some kind of project identifier.
set(XTOOLS_VERSION_MAJOR 2)
set(XTOOLS_VERSION_MINOR 2)
set(XTOOLS_VERSION_PATCH 4)
set(XTOOLS_VERSION_SUFFIX git)
set(XTOOLS_VERSION "${XTOOLS_VERSION_MAJOR}.${XTOOLS_VERSION_MINOR}.${XTOOLS_VERSION_PATCH}")
if (NOT PACKAGE_VERSION)
set(PACKAGE_VERSION "unpackaged")
endif()
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. ")
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
set(UNIX_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
if(CMAKE_CROSSCOMPILING)
message(STATUS "*Top Level* Cross compiling")
else()
message(STATUS "*Top Level* native build")
endif()
if(XTOOLS_LTO_PATH AND
EXISTS ${XTOOLS_LTO_PATH}/include/llvm-c/lto.h AND
EXISTS ${XTOOLS_LTO_PATH}/lib/libLTO.dylib)
configure_file(
${XTOOLS_LTO_PATH}/include/llvm-c/lto.h
${CMAKE_BINARY_DIR}/include/llvm-c/lto.h
COPYONLY)
configure_file(
${XTOOLS_LTO_PATH}/lib/libLTO.dylib
${CMAKE_BINARY_DIR}/lib/libLTO.dylib
COPYONLY)
option(XTOOLS_LTO_SUPPORT "Support LTO in cctools and ld64." ON)
message(STATUS "*Top Level* WITH LTO")
else()
option(XTOOLS_LTO_SUPPORT "Support LTO in cctools and ld64." OFF)
message(STATUS "*Top Level* NO LTO")
endif()
if(XTOOLS_TAPI_PATH AND
EXISTS ${XTOOLS_TAPI_PATH}/include/tapi AND
EXISTS ${XTOOLS_TAPI_PATH}/lib/libtapi.dylib)
configure_file(
${XTOOLS_TAPI_PATH}/lib/libtapi.dylib
${CMAKE_BINARY_DIR}/lib/libtapi.dylib
COPYONLY)
option(XTOOLS_TAPI_SUPPORT "Support TAPI in cctools and ld64." ON)
message(STATUS "*Top Level* WITH TAPI")
else()
option(XTOOLS_TAPI_SUPPORT "Support TAPI in cctools and ld64." OFF)
message(STATUS "*Top Level* NO TAPI")
endif()
SET(CMAKE_C_FLAGS_MINSIZEREL "-Os")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
#SET(CMAKE_C_FLAGS_DEBUG "-Og")
#SET(CMAKE_CXX_FLAGS_DEBUG "-Og")
include(config-ix)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
if (APPLE)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
else(UNIX)
if(NOT DEFINED CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib${UNIX_LIBDIR_SUFFIX}")
if (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,origin")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,origin")
endif()
endif(NOT DEFINED CMAKE_INSTALL_RPATH)
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archs)
#link_directories("${CMAKE_SOURCE_DIR}/host-libs")
# *sigh* ... re-working cctools to allow regular 'bool' is possible but quite
# a lot of fiddling. For now it's simply easier to use two versions of the
# dyld headers, one local to cctools and the ld64 one copied from up-to-date
# dyld. This include dir should NOT be used for cctools.
if( EXISTS ${CMAKE_SOURCE_DIR}/dyld/include/mach-o/dyld_priv.h)
configure_file(
${CMAKE_SOURCE_DIR}/dyld/include/mach-o/dyld_priv.h
${CMAKE_BINARY_DIR}/dyld-include/mach-o/dyld_priv.h
COPYONLY)
configure_file(
${CMAKE_SOURCE_DIR}/dyld/include/mach-o/dyld.h
${CMAKE_BINARY_DIR}/dyld-include/mach-o/dyld.h
COPYONLY)
configure_file(
${CMAKE_SOURCE_DIR}/dyld/include/mach-o/dyld_images.h
${CMAKE_BINARY_DIR}/dyld-include/mach-o/dyld_images.h
COPYONLY)
endif()
include_directories(BEFORE SYSTEM "${CMAKE_SOURCE_DIR}/macho-target-includes")
include_directories(BEFORE SYSTEM "${CMAKE_BINARY_DIR}/include")
include_directories(BEFORE SYSTEM "${CMAKE_BINARY_DIR}/host-includes")
if(XTOOLS_TAPI_SUPPORT)
include_directories(BEFORE SYSTEM "${XTOOLS_TAPI_PATH}/include")
message(STATUS "*Top Level* including ${XTOOLS_TAPI_PATH}/include")
endif()
if (EXISTS ${CMAKE_BINARY_DIR}/lib)
link_directories("${CMAKE_BINARY_DIR}/lib")
endif()
if (EXISTS ${CMAKE_BINARY_DIR}/archs)
link_directories("${CMAKE_BINARY_DIR}/archs")
endif()
if(XTOOLS_NEEDS_STRLIB)
add_subdirectory(strlib)
configure_file(
${CMAKE_SOURCE_DIR}/strlib/string.h
${CMAKE_BINARY_DIR}/host-includes/string.h
COPYONLY)
endif()
# Darwin < 10 doesn't specify the uuid_string_t, provide it here.
configure_file(${CMAKE_SOURCE_DIR}/host-includes/uuid/uuid.h
${CMAKE_BINARY_DIR}/host-includes/uuid/uuid.h
COPYONLY)
if (NOT XTOOLS_HAS_MODERNXAR)
add_subdirectory(xar-additions)
configure_file(
${CMAKE_SOURCE_DIR}/xar-additions/xar.h
${CMAKE_BINARY_DIR}/host-includes/xar/xar.h
COPYONLY)
endif()
# Evaluate first so that we find out about libprunetrie.
if( EXISTS ${CMAKE_SOURCE_DIR}/ld64/CMakeLists.txt )
add_subdirectory(ld64)
endif()
set(XTOOLS_HAS_LIBPRUNETRIE)
if( EXISTS ${CMAKE_SOURCE_DIR}/ld64/src/other/PruneTrie.cpp)
# We need to do this here, because cctools and ld items both want it.
#add_library(prunetrie ${CMAKE_SOURCE_DIR}/ld64/src/other/PruneTrie.cpp)
#include_directories("${CMAKE_SOURCE_DIR}/ld64/src/abstraction")
# put the header where we can find it.
configure_file(
${CMAKE_SOURCE_DIR}/ld64/src/other/prune_trie.h
${CMAKE_BINARY_DIR}/include/mach-o/prune_trie.h
COPYONLY)
set(XTOOLS_HAS_LIBPRUNETRIE YES)
endif()
if( EXISTS ${CMAKE_SOURCE_DIR}/cctools/CMakeLists.txt )
add_subdirectory(cctools)
endif()