annotate cmake/FindD.cmake @ 401:827147052d8d

Corrected typo in CMake error message, fixes #68.
author David Nadlinger <code@klickverbot.at>
date Thu, 17 Mar 2011 19:11:40 +0100
parents d2f48c4cb3e3
children 8564ab82ea42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
1 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
2 ## Variables.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
3 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
4
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 224
diff changeset
5 ## Find D compiler and parse its version.
166
52da31f967f0 CMake: minor fix
SokoL_SD
parents: 139
diff changeset
6 find_program(DC NAMES dmd ldc)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
7 if (DC)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
8 get_filename_component(dc_path ${DC} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
9 if("${dc_path}" STREQUAL ${CMAKE_BINARY_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
10 get_filename_component(DC ${DC} NAME)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
11 endif("${dc_path}" STREQUAL ${CMAKE_BINARY_DIR})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
12 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
13 string(REGEX MATCH "Digital Mars D Compiler v[0-9]\\.[0-9]+" dmd_version "${d_output}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
14 if (dmd_version)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
15 set(D_IS_MARS true)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
16 set(D_IS_DMD true)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
17 set(D_COMPILER_NAME "Digital Mars D Compiler")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
18 string(REGEX REPLACE "Digital Mars D Compiler v([0-9])\\.[0-9]+" "\\1" D_VERSION "${dmd_version}")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
19 string(REGEX REPLACE "Digital Mars D Compiler v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${dmd_version}")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
20 else (dmd_version)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
21 string(REGEX MATCH "LLVM-based D Compiler" is_ldc "${d_output}")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
22 if (is_ldc)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
23 exec_program(${DC} ARGS "--version" OUTPUT_VARIABLE d_output)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
24 string(REGEX MATCH "based on DMD v[0-9]\\.[0-9]+" ldc_version "${d_output}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
25 set(D_IS_LLVM true)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
26 set(D_IS_LDC true)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
27 if(ldc_version)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
28 set(D_IS_LLVM true)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
29 set(D_COMPILER_NAME "LLVM-based D Compiler")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
30 string(REGEX REPLACE "based on DMD v([0-9])\\.[0-9]+" "\\1" D_VERSION "${ldc_version}")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
31 string(REGEX REPLACE "based on DMD v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${ldc_version}")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
32 else(ldc_version)
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 224
diff changeset
33 message(FATAL_ERROR "LDC compiler found, but the version can not be processed")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
34 endif(ldc_version)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
35 else (is_ldc)
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
36 message(FATAL_ERROR "D compiler is not found")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
37 endif(is_ldc)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
38 endif(dmd_version)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
39 message(STATUS "D compiler found -- ${D_COMPILER_NAME} v${D_VERSION}.${D_FRONTEND}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
40 else (DC)
401
827147052d8d Corrected typo in CMake error message, fixes #68.
David Nadlinger <code@klickverbot.at>
parents: 384
diff changeset
41 message(FATAL_ERROR "D compiler is not found")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
42 endif (DC)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
43
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
44 ## Get D compiler path.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
45 get_filename_component(DC_PATH ${DC} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
46 if("${DC_PATH}" STREQUAL "")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
47 find_program(dc_path_tmp ${DC})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
48 get_filename_component(DC_PATH ${dc_path_tmp} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
49 mark_as_advanced(dc_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
50 endif("${DC_PATH}" STREQUAL "")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
51 get_filename_component(dc_parent_dir ${DC_PATH} NAME)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
52 if("${dc_parent_dir}" STREQUAL "bin")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
53 get_filename_component(DC_PATH ${DC_PATH} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
54 endif("${dc_parent_dir}" STREQUAL "bin")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
55
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
56 #option(ONE_BUILD_COMMAND "Build in one command" "OFF")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
57 set(ONE_BUILD_COMMAND OFF) ## TODO: test it and uncomment the previous line.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
58
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
59 if (NOT ONE_BUILD_COMMAND)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
60 if(D_IS_MARS)
281
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
61 set(opt_tmp "ON")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
62 else(D_IS_MARS)
281
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
63 set(opt_tmp "OFF")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
64 endif(D_IS_MARS)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
65 option(SINGLE_D_OBJECT "Build all d sources to one object file" ${opt_tmp})
181
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
66 if(D_IS_LLVM)
281
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
67 set(D_FLAGS ${D_FLAGS} -singleobj)
181
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
68 endif(D_IS_LLVM)
281
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
69 if(CMAKE_HOST_WIN32 AND D_IS_MARS)
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
70 set(D_MODULES_PER_OBJECT 200 CACHE STRING "Max number of modules per object file")
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
71 else(CMAKE_HOST_WIN32 AND D_IS_MARS)
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
72 set(D_MODULES_PER_OBJECT 10000 CACHE STRING "Max number of modules per object file")
7f2e3ffa1c33 Workaround of the major dmd/optlink bug. All examples that failed on Windows now work.
eldar
parents: 275
diff changeset
73 endif(CMAKE_HOST_WIN32 AND D_IS_MARS)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
74 endif(NOT ONE_BUILD_COMMAND)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
75
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 224
diff changeset
76 ## Specific flags for build configurations.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
77 ## TODO: Add another targets.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
78 set(D_RELEASE_FLAGS -O -release)
139
825ac6364d2f CMake: fix debug flags for ldc
SokoL_SD
parents: 132
diff changeset
79 set(D_DEBUG_FLAGS -g )
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
80 if(D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
81 set(D_RELEASE_FLAGS ${D_RELEASE_FLAGS} -enable-inlining)
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
82 set(D_VERSION_FLAG -d-version)
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
83 set(D_DEBUG_FLAG -d-debug)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
84 else(D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
85 set(D_RELEASE_FLAGS ${D_RELEASE_FLAGS} -inline)
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
86 set(D_VERSION_FLAG -version)
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
87 set(D_DEBUG_FLAG -debug)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
88 endif(D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
89 if(CMAKE_HOST_WIN32)
368
185df9220ea7 Fixed startsWith. Implemented meta-object members as ranges. Freed QMetaObject from stuff that belongs to MetaClass
Max Samukha <maxter@maxter.com>
parents: 366
diff changeset
90 # Linking fails with this. Commenting out for now.
185df9220ea7 Fixed startsWith. Implemented meta-object members as ranges. Freed QMetaObject from stuff that belongs to MetaClass
Max Samukha <maxter@maxter.com>
parents: 366
diff changeset
91 # set(D_RELEASE_FLAGS ${D_RELEASE_FLAGS} -L/subsystem:windows)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
92 endif(CMAKE_HOST_WIN32)
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
93 set(D_DEBUG_FLAGS ${D_DEBUG_FLAGS} ${D_DEBUG_FLAG})
139
825ac6364d2f CMake: fix debug flags for ldc
SokoL_SD
parents: 132
diff changeset
94
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
95 # Unittest flags.
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
96 option(UNITTEST "Includes unittests" "OFF")
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
97 if(UNITTEST)
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
98 set(D_FLAGS ${D_FLAGS} -unittest)
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
99 endif(UNITTEST)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
100
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
101 ## Settings.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
102 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
103 set(D_OBJECT_SUFFIX .obj)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
104 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
105 set(D_LIB_SUFFIX .lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
106 set(D_LIB_PREFIX )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
107 elseif(D_IS_LDC)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
108 set(D_LIB_SUFFIX .a)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
109 set(D_LIB_PREFIX lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
110 endif(D_IS_MARS)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
111 elseif(CMAKE_HOST_UNIX)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
112 set(D_LIB_SUFFIX .a)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
113 set(D_LIB_PREFIX lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
114 set(D_OBJECT_SUFFIX .o)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
115 endif(CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
116
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
117 ##--------------------------------------------
224
7f150ad4cb5f spelling fix in CMakeD
SokoL_SD
parents: 215
diff changeset
118 ## Macros and functions.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
119 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
120
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
121 macro(add_d_flags option)
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
122 foreach(arg_tmp ${ARGN})
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
123 set(D_FLAGS ${D_FLAGS} ${option}=${arg_tmp})
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
124 endforeach(arg_tmp ${ARGN})
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
125 endmacro(add_d_flags option)
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
126
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
127 macro(add_d_versions)
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
128 add_d_flags(${D_VERSION_FLAG} ${ARGN})
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
129 endmacro(add_d_versions)
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
130
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
131 macro(add_d_debugs)
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
132 add_d_flags(${D_DEBUG_FLAG} ${ARGN})
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
133 endmacro(add_d_debugs)
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
134
224
7f150ad4cb5f spelling fix in CMakeD
SokoL_SD
parents: 215
diff changeset
135 ## Make a native path.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
136 ## Usage:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
137 ## set(path c:/file_path/file_name.cpp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
138 ## make_native_path(path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
139 ## message(STATUS ${path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
140 ## Output:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
141 ## -- "c:\file_path\file_name.cpp"
384
d2f48c4cb3e3 Same behavior of shared libs on linux and windows. Minor build script fixes.
Max Samukha <maxter@spambox.com>
parents: 368
diff changeset
142 ## Command "file(TO_NATIVE_PATH ...)" gives incorrect results on Windows
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
143 macro(make_native_path pathname)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
144 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
145 # An extra \\ escape is necessary to get a \ through CMake's processing.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
146 string(REPLACE "/" "\\" ${pathname} "${${pathname}}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
147 # Enclose with UNESCAPED quotes. This means we need to escape our
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
148 # quotes once here, i.e. with \"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
149 set(${pathname} \"${${pathname}}\")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
150 endif(CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
151 endmacro(make_native_path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
152
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
153 ##
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
154 ## Example:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
155 ## set(path 24.3+23.bin)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
156 ## obj_path(path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
157 ## message(STATUS ${path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
158 ## Example output:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
159 ## -- 24\.3\+23\.bin
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
160 macro(regex_safe_string outvariable)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
161 set(${outvariable} ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
162 set(__regex_chars__ ^ $ . ] [ - * + ? | \( \))
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
163 foreach(__regex_char__ ${__regex_chars__})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
164 string(REPLACE "${__regex_char__}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
165 "\\${__regex_char__}" ${outvariable} ${${outvariable}}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
166 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
167 endforeach(__regex_char__ ${__regex_chars__})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
168 endmacro(regex_safe_string outvariable)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
169
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
170 ## Remove unnecessary path to the object file.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
171 ## path -- path to object file.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
172 ## Example:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
173 ## set(path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/target.dir/main.d.obj)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
174 ## obj_path(path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
175 ## message(STATUS ${path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
176 ## Example output:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
177 ## -- CMakeFiles/target.dir/main.d.obj
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
178 macro(obj_path path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
179 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
180 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
181 set(regexp_str_tmp "(${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
182 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ${path} "${${path}}")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
183 endmacro(obj_path path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
184
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
185 ## Compile d files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
186 ## target -- name of a new target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
187 ## objects_list -- created object files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
188 ## params -- sources files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
189 macro(compile_d_files target objects_list)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
190 set(${objects_list})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
191 set(tmp_dir_tmp ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
192
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
193 set(type_tmp SOURCES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
194 set(SOURCES_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
195 set(FLAGS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
196
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
197 ## Parse parameters list.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
198 set(params_tmp SOURCES FLAGS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
199 foreach(arg_tmp ${ARGN})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
200 set(found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
201 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
202 foreach(param_tmp ${params_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
203 if(arg_tmp STREQUAL param_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
204 set(type_tmp ${param_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
205 set(found_type_tmp 1)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
206 break(param_tmp ${params_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
207 endif(arg_tmp STREQUAL param_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
208 endforeach(param_tmp ${params_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
209 endif(NOT found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
210 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
211 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
212 endif(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
213 endforeach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
214
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
215 if(NOT SINGLE_D_OBJECT)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
216 set(${objects_list})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
217 foreach (d_source_p_tmp ${SOURCES_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
218 get_filename_component(ext_tmp ${d_source_p_tmp} EXT)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
219 find_file(d_source_p_tmp ${d_source_p_tmp} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
220 ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
221 set (d_source_tmp ${d_source_p_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
222 obj_path(d_source_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
223 set(d_obj_tmp ${tmp_dir_tmp}/${d_source_tmp}${D_OBJECT_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
224 set(${objects_list} ${${objects_list}} ${d_obj_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
225 get_filename_component(path_tmp ${d_obj_tmp} PATH)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
226 file(MAKE_DIRECTORY ${path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
227 set(d_obj_out_tmp ${d_obj_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
228 obj_path(d_obj_out_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
229 #get_imported_files(depends_tmp ${d_source_p_tmp}) ## Too slow.....
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
230 add_custom_command(OUTPUT "${d_obj_tmp}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
231 COMMAND "${DC}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
232 ARGS ${FLAGS_tmp} ${d_source_p_tmp} -c -of${d_obj_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
233 COMMENT "Building ${d_obj_out_tmp}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
234 DEPENDS ${d_source_p} ${depends_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
235 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
236 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
237 endforeach (d_source_p_tmp ${SOURCES_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
238 else(NOT SINGLE_D_OBJECT)
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
239 if(D_IS_LDC)
273
2161595da42b Unittest flags.
SokoL_SD
parents: 245
diff changeset
240 set(FLAGS_tmp ${FLAGS_tmp} -oq )
274
f5606687c578 VERBOSE_DEBUG flag
SokoL_SD
parents: 273
diff changeset
241 endif(D_IS_LDC)
181
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
242 set(count_objects_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
243 set(files${count_objects_tmp}_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
244 set(counter_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
245 set(files_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
246 set(objects_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
247 foreach (d_source_p_tmp ${SOURCES_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
248 math(EXPR counter_tmp "${counter_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
249 set(files${count_objects_tmp}_tmp ${files${count_objects_tmp}_tmp} ${d_source_p_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
250 if(counter_tmp GREATER D_MODULES_PER_OBJECT)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
251 math(EXPR count_objects_tmp "${count_objects_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
252 set(files${count_objects_tmp}_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
253 set(counter_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
254 endif(counter_tmp GREATER D_MODULES_PER_OBJECT)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
255 endforeach (d_source_p_tmp ${SOURCES_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
256
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
257 if(files${count_objects_tmp}_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
258 math(EXPR count_objects_tmp "${count_objects_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
259 endif(files${count_objects_tmp}_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
260
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
261 set(id_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
262 while(id_tmp LESS ${count_objects_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
263 set(object_tmp ${tmp_dir_tmp}/${target}${id_tmp}${D_OBJECT_SUFFIX})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
264 set(d_obj_out_tmp ${${object_tmp}})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
265 obj_path(d_obj_out_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
266 set(parameters_tmp ${FLAGS_tmp} -c ${files${id_tmp}_tmp} -of${object_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
267 set(parameters_list_file_tmp ${tmp_dir_tmp}/parameters${id_tmp}_obj)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
268 if(CMAKE_HOST_WIN32)
181
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
269 file(REMOVE ${parameters_list_file_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
270 foreach(arg_tmp ${parameters_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
271 file(APPEND ${parameters_list_file_tmp} "${arg_tmp}\n")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
272 endforeach(arg_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
273 set(param_tmp @${parameters_list_file_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
274 elseif(CMAKE_HOST_UNIX)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
275 set(param_tmp ${parameters_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
276 endif(CMAKE_HOST_WIN32)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
277 #get_imported_files(depends_tmp ${ARGN})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
278 add_custom_command(OUTPUT "${object_tmp}"
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
279 COMMAND "${DC}"
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
280 ARGS ${param_tmp}
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
281 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
282 DEPENDS ${files${id_tmp}_tmp} ${depends_tmp}
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
283 COMMENT ""
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
284 )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
285 set(objects_tmp ${objects_tmp} ${object_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
286 math(EXPR id_tmp "${id_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
287 endwhile(id_tmp LESS ${count_objects_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
288
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
289 set(${objects_list} ${objects_tmp})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
290 endif(NOT SINGLE_D_OBJECT)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
291 #add_custom_target(${target} DEPENDS "${${objects_list}}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
292 endmacro(compile_d_files objects_list)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
293
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
294
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
295 ## Add D target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
296 ## name -- target name.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
297 ## Params:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
298 ## TYPE -- target type.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
299 ## STATIC -- static library.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
300 ## SHARED -- shared library.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
301 ## BINARY -- executable.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
302 ## SOURCES -- sources of the target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
303 ## INCLUDES -- include paths.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
304 ## FLAGS -- build flags.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
305 ## LIBS -- libraries for link.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
306 ## LIB_PATHS -- libraries paths.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
307 ## DEPENDS -- target depends.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
308 macro(add_d_target name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
309 set(type_tmp SOURCES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
310 set(TYPE_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
311 set(INCLUDES_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
312 set(FLAGS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
313 set(SOURCES_tmp )
203
d3383b16f1d7 Add a 'NO_DEPS_SOURCES' option to the 'add_d_target' macro. And use it for resources and forms in QtD examples.
SokoL_SD
parents: 181
diff changeset
314 set(GEN_FILES_tmp )
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
315 set(OBJECTS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
316 set(LIBS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
317 set(LIB_PATHS_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
318 set(DEPENDS_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
319 set(OUTPUT_PATH_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
320 set(compile_flags_tmp ${D_FLAGS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
321 set(additional_commands_tmp )
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
322 set(detect_deps_tmp 1)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
323 set(link_flags_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
324
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
325 ## Parse parameters list.
203
d3383b16f1d7 Add a 'NO_DEPS_SOURCES' option to the 'add_d_target' macro. And use it for resources and forms in QtD examples.
SokoL_SD
parents: 181
diff changeset
326 set(params_tmp TYPE INCLUDES FLAGS SOURCES NO_DEPS_SOURCES OBJECTS LIBS LIB_PATHS DEPENDS OUTPUT_PATH)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
327
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
328 foreach(arg_tmp ${ARGN})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
329 set(found_type_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
330 if(${arg_tmp} STREQUAL "NOT_DETECT_DEPENDS")
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
331 set(detect_deps_tmp 0)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
332 set(found_type_tmp 1)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
333 endif(${arg_tmp} STREQUAL "NOT_DETECT_DEPENDS")
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
334 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
335 foreach(param_tmp ${params_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
336 if(arg_tmp STREQUAL param_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
337 set(type_tmp ${param_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
338 set(found_type_tmp 1)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
339 break(param_tmp ${params_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
340 endif(arg_tmp STREQUAL param_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
341 endforeach(param_tmp ${params_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
342 endif(NOT found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
343 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
344 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
345 endif(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
346 endforeach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
347
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
348 ## Init target type.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
349 if (OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
350 set(output_name_tmp "${OUTPUT_PATH_tmp}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
351 endif (OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
352 if("${TYPE_tmp}" STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
353 set(link_flags_tmp ${link_flags_tmp} -lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
354 if(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
355 if(ARCHIVE_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
356 set(output_name_tmp ${ARCHIVE_OUTPUT_DIRECTORY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
357 else(ARCHIVE_OUTPUT_DIRECTORY)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
358 set(output_name_tmp ${CMAKE_CURRENT_BINARY_DIR}/lib)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
359 endif(ARCHIVE_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
360 endif(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
361 set(output_name_tmp ${output_name_tmp}/${D_LIB_PREFIX}${name}${D_LIB_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
362 elseif("${TYPE_tmp}" STREQUAL "BINARY")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
363 set(build_binary_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
364 if(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
365 if(RUNTIME_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
366 set(output_name ${RUNTIME_OUTPUT_DIRECTORY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
367 else(RUNTIME_OUTPUT_DIRECTORY)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
368 set(output_name_tmp ${CMAKE_CURRENT_BINARY_DIR}/bin)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
369 endif(RUNTIME_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
370 endif(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
371 set(output_name_tmp ${output_name_tmp}/${name}${CMAKE_EXECUTABLE_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
372 elseif("${TYPE_tmp}" STREQUAL "SHARED")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
373 if(D_IS_MARS)
355
08c1ca7975ab obviated redundant virtual dispatch callbacks
Max Samukha <maxter@spambox.com>
parents: 281
diff changeset
374 message(FATAL_ERROR "DMD does not support building shared libraries")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
375 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
376 if(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
377 if(LIBRARY_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
378 set(output_name_tmp ${LIBRARY_OUTPUT_DIRECTORY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
379 else(LIBRARY_OUTPUT_DIRECTORY)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
380 set(output_name_tmp ${CMAKE_CURRENT_BINARY_DIR}/lib)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
381 endif(LIBRARY_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
382 endif(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
383 set(build_binary 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
384 set(output_name_tmp ${output_name_tmp}/${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
385 set(link_flags_tmp ${compile_flags_tmp} -L-shared)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
386 else("${TYPE_tmp}" STREQUAL "STATIC")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
387 message(FATAL_ERROR "D target ${TYPE_tmp} not supported")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
388 endif("${TYPE_tmp}" STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
389
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
390 ## Include paths.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
391 foreach(inc_tmp ${INCLUDES_tmp} ${D_INCLUDES})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
392 set(compile_flags_tmp ${compile_flags_tmp} -I${inc_tmp})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
393 endforeach(inc_tmp ${INCLUDES_tmp} ${D_INCLUDES})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
394
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
395 ## Libraries and paths of them.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
396 set(libs_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
397 if(build_binary_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
398 if(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
399 foreach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
400 make_native_path(lib_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
401 string(REPLACE "/" "\\" lib_path_tmp "${lib_path_tmp}//")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
402 set(lib_path_tmp \"${lib_path_tmp}\")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
403 set(link_flags_tmp ${link_flags_tmp} -L+${lib_path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
404 endforeach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
405 #set(additional_commands_tmp COMMAND set ARGS LIB=)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
406 #foreach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
407 #MAKE_NATIVE_PATH(lib_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
408 #set(additional_commands_tmp ${additional_commands_tmp}${lib_path_tmp};)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
409 #endforeach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
410 else(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
411 foreach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
412 set(link_flags_tmp ${link_flags_tmp} -L-L${lib_path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
413 endforeach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
414 endif(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
415 foreach(lib_tmp ${LIBS_tmp} ${D_LIBS})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
416 if(D_IS_MARS AND CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
417 set(link_flags_tmp ${link_flags_tmp} -L+${lib_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
418 else(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
419 set(link_flags_tmp ${link_flags_tmp} -L-l${lib_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
420 endif(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
421 endforeach(lib_tmp ${LIBS_tmp} ${D_LIBS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
422 endif(build_binary_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
423
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
424 set(not_obj_tmp ${ONE_BUILD_COMMAND})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
425 ## Ldc not support -lib flag.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
426 if(ONE_BUILD_COMMAND AND ${TYPE_tmp} STREQUAL "STATIC" AND D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
427 set(not_obj_tmp OFF)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
428 endif(ONE_BUILD_COMMAND AND ${TYPE_tmp} STREQUAL "STATIC" AND D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
429
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
430 if(build_binary_tmp AND NOT D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
431 set(compile_flags_tmp ${compile_flags_tmp} -od${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${name}.dir)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
432 endif(build_binary_tmp AND NOT D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
433
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
434 if(CMAKE_BUILD_TYPE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
435 string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
436 set(compile_flags_tmp ${compile_flags_tmp} ${D_${CMAKE_BUILD_TYPE_UPPER}_FLAGS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
437 endif(CMAKE_BUILD_TYPE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
438
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
439 if(detect_deps_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
440 message(STATUS "Getting dependencies for ${name}")
203
d3383b16f1d7 Add a 'NO_DEPS_SOURCES' option to the 'add_d_target' macro. And use it for resources and forms in QtD examples.
SokoL_SD
parents: 181
diff changeset
441 get_files_depends(tmp ${SOURCES_tmp})
d3383b16f1d7 Add a 'NO_DEPS_SOURCES' option to the 'add_d_target' macro. And use it for resources and forms in QtD examples.
SokoL_SD
parents: 181
diff changeset
442 set(SOURCES_tmp ${tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
443 endif(detect_deps_tmp)
212
bc1525b955d8 a small fix in cmake for the build_example macro.
SokoL_SD
parents: 203
diff changeset
444 set(SOURCES_tmp ${SOURCES_tmp} ${NO_DEPS_SOURCES_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
445
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
446 set(used_ar_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
447 get_filename_component(output_path_tmp ${output_name_tmp} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
448 if (NOT not_obj_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
449 compile_d_files(${name} objs_tmp ${SOURCES_tmp} FLAGS ${compile_flags_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
450 set(SOURCES_tmp ${objs_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
451 if(NOT D_IS_MARS AND ${TYPE_tmp} STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
452 set(parameters_tmp rcs ${output_name_tmp} ${SOURCES_tmp} ${OBJECTS_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
453 set(parameters_list_file_tmp ${tmp_dir_tmp}/parameters)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
454 if(CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
455 file(REMOVE ${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
456 foreach(arg_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
457 file(APPEND ${parameters_list_file_tmp} "${arg_tmp}\n")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
458 endforeach(arg_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
459 set(param_tmp @${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
460 elseif(CMAKE_HOST_UNIX)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
461 set(param_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
462 endif(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
463 add_custom_command(
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
464 OUTPUT "${output_name_tmp}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
465 COMMAND "${CMAKE_AR}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
466 ARGS ${param_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
467 DEPENDS ${SOURCES_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
468 COMMENT "Linking ${lib_name}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
469 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
470 set(used_ar_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
471 endif(NOT D_IS_MARS AND ${TYPE_tmp} STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
472 endif (NOT not_obj_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
473
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
474 if (NOT used_ar_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
475 set(output_name_native_tmp ${output_name_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
476 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
477 set(additional_commands_tmp ${additional_commands_tmp} COMMAND ${CMAKE_COMMAND} -E make_directory ${output_path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
478 make_native_path(output_name_native_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
479 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
480 set(parameters_tmp ${compile_flags_tmp} ${link_flags_tmp} ${SOURCES_tmp} ${OBJECTS_tmp} -of${output_name_native_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
481 set(parameters_list_file_tmp ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${name}.dir/parameters)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
482 if(CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
483 file(REMOVE ${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
484 foreach(arg_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
485 file(APPEND ${parameters_list_file_tmp} "${arg_tmp}\n")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
486 endforeach(arg_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
487 set(param_tmp @${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
488 elseif(CMAKE_HOST_UNIX)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
489 set(param_tmp ${parameters_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
490 endif(CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
491 #get_imported_files(depends_tmp ${SOURCES_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
492 add_custom_command(
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
493 OUTPUT ${output_name_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
494 ${additional_commands_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
495 COMMAND ${DC}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
496 ARGS ${param_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
497 DEPENDS ${SOURCES_tmp} ${depends_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
498 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
499 COMMENT "Linking ${name}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
500 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
501 endif(NOT used_ar_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
502 add_custom_target(${name} ALL DEPENDS ${DEPENDS_tmp} ${output_name_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
503 endmacro(add_d_target name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
504
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
505 ## Add static library target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
506 macro(add_d_static_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
507 add_d_target(${name} TYPE STATIC SOURCES ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
508 endmacro(add_d_static_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
509
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
510 ## Add binary target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
511 macro(add_d_program name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
512 add_d_target(${name} TYPE BINARY SOURCES ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
513 endmacro(add_d_program name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
514
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
515 ## Add shared library target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
516 macro(add_d_shared_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
517 add_d_target(${name} TYPE SHARED SOURCES ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
518 endmacro(add_d_shared_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
519
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
520 ## Add library target.
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
521 ## Library will shared if it supported.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
522 macro(add_d_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
523 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
524 add_d_target(${name} TYPE STATIC ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
525 else(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
526 add_d_target(${name} TYPE SHARED ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
527 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
528 endmacro(add_d_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
529
245
SokoL_SD
parents: 237
diff changeset
530 ##
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
531 macro(get_imported_files_old imported)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
532 execute_process(COMMAND ${DC} -c -o- -v ${compile_flags_tmp} ${ARGN}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
533 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
534 OUTPUT_VARIABLE dc_output_tmp
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
535
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
536 )
245
SokoL_SD
parents: 237
diff changeset
537 string(REGEX MATCHALL "import[^(]*([^)]*)" dc_output_tmp "${dc_output_tmp}")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
538
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
539 ## Initial filter.
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
540 regex_safe_string(tmp ${CMAKE_CURRENT_SOURCE_DIR})
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
541 regex_safe_string(tmp2 ${CMAKE_CURRENT_BINARY_DIR})
245
SokoL_SD
parents: 237
diff changeset
542 set(regex_includes_tmp "${tmp}|${tmp2}")
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
543
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
544 set(${imported})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
545 foreach(import_tmp ${dc_output_tmp})
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
546 ## Getting a next import.
245
SokoL_SD
parents: 237
diff changeset
547 string(REGEX REPLACE "import[^(]*\\(([^)]*)" "\\1" import_tmp ${import_tmp})
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
548 ## Filtering.
245
SokoL_SD
parents: 237
diff changeset
549 string(REPLACE "\\" "/" import_tmp ${import_tmp})
SokoL_SD
parents: 237
diff changeset
550 string(REGEX MATCH "(${regex_includes_tmp})" found "${import_tmp}")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
551 if(CMAKE_HOST_WIN32)
245
SokoL_SD
parents: 237
diff changeset
552 string(SUBSTRING "${import_tmp}" 1 2 first_sym_tmp)
SokoL_SD
parents: 237
diff changeset
553 set(full_path_tmp)
SokoL_SD
parents: 237
diff changeset
554 if(${first_sym_tmp} STREQUAL ":/")
SokoL_SD
parents: 237
diff changeset
555 set(full_path_tmp 1)
SokoL_SD
parents: 237
diff changeset
556 endif(${first_sym_tmp} STREQUAL ":/")
SokoL_SD
parents: 237
diff changeset
557 elseif(CMAKE_HOST_UNIX)
SokoL_SD
parents: 237
diff changeset
558 string(SUBSTRING "${import_tmp}" 0 1 first_sym_tmp)
SokoL_SD
parents: 237
diff changeset
559 set(full_path_tmp)
SokoL_SD
parents: 237
diff changeset
560 if(${first_sym_tmp} STREQUAL "/")
SokoL_SD
parents: 237
diff changeset
561 set(full_path_tmp 1)
SokoL_SD
parents: 237
diff changeset
562 endif(${first_sym_tmp} STREQUAL "/")
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
563 endif(CMAKE_HOST_WIN32)
245
SokoL_SD
parents: 237
diff changeset
564 if(found OR NOT full_path_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
565 set(${imported} ${${imported}} ${import_tmp})
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
566 endif(found OR NOT full_path_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
567 endforeach(import_tmp ${dc_output_tmp})
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
568 endmacro(get_imported_files_old imported)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
569
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
570 macro(filter_paths result)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
571 set(${result})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
572 set(read_now_tmp paths)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
573 set(include_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
574 set(paths_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
575 foreach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
576 set(founded_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
577 if(${arg_tmp} STREQUAL "INCLUDE_PATHS")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
578 set(read_now_tmp includes)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
579 set(founded_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
580 elseif(${arg_tmp} STREQUAL "INCLUDE_CURRENT_DIR")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
581 set(locale_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
582 set(read_now_tmp paths)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
583 set(founded_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
584 endif(${arg_tmp} STREQUAL "INCLUDE_PATHS")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
585 if(NOT founded_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
586 set(${read_now_tmp}_tmp ${${read_now_tmp}_tmp} ${arg_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
587 endif(NOT founded_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
588 endforeach(arg_tmp ${ARGN})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
589 regex_safe_string(include_tmp ${includes_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
590 set(regex_include_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
591 set(is_first_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
592 foreach(include_tmp ${includes_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
593 if(is_first_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
594 set(is_first_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
595 else(is_first_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
596 set(regex_includes_tmp ${regex_includes_tmp}|)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
597 endif(is_first_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
598 set(regex_includes_tmp ${regex_includes_tmp}${include_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
599 endforeach(include_tmp ${include_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
600 foreach(path_tmp ${paths_tmp})
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
601 file(TO_CMAKE_PATH path_tmp ${path_tmp})
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
602 string(REGEX MATCH "(${regex_includes_tmp})[^/]*" found "${path_tmp}")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
603 set(full_path_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
604 if(locale_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
605 string(SUBSTRING "${path_tmp}" 0 1 first_sym_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
606 set(full_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
607 if(${first_sym_tmp} STREQUAL "/")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
608 set(full_path_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
609 endif(${first_sym_tmp} STREQUAL "/")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
610 endif(locale_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
611 if(NOT found AND full_path_tmp)
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
612 else(NOT found AND full_path_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
613 set(${result} ${${result}} ${path_tmp})
366
da4235301224 Fixed VoidFunc. Updated to dmd.2.047.
Max Samukha <maxter@spambox.com>
parents: 355
diff changeset
614 endif(NOT found AND full_path_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
615 endforeach(path_tmp ${paths_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
616 endmacro(filter_paths )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
617
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
618 macro(get_files_depends out)
275
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
619 set(deps_file_tmp ${CMAKE_CURRENT_BINARY_DIR}/${ARGN}.deps)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
620 set(update_deps_tmp 0)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
621 foreach(arg_tmp ${ARGN})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
622 if(NOT IS_ABSOLUTE arg_tmp)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
623 set(arg_tmp ${CMAKE_CURRENT_SOURCE_DIR}/${arg_tmp})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
624 endif(NOT IS_ABSOLUTE arg_tmp)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
625 if(${arg_tmp} IS_NEWER_THAN ${deps_file_tmp})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
626 set(update_deps_tmp 1)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
627 break(arg_tmp ${ARGN})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
628 endif(${arg_tmp} IS_NEWER_THAN ${deps_file_tmp})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
629 endforeach(arg_tmp ${ARGN})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
630 if(update_deps_tmp)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
631 get_imported_files_old(${out} ${ARGN})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
632 #filter_paths(${out} ${${out}} INCLUDE_CURRENT_DIR INCLUDE_PATHS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
633 set(${out} ${ARGN} ${${out}})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
634 file(WRITE ${deps_file_tmp} "${${out}}")
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
635 else(update_deps_tmp)
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
636 file(STRINGS ${deps_file_tmp} ${out})
bb0f228c27cd Caching dependencies for d sources.
SokoL_SD
parents: 274
diff changeset
637 endif(update_deps_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
638 endmacro(get_files_depends out)