annotate CMakeLists.txt @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents 18bbb1436153
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
1 project(ldc)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
2
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
3 cmake_minimum_required(VERSION 2.6)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
4 # actually, 2.4 will work, with a warning
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
5 # if we required 2.4, 2.6+ would switch to a compatibility mode and cause problems on 2.6+ specifics
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
6
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
7 include(FindPerl)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
8 if(NOT PERL)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
9 message(FATAL_ERROR "perl not found")
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
10 endif(NOT PERL)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
11
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
12 include(FindPkgConfig)
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
13 if(NOT PKG_CONFIG_FOUND)
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
14 message(FATAL_ERROR "pkg-config not found")
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
15 else(NOT PKG_CONFIG_FOUND)
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
16 pkg_search_module(LIBCONFIGPP libconfig++)
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
17 if(NOT LIBCONFIGPP_FOUND)
1139
d82cc6e5bb65 Fixed error when pkg-config couldn't find libconfig, allows user to set flags manually.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1129
diff changeset
18 set(LIBCONFIG_CXXFLAGS "" CACHE STRING "libconfig++ compiler flags")
d82cc6e5bb65 Fixed error when pkg-config couldn't find libconfig, allows user to set flags manually.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1129
diff changeset
19 set(LIBCONFIG_LDFLAGS "" CACHE STRING "libconfig++ linker flags")
d82cc6e5bb65 Fixed error when pkg-config couldn't find libconfig, allows user to set flags manually.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1129
diff changeset
20 else(NOT LIBCONFIGPP_FOUND)
d82cc6e5bb65 Fixed error when pkg-config couldn't find libconfig, allows user to set flags manually.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1129
diff changeset
21 set(LIBCONFIG_CXXFLAGS ${LIBCONFIGPP_CFLAGS} CACHE STRING "libconfig++ compiler flags")
d82cc6e5bb65 Fixed error when pkg-config couldn't find libconfig, allows user to set flags manually.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1129
diff changeset
22 set(LIBCONFIG_LDFLAGS ${LIBCONFIGPP_LDFLAGS} CACHE STRING "libconfig++ linker flags")
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
23 endif(NOT LIBCONFIGPP_FOUND)
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
24 endif(NOT PKG_CONFIG_FOUND)
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
25
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
26 find_program(LLVM_CONFIG llvm-config ${LLVM_INSTDIR}/bin DOC "path to llvm-config tool")
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
27 # get llvm's install dir. a little hackish, we could do something like llvm-config --prefix, but this does as well
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
28 string(REPLACE "/bin/llvm-config" "" LLVM_DIR ${LLVM_CONFIG})
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
29
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
30 set(LLVM_INSTDIR ${LLVM_DIR} CACHE PATH "LLVM installation directory" FORCE)
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
31 if(NOT LLVM_INSTDIR)
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
32 message(FATAL_ERROR "llvm not found")
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
33 endif(NOT LLVM_INSTDIR)
749
db2dd9861600 Add basic CMake build file.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
34
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
35 execute_process(
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
36 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --host-target
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
37 OUTPUT_VARIABLE HOST_TARGET
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
38 OUTPUT_STRIP_TRAILING_WHITESPACE
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
39 )
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
40 execute_process(
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
41 COMMAND /bin/sh ${PROJECT_SOURCE_DIR}/find-alt-triple.sh ${HOST_TARGET}
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
42 OUTPUT_VARIABLE HOST_ALT_TARGET
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
43 OUTPUT_STRIP_TRAILING_WHITESPACE
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
44 )
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
45 execute_process(
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
46 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --cxxflags
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
47 OUTPUT_VARIABLE LLVM_CXXFLAGS
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
48 OUTPUT_STRIP_TRAILING_WHITESPACE
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
49 )
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
50 execute_process(
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
51 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --ldflags
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
52 OUTPUT_VARIABLE LLVM_LDFLAGS
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
53 OUTPUT_STRIP_TRAILING_WHITESPACE
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
54 )
1519
6182ceeb336a LLVM_INSTDIR -> LLVM_INCLUDEDIR fix by d0k.
Christian Kamm <kamm incasoftware de>
parents: 1518
diff changeset
55 execute_process(
6182ceeb336a LLVM_INSTDIR -> LLVM_INCLUDEDIR fix by d0k.
Christian Kamm <kamm incasoftware de>
parents: 1518
diff changeset
56 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --includedir
6182ceeb336a LLVM_INSTDIR -> LLVM_INCLUDEDIR fix by d0k.
Christian Kamm <kamm incasoftware de>
parents: 1518
diff changeset
57 OUTPUT_VARIABLE LLVM_INCLUDEDIR
6182ceeb336a LLVM_INSTDIR -> LLVM_INCLUDEDIR fix by d0k.
Christian Kamm <kamm incasoftware de>
parents: 1518
diff changeset
58 OUTPUT_STRIP_TRAILING_WHITESPACE
6182ceeb336a LLVM_INSTDIR -> LLVM_INCLUDEDIR fix by d0k.
Christian Kamm <kamm incasoftware de>
parents: 1518
diff changeset
59 )
1105
cdb7e1167803 - Fixed building tango-user-ldc on x86-32.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1103
diff changeset
60
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
61 set(D_VERSION 1 CACHE STRING "D language version")
828
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
62 set(PROGRAM_PREFIX CACHE STRING "prepended to ldc binary name")
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
63 set(PROGRAM_SUFFIX CACHE STRING "appended to ldc binary name")
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
64 option(USE_BOEHM_GC "use the Boehm garbage collector internally")
821
8f0b24bc55f0 Added CMake option to disable generation of ClassInfo.offTi arrays, defaults to OFF.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 785
diff changeset
65 option(GENERATE_OFFTI "generate complete ClassInfo.offTi arrays")
1558
3adcb70700cb Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents: 1547
diff changeset
66 option(USE_METADATA "use metadata and related custom optimization passes")
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
67
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
68 if(D_VERSION EQUAL 1)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
69 set(DMDFE_PATH dmd)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
70 set(LDC_EXE ldc)
1453
f35a9a77d256 More tweaks.
Robert Clipsham <robert@octarineparrot.com>
parents: 1396
diff changeset
71 set(LDMD_EXE ldmd)
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
72 add_definitions(-DDMDV1)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
73 elseif(D_VERSION EQUAL 2)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
74 set(DMDFE_PATH dmd2)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
75 set(LDC_EXE ldc2)
1453
f35a9a77d256 More tweaks.
Robert Clipsham <robert@octarineparrot.com>
parents: 1396
diff changeset
76 set(LDMD_EXE ldmd2)
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
77 add_definitions(-DDMDV2)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
78 else(D_VERSION EQUAL 1)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
79 message(FATAL_ERROR "unsupported D version")
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
80 endif(D_VERSION EQUAL 1)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
81
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
82 file(MAKE_DIRECTORY
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
83 ${PROJECT_BINARY_DIR}/bin
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
84 ${PROJECT_BINARY_DIR}/${DMDFE_PATH}
1065
dc576c7e4b1e Fix to make sure to create gen/ in build dir and unbreak build with older perl
Frits van Bommel <fvbommel wxs.nl>
parents: 1064
diff changeset
85 ${PROJECT_BINARY_DIR}/gen
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
86 )
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
87
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
88 # idgen and impcnvgen
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
89 set_source_files_properties(
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
90 ${DMDFE_PATH}/idgen.c
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
91 ${DMDFE_PATH}/impcnvgen.c
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
92 PROPERTIES LANGUAGE CXX
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
93 )
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
94 add_executable(idgen ${DMDFE_PATH}/idgen.c)
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
95 add_executable(impcnvgen ${DMDFE_PATH}/impcnvgen.c)
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
96 # cmake 2.4
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
97 set_target_properties(
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
98 idgen impcnvgen PROPERTIES
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
99 LINKER_LANGUAGE CXX
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
100 RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${DMDFE_PATH}
1051
dc608dc33081 Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents: 1032
diff changeset
101 COMPILE_FLAGS ${LLVM_CXXFLAGS}
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
102 )
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
103 get_target_property(IDGEN_LOC idgen LOCATION)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
104 get_target_property(IMPCNVGEN_LOC impcnvgen LOCATION)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
105 #
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
106 add_custom_command(
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
107 OUTPUT
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
108 ${PROJECT_BINARY_DIR}/${DMDFE_PATH}/id.c
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
109 ${PROJECT_BINARY_DIR}/${DMDFE_PATH}/id.h
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
110 # 2.4
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
111 COMMAND ${IDGEN_LOC}
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
112 #COMMAND idgen
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
113 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${DMDFE_PATH}
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
114 DEPENDS idgen
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
115 )
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
116 add_custom_command(
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
117 OUTPUT ${PROJECT_BINARY_DIR}/${DMDFE_PATH}/impcnvtab.c
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
118 # 2.4
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
119 COMMAND ${IMPCNVGEN_LOC}
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
120 #COMMAND impcnvgen
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
121 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${DMDFE_PATH}
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
122 DEPENDS impcnvgen
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
123 )
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
124 set(LDC_GENERATED
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
125 ${PROJECT_BINARY_DIR}/${DMDFE_PATH}/id.c
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
126 ${PROJECT_BINARY_DIR}/${DMDFE_PATH}/id.h
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
127 ${PROJECT_BINARY_DIR}/${DMDFE_PATH}/impcnvtab.c
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
128 )
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
129 # idgen and impcnvgen done
749
db2dd9861600 Add basic CMake build file.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
130
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
131 set(DEFAULT_TARGET ${HOST_TARGET} CACHE STRING "default target")
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
132 set(DEFAULT_ALT_TARGET ${HOST_ALT_TARGET} CACHE STRING "default alt target")
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
133
1519
6182ceeb336a LLVM_INSTDIR -> LLVM_INCLUDEDIR fix by d0k.
Christian Kamm <kamm incasoftware de>
parents: 1518
diff changeset
134 include_directories(. ${DMDFE_PATH} ${DMDFE_PATH}/root ${PROJECT_BINARY_DIR}/${DMDFE_PATH} ${PROJECT_BINARY_DIR} ${LLVM_INCLUDEDIR})
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
135
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
136 set(EXTRA_LLVM_MODULES "" CACHE STRING "extra llvm components to link in (see llvm-config --components)")
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
137 separate_arguments(EXTRA_LLVM_MODULES)
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
138 execute_process(
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
139 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --libfiles bitwriter linker ipo instrumentation backend ${EXTRA_LLVM_MODULES}
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
140 OUTPUT_VARIABLE LLVM_LIBS
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
141 OUTPUT_STRIP_TRAILING_WHITESPACE
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
142 )
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
143
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
144 # build a define that contains all LLVM targets required and is usable for
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
145 # preprocessor code generation. start with the native target.
1520
1a93c3da09ef Yet another fix for finding llvm's config file.
Christian Kamm <kamm incasoftware de>
parents: 1519
diff changeset
146 find_path(LLVM_CONFIG_FILE_PATH config.h PATHS ${LLVM_INCLUDEDIR}/llvm/Config ${LLVM_INCLUDEDIR}/Config NO_DEFAULT_PATH)
1522
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
147 if(LLVM_CONFIG_FILE_PATH STREQUAL "LLVM_CONFIG_FILE_PATH-NOTFOUND")
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
148 message("Couldn't find your llvm Config.h file in ${LLVM_INCLUDEDIR}, no native target will be initialized.")
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
149 else(LLVM_CONFIG_FILE_PATH STREQUAL "LLVM_CONFIG_FILE_PATH-NOTFOUND")
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
150 file(STRINGS ${LLVM_CONFIG_FILE_PATH}/config.h LLVM_NATIVE_ARCH REGEX "^#define LLVM_NATIVE_ARCH")
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
151 if(LLVM_NATIVE_ARCH)
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
152 string(REGEX REPLACE "^#define LLVM_NATIVE_ARCH (.*)Target$" "\\1" LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH})
1547
259b031f3d22 Some minor cleanups
Benjamin Kramer <benny.kra@gmail.com>
parents: 1522
diff changeset
153 message(STATUS "Found native target ${LLVM_NATIVE_ARCH}")
1522
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
154 set(LLVM_MODULES_DEFINE "LLVM_TARGET(${LLVM_NATIVE_ARCH})")
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
155 else(LLVM_NATIVE_ARCH)
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
156 message("Couldn't find the LLVM_NATIVE_ARCH define in ${LLVM_CONFIG_FILE_PATH}/config.h. Probably you have an older LLVM and can ignore this warning.")
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
157 endif(LLVM_NATIVE_ARCH)
6766485fb584 Better error handling for CMake LLVM config file detection.
Christian Kamm <kamm incasoftware de>
parents: 1520
diff changeset
158 endif(LLVM_CONFIG_FILE_PATH STREQUAL "LLVM_CONFIG_FILE_PATH-NOTFOUND")
1518
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
159 # chain the extra target list to the define
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
160 foreach(EXTRA_TARGET ${EXTRA_LLVM_MODULES})
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
161 set(LLVM_MODULES_DEFINE "${LLVM_MODULES_DEFINE} LLVM_TARGET(${EXTRA_TARGET})")
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
162 endforeach(EXTRA_TARGET)
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
163 set_source_files_properties(
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
164 ${PROJECT_SOURCE_DIR}/gen/main.cpp PROPERTIES
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
165 COMPILE_DEFINITIONS LDC_TARGETS=${LLVM_MODULES_DEFINE}
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
166 )
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
167
26d061e61b02 Initialize LLVM target and asmprinter for the native and extra targets.
Christian Kamm <kamm incasoftware de>
parents: 1453
diff changeset
168
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
169 file(GLOB FE_SRC ${DMDFE_PATH}/*.c)
1194
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1139
diff changeset
170 file(GLOB FE_SRC_ROOT ${DMDFE_PATH}/root/*.c)
1275
bedf0bfb8fdb Implement first D-specific optimization pass: -simplify-drtcalls.
Frits van Bommel <fvbommel wxs.nl>
parents: 1256
diff changeset
171 file(GLOB_RECURSE GEN_SRC gen/*.cpp)
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
172 file(GLOB IR_SRC ir/*.cpp)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
173 # exclude idgen and impcnvgen and generated sources, just in case
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
174 list(REMOVE_ITEM FE_SRC
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
175 ${PROJECT_SOURCE_DIR}/${DMDFE_PATH}/idgen.c
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
176 ${PROJECT_SOURCE_DIR}/${DMDFE_PATH}/impcnvgen.c
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
177 ${PROJECT_SOURCE_DIR}/${DMDFE_PATH}/id.c
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
178 ${PROJECT_SOURCE_DIR}/${DMDFE_PATH}/impcnvtab.c
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
179 )
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
180 set(LDC_SOURCE_FILES
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
181 ${LDC_GENERATED}
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
182 ${FE_SRC}
1194
1853dcd9b944 Moved some DMDFE files into a seperate dmd/root subdir to closer match the DMD file structure since 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1139
diff changeset
183 ${FE_SRC_ROOT}
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
184 ${GEN_SRC}
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
185 ${IR_SRC}
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
186 )
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
187 set_source_files_properties(
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
188 ${LDC_SOURCE_FILES} PROPERTIES
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
189 LANGUAGE CXX
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
190 )
749
db2dd9861600 Add basic CMake build file.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
191
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
192 add_definitions(
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
193 -DIN_LLVM
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
194 -D_DH
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
195 -DOPAQUE_VTBLS
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
196 )
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
197
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
198 if(UNIX)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
199 add_definitions(-DPOSIX)
829
0a31c60a6bc1 .. and fixed the install target (hopefully)
elrood
parents: 828
diff changeset
200 set(CONF_INST_DIR bin)
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
201 endif(UNIX)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
202
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
203 if(USE_BOEHM_GC)
883
b52d5de7783f GC defines and linkage changes.
Christian Kamm <kamm incasoftware de>
parents: 853
diff changeset
204 add_definitions(-DREDIRECT_MALLOC=GC_malloc -DIGNORE_FREE)
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
205 endif(USE_BOEHM_GC)
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
206
821
8f0b24bc55f0 Added CMake option to disable generation of ClassInfo.offTi arrays, defaults to OFF.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 785
diff changeset
207 if(GENERATE_OFFTI)
8f0b24bc55f0 Added CMake option to disable generation of ClassInfo.offTi arrays, defaults to OFF.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 785
diff changeset
208 add_definitions(-DGENERATE_OFFTI)
8f0b24bc55f0 Added CMake option to disable generation of ClassInfo.offTi arrays, defaults to OFF.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 785
diff changeset
209 endif(GENERATE_OFFTI)
8f0b24bc55f0 Added CMake option to disable generation of ClassInfo.offTi arrays, defaults to OFF.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 785
diff changeset
210
1558
3adcb70700cb Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents: 1547
diff changeset
211 if(USE_METADATA)
3adcb70700cb Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents: 1547
diff changeset
212 add_definitions(-DUSE_METADATA)
3adcb70700cb Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents: 1547
diff changeset
213 endif(USE_METADATA)
3adcb70700cb Added back option to disable metadata generation and users. Set USE_METADATA to OFF in ccmake.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents: 1547
diff changeset
214
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
215 if(CMAKE_MINOR_VERSION LESS 6)
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
216 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "output dir for built executables")
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
217 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib CACHE PATH "output dir for built libraries")
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
218 add_definitions(-DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TARGET}\\")
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
219 add_definitions(-DDEFAULT_ALT_TARGET_TRIPLE=\\"${DEFAULT_ALT_TARGET}\\")
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
220 add_definitions(-DLDC_INSTALL_PREFIX=\\"${CMAKE_INSTALL_PREFIX}\\")
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
221 else(CMAKE_MINOR_VERSION LESS 6)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
222 add_definitions(-DDEFAULT_TARGET_TRIPLE="${DEFAULT_TARGET}")
1021
d1ec9ff0e9ba Implemented basic -m32 and -m64 options.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 982
diff changeset
223 add_definitions(-DDEFAULT_ALT_TARGET_TRIPLE="${DEFAULT_ALT_TARGET}")
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
224 add_definitions(-DLDC_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
225 endif(CMAKE_MINOR_VERSION LESS 6)
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
226
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
227 add_executable(${LDC_EXE} ${LDC_SOURCE_FILES})
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
228
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents: 829
diff changeset
229 # generate revision info
1064
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
230 configure_file(
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
231 ${PROJECT_SOURCE_DIR}/revisions.pl.in
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
232 ${PROJECT_BINARY_DIR}/revisions.pl
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
233 @ONLY
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
234 )
1074
d9820e08bb84 Make sure revisions.pl always runs so revisions.h doesn't get out of date.
Frits van Bommel <fvbommel wxs.nl>
parents: 1071
diff changeset
235 add_custom_target(
d9820e08bb84 Make sure revisions.pl always runs so revisions.h doesn't get out of date.
Frits van Bommel <fvbommel wxs.nl>
parents: 1071
diff changeset
236 gen_revs_h
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents: 829
diff changeset
237 COMMAND ${PERL_EXECUTABLE} ${PROJECT_BINARY_DIR}/revisions.pl
1074
d9820e08bb84 Make sure revisions.pl always runs so revisions.h doesn't get out of date.
Frits van Bommel <fvbommel wxs.nl>
parents: 1071
diff changeset
238 DEPENDS ${PROJECT_BINARY_DIR}/revisions.pl
1113
123812e02bc8 Split out LLVM_REV into separate header, to reduce rebuilding when only the LDC
Frits van Bommel <fvbommel wxs.nl>
parents: 1107
diff changeset
239 COMMENT "Generating revisions.h and llvm-version.h"
1064
f0b6549055ab Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Frits van Bommel <fvbommel wxs.nl>
parents: 1051
diff changeset
240 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/gen
853
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents: 829
diff changeset
241 )
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents: 829
diff changeset
242 add_dependencies(${LDC_EXE} gen_revs_h)
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents: 829
diff changeset
243 #
82ad6c0c601c Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents: 829
diff changeset
244
828
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
245 set(LDC_EXE_NAME ${PROGRAM_PREFIX}${LDC_EXE}${PROGRAM_SUFFIX})
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
246
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
247 set_target_properties(
758
f04dde6e882c Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 753
diff changeset
248 ${LDC_EXE} PROPERTIES
828
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
249 OUTPUT_NAME ${LDC_EXE_NAME}
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
250 RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
1103
b30fe7e1dbb9 - Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1074
diff changeset
251 COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LIBCONFIG_CXXFLAGS} -Wno-deprecated -Wno-write-strings"
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
252 )
749
db2dd9861600 Add basic CMake build file.
Christian Kamm <kamm incasoftware de>
parents:
diff changeset
253
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
254 # LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems
1107
015b1634b33f Unquote ${LIBCONFIG_LDFLAGS} in target_link_libraries().
Frits van Bommel <fvbommel wxs.nl>
parents: 1105
diff changeset
255 target_link_libraries(${LDC_EXE} "${LLVM_LDFLAGS} ${LLVM_LIBS}" ${LIBCONFIG_LDFLAGS})
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
256 if(WIN32)
1256
6af2359b433a Change needed for mingw
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents: 1194
diff changeset
257 target_link_libraries(${LDC_EXE} config++ imagehlp psapi)
828
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
258 set(CONF_INST_DIR bin)
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
259 endif(WIN32)
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
260
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
261 if(USE_BOEHM_GC)
883
b52d5de7783f GC defines and linkage changes.
Christian Kamm <kamm incasoftware de>
parents: 853
diff changeset
262 target_link_libraries(${LDC_EXE} ${PROJECT_SOURCE_DIR}/libgc.a)
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
263 endif(USE_BOEHM_GC)
750
d05fc504a3a0 Improve CMake build file.
Christian Kamm <kamm incasoftware de>
parents: 749
diff changeset
264
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
265 get_target_property(LDC_LOC ${LDC_EXE} LOCATION)
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
266
753
405e40f20ef9 Switch to Elrood's rewritten CMakeLists.txt.
Christian Kamm <kamm incasoftware de>
parents: 750
diff changeset
267 # TODO: testrun
785
ac39e5449ca5 Apply Elrood's CMake changes from #124. Thanks a lot!
Christian Kamm <kamm incasoftware de>
parents: 758
diff changeset
268
828
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
269 install(TARGETS ${LDC_EXE} DESTINATION bin)
1453
f35a9a77d256 More tweaks.
Robert Clipsham <robert@octarineparrot.com>
parents: 1396
diff changeset
270 install(FILES ${PROJECT_SOURCE_DIR}/bin/${LDMD_EXE} DESTINATION bin)
829
0a31c60a6bc1 .. and fixed the install target (hopefully)
elrood
parents: 828
diff changeset
271 install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}.conf DESTINATION ${CONF_INST_DIR})
1129
8403fec8c34c Add dmd-style configuration file for rebuild usage. See #236 and thanks to ccuter for the patch!
Christian Kamm <kamm incasoftware de>
parents: 1113
diff changeset
272 install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}.rebuild.conf DESTINATION ${CONF_INST_DIR})
829
0a31c60a6bc1 .. and fixed the install target (hopefully)
elrood
parents: 828
diff changeset
273 install(DIRECTORY ${PROJECT_BINARY_DIR}/lib DESTINATION . USE_SOURCE_PERMISSIONS)
828
03b0c817a1a3 added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
elrood
parents: 821
diff changeset
274
829
0a31c60a6bc1 .. and fixed the install target (hopefully)
elrood
parents: 828
diff changeset
275 add_subdirectory(runtime EXCLUDE_FROM_ALL)