Mercurial > projects > ldc
comparison CMakeLists.txt @ 785:ac39e5449ca5
Apply Elrood's CMake changes from #124. Thanks a lot!
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 24 Nov 2008 18:17:58 +0100 |
parents | f04dde6e882c |
children | 8f0b24bc55f0 |
comparison
equal
deleted
inserted
replaced
784:a45179dfaa43 | 785:ac39e5449ca5 |
---|---|
7 include(FindPerl) | 7 include(FindPerl) |
8 if(NOT PERL) | 8 if(NOT PERL) |
9 message(FATAL_ERROR "perl not found") | 9 message(FATAL_ERROR "perl not found") |
10 endif(NOT PERL) | 10 endif(NOT PERL) |
11 | 11 |
12 set(LLVM_INSTDIR CACHE PATH "LLVM installation directory") | 12 find_program(LLVM_CONFIG llvm-config ${LLVM_INSTDIR}/bin DOC "path to llvm-config tool") |
13 # get llvm's install dir. a little hackish, we could do something like llvm-config --prefix, but this does as well | |
14 string(REPLACE "/bin/llvm-config" "" LLVM_DIR ${LLVM_CONFIG}) | |
13 | 15 |
14 find_program(LLVM_CONFIG llvm-config ${LLVM_INSTDIR}/bin DOC "path to llvm-config tool") | 16 set(LLVM_INSTDIR ${LLVM_DIR} CACHE PATH "LLVM installation directory" FORCE) |
15 if(NOT LLVM_CONFIG) | 17 if(NOT LLVM_INSTDIR) |
16 message(FATAL_ERROR "llvm-config not found") | 18 message(FATAL_ERROR "llvm not found") |
17 endif(NOT LLVM_CONFIG) | 19 endif(NOT LLVM_INSTDIR) |
18 | 20 |
19 execute_process( | 21 execute_process( |
20 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --host-target | 22 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --host-target |
21 OUTPUT_VARIABLE HOST_TARGET | 23 OUTPUT_VARIABLE HOST_TARGET |
22 OUTPUT_STRIP_TRAILING_WHITESPACE | 24 OUTPUT_STRIP_TRAILING_WHITESPACE |
34 execute_process( | 36 execute_process( |
35 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --libfiles bitwriter linker ipo instrumentation backend | 37 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --libfiles bitwriter linker ipo instrumentation backend |
36 OUTPUT_VARIABLE LLVM_LIBS | 38 OUTPUT_VARIABLE LLVM_LIBS |
37 OUTPUT_STRIP_TRAILING_WHITESPACE | 39 OUTPUT_STRIP_TRAILING_WHITESPACE |
38 ) | 40 ) |
39 # get llvm's install dir. a little hackish, we could do something like llvm-config --prefix, but this does as well | |
40 string(REPLACE "/bin/llvm-config" "" LLVM_INSTDIR ${LLVM_CONFIG}) | |
41 | 41 |
42 set(D_VERSION 1 CACHE STRING "D language version") | 42 set(D_VERSION 1 CACHE STRING "D language version") |
43 option(USE_BOEHM_GC "use the Boehm garbage collector internally") | |
44 | |
43 if(D_VERSION EQUAL 1) | 45 if(D_VERSION EQUAL 1) |
44 set(DMDFE_PATH dmd) | 46 set(DMDFE_PATH dmd) |
45 set(LDC_EXE ldc) | 47 set(LDC_EXE ldc) |
46 add_definitions(-DDMDV1) | 48 add_definitions(-DDMDV1) |
47 elseif(D_VERSION EQUAL 2) | 49 elseif(D_VERSION EQUAL 2) |
67 add_executable(impcnvgen ${DMDFE_PATH}/impcnvgen.c) | 69 add_executable(impcnvgen ${DMDFE_PATH}/impcnvgen.c) |
68 # cmake 2.4 | 70 # cmake 2.4 |
69 set_target_properties( | 71 set_target_properties( |
70 idgen impcnvgen PROPERTIES | 72 idgen impcnvgen PROPERTIES |
71 LINKER_LANGUAGE CXX | 73 LINKER_LANGUAGE CXX |
74 RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${DMDFE_PATH} | |
72 ) | 75 ) |
73 get_target_property(IDGEN_LOC idgen LOCATION) | 76 get_target_property(IDGEN_LOC idgen LOCATION) |
74 get_target_property(IMPCNVGEN_LOC impcnvgen LOCATION) | 77 get_target_property(IMPCNVGEN_LOC impcnvgen LOCATION) |
75 # | 78 # |
76 add_custom_command( | 79 add_custom_command( |
125 | 128 |
126 add_definitions( | 129 add_definitions( |
127 -DIN_LLVM | 130 -DIN_LLVM |
128 -D_DH | 131 -D_DH |
129 -DOPAQUE_VTBLS | 132 -DOPAQUE_VTBLS |
130 -DUSE_BOEHM_GC=0 | |
131 -DX86_REVERSE_PARAMS | 133 -DX86_REVERSE_PARAMS |
132 -DX86_PASS_IN_EAX | 134 -DX86_PASS_IN_EAX |
133 ) | 135 ) |
134 | 136 |
135 if(UNIX) | 137 if(UNIX) |
136 add_definitions(-DPOSIX) | 138 add_definitions(-DPOSIX) |
137 #set(CONF_SUFFIX conf) | |
138 endif(UNIX) | 139 endif(UNIX) |
139 | 140 |
141 if(USE_BOEHM_GC) | |
142 add_definitions(-DUSE_BOEHM_GC) | |
143 endif(USE_BOEHM_GC) | |
144 | |
140 if(CMAKE_MINOR_VERSION LESS 6) | 145 if(CMAKE_MINOR_VERSION LESS 6) |
146 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "output dir for built executables") | |
147 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib CACHE PATH "output dir for built libraries") | |
141 add_definitions(-DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TARGET}\\") | 148 add_definitions(-DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TARGET}\\") |
142 else(CMAKE_MINOR_VERSION LESS 6) | 149 else(CMAKE_MINOR_VERSION LESS 6) |
143 add_definitions(-DDEFAULT_TARGET_TRIPLE="${DEFAULT_TARGET}") | 150 add_definitions(-DDEFAULT_TARGET_TRIPLE="${DEFAULT_TARGET}") |
144 endif(CMAKE_MINOR_VERSION LESS 6) | 151 endif(CMAKE_MINOR_VERSION LESS 6) |
145 | 152 |
153 | 160 |
154 # LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems | 161 # LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems |
155 target_link_libraries(${LDC_EXE} "${LLVM_LDFLAGS} ${LLVM_LIBS}") | 162 target_link_libraries(${LDC_EXE} "${LLVM_LDFLAGS} ${LLVM_LIBS}") |
156 if(WIN32) | 163 if(WIN32) |
157 target_link_libraries(${LDC_EXE} psapi) | 164 target_link_libraries(${LDC_EXE} psapi) |
158 #set(CONF_SUFFIX ini) | |
159 endif(WIN32) | 165 endif(WIN32) |
160 | 166 |
161 # cmake pre 2.6 doesn't support the RUNTIME_OUTPUT_DIRECTORY target property | 167 if(USE_BOEHM_GC) |
162 if(CMAKE_MINOR_VERSION LESS 6) | 168 target_link_libraries(${LDC_EXE} gc) |
163 get_target_property(LDC_LOC ${LDC_EXE} LOCATION) | 169 endif(USE_BOEHM_GC) |
164 add_custom_command( | |
165 TARGET ${LDC_EXE} | |
166 POST_BUILD | |
167 COMMAND ${CMAKE_COMMAND} -E copy ${LDC_LOC} ${PROJECT_BINARY_DIR}/bin/ | |
168 COMMAND ${CMAKE_COMMAND} -E remove ${LDC_LOC} | |
169 ) | |
170 endif(CMAKE_MINOR_VERSION LESS 6) | |
171 | 170 |
172 #configure_file(${PROJECT_SOURCE_DIR}/ldc.conf.in ${PROJECT_BINARY_DIR}/bin/ldc.${CONF_SUFFIX}) | 171 get_target_property(LDC_LOC ${LDC_EXE} LOCATION) |
173 | 172 |
174 # TODO: runtime build | |
175 # possible problems: | |
176 # with an oos-build, how to set up a working environment, with conf/ini and tango in place? | |
177 # patch tango? how to determine if that's already been done? | |
178 # std but compatible runtime build, or shared, which doesn't yet work on every platform | |
179 # | |
180 # TODO: install target | 173 # TODO: install target |
181 # TODO: testrun | 174 # TODO: testrun |
175 | |
176 add_subdirectory(runtime EXCLUDE_FROM_ALL) |