annotate 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
rev   line source
kamm@749 1 project (ldc)
kamm@749 2
kamm@749 3 set (LDC_SOURCE_FILES
kamm@749 4 dmd/access.c
kamm@749 5 dmd/array.c
kamm@749 6 dmd/arrayop.c
kamm@749 7 dmd/attrib.c
kamm@749 8 dmd/cast.c
kamm@749 9 dmd/class.c
kamm@749 10 dmd/clone.c
kamm@749 11 dmd/cond.c
kamm@749 12 dmd/constfold.c
kamm@749 13 dmd/dchar.c
kamm@749 14 dmd/declaration.c
kamm@749 15 dmd/delegatize.c
kamm@749 16 dmd/doc.c
kamm@749 17 dmd/dsymbol.c
kamm@749 18 dmd/dump.c
kamm@749 19 dmd/entity.c
kamm@749 20 dmd/enum.c
kamm@749 21 dmd/expression.c
kamm@749 22 dmd/func.c
kamm@749 23 dmd/gnuc.c
kamm@749 24 dmd/hdrgen.c
kamm@749 25 dmd/html.c
kamm@749 26 dmd/identifier.c
kamm@749 27 dmd/import.c
kamm@749 28 dmd/inifile.c
kamm@749 29 dmd/init.c
kamm@749 30 dmd/inline.c
kamm@749 31 dmd/interpret.c
kamm@749 32 dmd/lexer.c
kamm@749 33 dmd/lstring.c
kamm@749 34 dmd/macro.c
kamm@749 35 dmd/man.c
kamm@749 36 dmd/mangle.c
kamm@749 37 dmd/mars.c
kamm@749 38 dmd/mem.c
kamm@749 39 dmd/module.c
kamm@749 40 dmd/mtype.c
kamm@749 41 dmd/opover.c
kamm@749 42 dmd/optimize.c
kamm@749 43 dmd/parse.c
kamm@749 44 dmd/root.c
kamm@749 45 dmd/scope.c
kamm@749 46 dmd/statement.c
kamm@749 47 dmd/staticassert.c
kamm@749 48 dmd/stringtable.c
kamm@749 49 dmd/struct.c
kamm@749 50 dmd/template.c
kamm@749 51 dmd/unialpha.c
kamm@749 52 dmd/utf.c
kamm@749 53 dmd/version.c
kamm@749 54 gen/aa.cpp
kamm@749 55 gen/arrays.cpp
kamm@749 56 gen/asmstmt.cpp
kamm@749 57 gen/binops.cpp
kamm@749 58 gen/classes.cpp
kamm@749 59 gen/complex.cpp
kamm@749 60 gen/dvalue.cpp
kamm@749 61 gen/dwarftypes.cpp
kamm@749 62 gen/functions.cpp
kamm@749 63 gen/irstate.cpp
kamm@749 64 gen/linker.cpp
kamm@749 65 gen/llvmhelpers.cpp
kamm@749 66 gen/logger.cpp
kamm@749 67 gen/optimizer.cpp
kamm@749 68 gen/runtime.cpp
kamm@749 69 gen/statements.cpp
kamm@749 70 gen/structs.cpp
kamm@749 71 gen/tocall.cpp
kamm@749 72 gen/tocsym.cpp
kamm@749 73 gen/todebug.cpp
kamm@749 74 gen/todt.cpp
kamm@749 75 gen/toir.cpp
kamm@749 76 gen/tollvm.cpp
kamm@749 77 gen/toobj.cpp
kamm@749 78 gen/typinf.cpp
kamm@749 79 ir/irfunction.cpp
kamm@749 80 ir/irlandingpad.cpp
kamm@749 81 ir/irmodule.cpp
kamm@749 82 ir/irstruct.cpp
kamm@749 83 ir/irsymbol.cpp
kamm@749 84 ir/irtype.cpp
kamm@750 85 ir/irvar.cpp
kamm@750 86 )
kamm@749 87
kamm@750 88 set (LDC_GENERATED_SOURCE_FILES
kamm@750 89 ${CMAKE_CURRENT_BINARY_DIR}/impcnvtab.c
kamm@750 90 ${CMAKE_CURRENT_BINARY_DIR}/id.c
kamm@750 91 )
kamm@750 92 set (LDC_GENERATED_HEADER_FILES
kamm@750 93 ${CMAKE_CURRENT_BINARY_DIR}/id.h
kamm@750 94 )
kamm@749 95
kamm@750 96 # some sources are generated
kamm@750 97 set_source_files_properties (
kamm@750 98 ${LDC_GENERATED_SOURCE_FILES}
kamm@750 99 ${LDC_GENERATED_HEADER_FILES}
kamm@750 100 PROPERTIES GENERATED 1
kamm@750 101 )
kamm@749 102
kamm@750 103 # mark all source as c++
kamm@750 104 set_source_files_properties (
kamm@750 105 ${LDC_SOURCE_FILES} ${LDC_GENERATED_SOURCE_FILES}
kamm@750 106 PROPERTIES LANGUAGE CXX
kamm@750 107 )
kamm@750 108
kamm@750 109 # build and run idgen and impcnvgen
kamm@750 110 set_source_files_properties (
kamm@750 111 dmd/impcnvgen.c
kamm@750 112 dmd/idgen.c
kamm@750 113 PROPERTIES LANGUAGE CXX
kamm@750 114 )
kamm@750 115 add_executable (impcnvgen dmd/impcnvgen.c)
kamm@750 116 add_executable (idgen dmd/idgen.c)
kamm@750 117 set_target_properties (impcnvgen idgen PROPERTIES LINKER_LANGUAGE CXX)
kamm@750 118 get_target_property (IMPCNVGEN_EXE impcnvgen LOCATION)
kamm@750 119 get_target_property (IDGEN_EXE idgen LOCATION)
kamm@750 120 add_custom_command (
kamm@750 121 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/impcnvtab.c
kamm@750 122 COMMAND ${IMPCNVGEN_EXE}
kamm@750 123 DEPENDS impcnvgen
kamm@750 124 )
kamm@750 125 add_custom_command (
kamm@750 126 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/id.c ${CMAKE_CURRENT_BINARY_DIR}/id.h
kamm@750 127 COMMAND ${IDGEN_EXE}
kamm@750 128 DEPENDS idgen
kamm@750 129 )
kamm@750 130
kamm@750 131 # ldc itself
kamm@750 132 add_executable (ldc ${LDC_SOURCE_FILES} ${LDC_GENERATED_SOURCE_FILES} ${LDC_GENERATED_HEADER_FILES})
kamm@750 133
kamm@750 134
kamm@750 135 # setup DEFAULT_TARGET_TRIPLE
kamm@750 136 execute_process (COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/config.guess OUTPUT_VARIABLE DEFAULT_TARGET_TRIPLE_GUESS OUTPUT_STRIP_TRAILING_WHITESPACE)
kamm@750 137 set (DEFAULT_TARGET_TRIPLE ${DEFAULT_TARGET_TRIPLE_GUESS} CACHE STRING "the default target triple LDC should compile for")
kamm@750 138
kamm@750 139 # setup POSIX
kamm@750 140 if (WIN32)
kamm@750 141 set (POSIX_GUESS 0)
kamm@750 142 else (WIN32)
kamm@750 143 set (POSIX_GUESS 1)
kamm@750 144 endif (WIN32)
kamm@750 145 set (POSIX ${POSIX_GUESS} CACHE BOOL "is LDC build on POSIX?")
kamm@750 146
kamm@750 147 # setup defines
kamm@749 148 set (LDC_DEFINES
kamm@749 149 -DIN_LLVM
kamm@749 150 -D_DH
kamm@749 151 -DOPAQUE_VTBLS
kamm@749 152 -DUSE_BOEHM_GC=0
kamm@749 153 -DDMDV1
kamm@750 154 -DPOSIX=${POSIX}
kamm@750 155 -DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TARGET_TRIPLE}\\"
kamm@749 156 -DX86_REVERSE_PARAMS=1
kamm@749 157 -DX86_PASS_IN_EAX=1)
kamm@750 158 execute_process (COMMAND llvm-config --cxxflags OUTPUT_VARIABLE LLVM_CXXFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
kamm@749 159 # passing CXXFLAGS here is not good style
kamm@749 160 add_definitions (${LDC_DEFINES} ${LLVM_CXXFLAGS})
kamm@750 161
kamm@750 162 include_directories (. dmd ${CMAKE_CURRENT_BINARY_DIR})
kamm@749 163
kamm@749 164 # this is hackish, but works
kamm@749 165 target_link_libraries (ldc "`llvm-config --ldflags` `llvm-config --libs bitwriter linker ipo instrumentation backend`")
kamm@749 166
kamm@750 167 #TODO: runtime build