Mercurial > projects > ldc
comparison CMakeLists.txt @ 750:d05fc504a3a0
Improve CMake build file.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 03 Nov 2008 12:25:25 +0100 |
parents | db2dd9861600 |
children | 405e40f20ef9 |
comparison
equal
deleted
inserted
replaced
749:db2dd9861600 | 750:d05fc504a3a0 |
---|---|
21 dmd/expression.c | 21 dmd/expression.c |
22 dmd/func.c | 22 dmd/func.c |
23 dmd/gnuc.c | 23 dmd/gnuc.c |
24 dmd/hdrgen.c | 24 dmd/hdrgen.c |
25 dmd/html.c | 25 dmd/html.c |
26 dmd/id.c | |
27 dmd/identifier.c | 26 dmd/identifier.c |
28 dmd/impcnvtab.c | |
29 dmd/import.c | 27 dmd/import.c |
30 dmd/inifile.c | 28 dmd/inifile.c |
31 dmd/init.c | 29 dmd/init.c |
32 dmd/inline.c | 30 dmd/inline.c |
33 dmd/interpret.c | 31 dmd/interpret.c |
82 ir/irlandingpad.cpp | 80 ir/irlandingpad.cpp |
83 ir/irmodule.cpp | 81 ir/irmodule.cpp |
84 ir/irstruct.cpp | 82 ir/irstruct.cpp |
85 ir/irsymbol.cpp | 83 ir/irsymbol.cpp |
86 ir/irtype.cpp | 84 ir/irtype.cpp |
87 ir/irvar.cpp) | 85 ir/irvar.cpp |
86 ) | |
88 | 87 |
89 add_executable (ldc ${LDC_SOURCE_FILES}) | 88 set (LDC_GENERATED_SOURCE_FILES |
90 set_source_files_properties (${LDC_SOURCE_FILES} PROPERTIES LANGUAGE CXX) | 89 ${CMAKE_CURRENT_BINARY_DIR}/impcnvtab.c |
90 ${CMAKE_CURRENT_BINARY_DIR}/id.c | |
91 ) | |
92 set (LDC_GENERATED_HEADER_FILES | |
93 ${CMAKE_CURRENT_BINARY_DIR}/id.h | |
94 ) | |
91 | 95 |
92 execute_process (COMMAND llvm-config --cxxflags OUTPUT_VARIABLE LLVM_CXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) | 96 # some sources are generated |
93 #execute_process (COMMAND llvm-config --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIR) | 97 set_source_files_properties ( |
94 #execute_process (COMMAND llvm-config --libs bitwriter linker ipo instrumentation backend OUTPUT_VARIABLE LLVM_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) | 98 ${LDC_GENERATED_SOURCE_FILES} |
95 execute_process (COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/config.guess OUTPUT_VARIABLE DEFAULT_TRIPLE OUTPUT_STRIP_TRAILING_WHITESPACE) | 99 ${LDC_GENERATED_HEADER_FILES} |
100 PROPERTIES GENERATED 1 | |
101 ) | |
96 | 102 |
103 # mark all source as c++ | |
104 set_source_files_properties ( | |
105 ${LDC_SOURCE_FILES} ${LDC_GENERATED_SOURCE_FILES} | |
106 PROPERTIES LANGUAGE CXX | |
107 ) | |
108 | |
109 # build and run idgen and impcnvgen | |
110 set_source_files_properties ( | |
111 dmd/impcnvgen.c | |
112 dmd/idgen.c | |
113 PROPERTIES LANGUAGE CXX | |
114 ) | |
115 add_executable (impcnvgen dmd/impcnvgen.c) | |
116 add_executable (idgen dmd/idgen.c) | |
117 set_target_properties (impcnvgen idgen PROPERTIES LINKER_LANGUAGE CXX) | |
118 get_target_property (IMPCNVGEN_EXE impcnvgen LOCATION) | |
119 get_target_property (IDGEN_EXE idgen LOCATION) | |
120 add_custom_command ( | |
121 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/impcnvtab.c | |
122 COMMAND ${IMPCNVGEN_EXE} | |
123 DEPENDS impcnvgen | |
124 ) | |
125 add_custom_command ( | |
126 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/id.c ${CMAKE_CURRENT_BINARY_DIR}/id.h | |
127 COMMAND ${IDGEN_EXE} | |
128 DEPENDS idgen | |
129 ) | |
130 | |
131 # ldc itself | |
132 add_executable (ldc ${LDC_SOURCE_FILES} ${LDC_GENERATED_SOURCE_FILES} ${LDC_GENERATED_HEADER_FILES}) | |
133 | |
134 | |
135 # setup DEFAULT_TARGET_TRIPLE | |
136 execute_process (COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/config.guess OUTPUT_VARIABLE DEFAULT_TARGET_TRIPLE_GUESS OUTPUT_STRIP_TRAILING_WHITESPACE) | |
137 set (DEFAULT_TARGET_TRIPLE ${DEFAULT_TARGET_TRIPLE_GUESS} CACHE STRING "the default target triple LDC should compile for") | |
138 | |
139 # setup POSIX | |
140 if (WIN32) | |
141 set (POSIX_GUESS 0) | |
142 else (WIN32) | |
143 set (POSIX_GUESS 1) | |
144 endif (WIN32) | |
145 set (POSIX ${POSIX_GUESS} CACHE BOOL "is LDC build on POSIX?") | |
146 | |
147 # setup defines | |
97 set (LDC_DEFINES | 148 set (LDC_DEFINES |
98 -DIN_LLVM | 149 -DIN_LLVM |
99 -D_DH | 150 -D_DH |
100 -DOPAQUE_VTBLS | 151 -DOPAQUE_VTBLS |
101 -DUSE_BOEHM_GC=0 | 152 -DUSE_BOEHM_GC=0 |
102 -DDMDV1 | 153 -DDMDV1 |
103 -DPOSIX=1 | 154 -DPOSIX=${POSIX} |
104 -DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TRIPLE}\\" | 155 -DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TARGET_TRIPLE}\\" |
105 -DX86_REVERSE_PARAMS=1 | 156 -DX86_REVERSE_PARAMS=1 |
106 -DX86_PASS_IN_EAX=1) | 157 -DX86_PASS_IN_EAX=1) |
107 | 158 execute_process (COMMAND llvm-config --cxxflags OUTPUT_VARIABLE LLVM_CXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) |
108 # passing CXXFLAGS here is not good style | 159 # passing CXXFLAGS here is not good style |
109 add_definitions (${LDC_DEFINES} ${LLVM_CXXFLAGS}) | 160 add_definitions (${LDC_DEFINES} ${LLVM_CXXFLAGS}) |
110 include_directories (. dmd) | 161 |
162 include_directories (. dmd ${CMAKE_CURRENT_BINARY_DIR}) | |
111 | 163 |
112 # this is hackish, but works | 164 # this is hackish, but works |
113 target_link_libraries (ldc "`llvm-config --ldflags` `llvm-config --libs bitwriter linker ipo instrumentation backend`") | 165 target_link_libraries (ldc "`llvm-config --ldflags` `llvm-config --libs bitwriter linker ipo instrumentation backend`") |
114 | 166 |
115 #TODO: POSIX detection, runtime build | 167 #TODO: runtime build |