annotate cmake/FindD.cmake @ 215:8aaa84d48451

Improve examples.
author SokoL_SD
date Tue, 14 Jul 2009 15:25:45 +0000
parents bc1525b955d8
children 7f150ad4cb5f
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
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
5 ## Find D compiler and parsing its version.
166
52da31f967f0 CMake: minor fix
SokoL_SD
parents: 139
diff changeset
6 find_program(DC NAMES dmd ldc)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
7 if (DC)
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})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
12 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output)
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}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
19 string(REGEX REPLACE "Digital Mars D Compiler v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${dmd_version}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
20 else (dmd_version)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
21 string(REGEX MATCH "LLVM-based D Compiler" is_ldc "${d_output}")
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}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
31 string(REGEX REPLACE "based on DMD v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${ldc_version}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
32 else(ldc_version)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
33 message(FATAL_ERROR "LDC compiler was found, but the version can not be processed")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
34 endif(ldc_version)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
35 else (is_ldc)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
36 message(FATAL_ERROR "D compliler not found")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
37 endif(is_ldc)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
38 endif(dmd_version)
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)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
41 message(FATAL_ERROR "D compliler not found")
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)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
52 if("${dc_parent_dir}" STREQUAL "bin")
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 ## TODO: disable SINGLE_D_OBJECT option for ldc < rev. 1433.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
61 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
62 set(opt_tmp "ON")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
63 else(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
64 set(opt_tmp "OFF")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
65 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
66 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
67 if(D_IS_LLVM)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
68 set(D_FLAGS ${D_FLAGS} -singleobj)
181
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
69 endif(D_IS_LLVM)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
70 set(D_MODULES_PER_OBJECT 10000 CACHE STRING "Max number of modules per object file")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
71 endif(NOT ONE_BUILD_COMMAND)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
72
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
73 ## Specifics flags for build configurations.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
74 ## TODO: Add another targets.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
75 set(D_RELEASE_FLAGS -O -release)
139
825ac6364d2f CMake: fix debug flags for ldc
SokoL_SD
parents: 132
diff changeset
76 set(D_DEBUG_FLAGS -g )
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
77 if(D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
78 set(D_RELEASE_FLAGS ${D_RELEASE_FLAGS} -enable-inlining)
139
825ac6364d2f CMake: fix debug flags for ldc
SokoL_SD
parents: 132
diff changeset
79 set(D_DEBUG_FLAGS ${D_DEBUG_FLAGS} -d-debug)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
80 else(D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
81 set(D_RELEASE_FLAGS ${D_RELEASE_FLAGS} -inline)
139
825ac6364d2f CMake: fix debug flags for ldc
SokoL_SD
parents: 132
diff changeset
82 set(D_DEBUG_FLAGS ${D_DEBUG_FLAGS} -debug)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
83 endif(D_IS_LLVM)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
84 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
85 set(D_RELEASE_FLAGS ${D_RELEASE_FLAGS} -L/subsystem:windows)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
86 endif(CMAKE_HOST_WIN32)
139
825ac6364d2f CMake: fix debug flags for ldc
SokoL_SD
parents: 132
diff changeset
87
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
88
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
89 ## Settings.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
90 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
91 set(D_OBJECT_SUFFIX .obj)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
92 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
93 set(D_LIB_SUFFIX .lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
94 set(D_LIB_PREFIX )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
95 elseif(D_IS_LDC)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
96 set(D_LIB_SUFFIX .a)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
97 set(D_LIB_PREFIX lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
98 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
99 elseif(CMAKE_HOST_UNIX)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
100 set(D_LIB_SUFFIX .a)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
101 set(D_LIB_PREFIX lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
102 set(D_OBJECT_SUFFIX .o)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
103 endif(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
104
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
105 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
106 ## Macroses and functions.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
107 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
108
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
109 ## Make native path.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
110 ## Usage:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
111 ## set(path c:/file_path/file_name.cpp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
112 ## make_native_path(path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
113 ## message(STATUS ${path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
114 ## Output:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
115 ## -- "c:\file_path\file_name.cpp"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
116 ## Command "file(TO_NATIVE_PATH ...)" is wrong on Windows
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
117 macro(make_native_path pathname)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
118 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
119 # An extra \\ escape is necessary to get a \ through CMake's processing.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
120 string(REPLACE "/" "\\" ${pathname} "${${pathname}}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
121 # Enclose with UNESCAPED quotes. This means we need to escape our
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
122 # quotes once here, i.e. with \"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
123 set(${pathname} \"${${pathname}}\")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
124 endif(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
125 endmacro(make_native_path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
126
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
127 ##
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
128 ## Example:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
129 ## set(path 24.3+23.bin)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
130 ## obj_path(path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
131 ## message(STATUS ${path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
132 ## Example output:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
133 ## -- 24\.3\+23\.bin
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
134 macro(regex_safe_string outvariable)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
135 set(${outvariable} ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
136 set(__regex_chars__ ^ $ . ] [ - * + ? | \( \))
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
137 foreach(__regex_char__ ${__regex_chars__})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
138 string(REPLACE "${__regex_char__}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
139 "\\${__regex_char__}" ${outvariable} ${${outvariable}}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
140 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
141 endforeach(__regex_char__ ${__regex_chars__})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
142 endmacro(regex_safe_string outvariable)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
143
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
144 ## Remove unnecessary path to the object file.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
145 ## path -- path to object file.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
146 ## Example:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
147 ## set(path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/target.dir/main.d.obj)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
148 ## obj_path(path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
149 ## message(STATUS ${path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
150 ## Example output:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
151 ## -- CMakeFiles/target.dir/main.d.obj
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
152 macro(obj_path path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
153 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
154 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
155 set(regexp_str_tmp "(${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
156 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ${path} "${${path}}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
157 endmacro(obj_path path)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
158
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
159 ## Compile d files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
160 ## target -- name of a new target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
161 ## objects_list -- created object files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
162 ## params -- sources files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
163 macro(compile_d_files target objects_list)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
164 set(${objects_list})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
165 set(tmp_dir_tmp ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir)
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 set(type_tmp SOURCES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
168 set(SOURCES_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
169 set(FLAGS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
170
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
171 ## Parse parameters list.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
172 set(params_tmp SOURCES FLAGS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
173 foreach(arg_tmp ${ARGN})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
174 set(found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
175 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
176 foreach(param_tmp ${params_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
177 if(arg_tmp STREQUAL param_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
178 set(type_tmp ${param_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
179 set(found_type_tmp 1)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
180 break(param_tmp ${params_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
181 endif(arg_tmp STREQUAL param_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
182 endforeach(param_tmp ${params_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
183 endif(NOT found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
184 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
185 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
186 endif(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
187 endforeach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
188
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
189 if(NOT SINGLE_D_OBJECT)
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 foreach (d_source_p_tmp ${SOURCES_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
192 get_filename_component(ext_tmp ${d_source_p_tmp} EXT)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
193 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
194 ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
195 set (d_source_tmp ${d_source_p_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
196 obj_path(d_source_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
197 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
198 set(${objects_list} ${${objects_list}} ${d_obj_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
199 get_filename_component(path_tmp ${d_obj_tmp} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
200 file(MAKE_DIRECTORY ${path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
201 set(d_obj_out_tmp ${d_obj_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
202 obj_path(d_obj_out_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
203 #get_imported_files(depends_tmp ${d_source_p_tmp}) ## Too slow.....
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
204 add_custom_command(OUTPUT "${d_obj_tmp}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
205 COMMAND "${DC}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
206 ARGS ${FLAGS_tmp} ${d_source_p_tmp} -c -of${d_obj_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
207 COMMENT "Building ${d_obj_out_tmp}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
208 DEPENDS ${d_source_p} ${depends_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
209 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
210 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
211 endforeach (d_source_p_tmp ${SOURCES_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
212 else(NOT SINGLE_D_OBJECT)
181
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
213 set(count_objects_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
214 set(files${count_objects_tmp}_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
215 set(counter_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
216 set(files_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
217 set(objects_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
218 foreach (d_source_p_tmp ${SOURCES_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
219 math(EXPR counter_tmp "${counter_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
220 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
221 if(counter_tmp GREATER D_MODULES_PER_OBJECT)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
222 math(EXPR count_objects_tmp "${count_objects_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
223 set(files${count_objects_tmp}_tmp )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
224 set(counter_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
225 endif(counter_tmp GREATER D_MODULES_PER_OBJECT)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
226 endforeach (d_source_p_tmp ${SOURCES_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
227
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
228 if(files${count_objects_tmp}_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
229 math(EXPR count_objects_tmp "${count_objects_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
230 endif(files${count_objects_tmp}_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
231
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
232 set(id_tmp 0)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
233 while(id_tmp LESS ${count_objects_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
234 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
235 set(d_obj_out_tmp ${${object_tmp}})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
236 obj_path(d_obj_out_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
237 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
238 set(parameters_list_file_tmp ${tmp_dir_tmp}/parameters${id_tmp}_obj)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
239 if(CMAKE_HOST_WIN32)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
240 file(REMOVE ${parameters_list_file_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
241 foreach(arg_tmp ${parameters_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
242 file(APPEND ${parameters_list_file_tmp} "${arg_tmp}\n")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
243 endforeach(arg_tmp)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
244 set(param_tmp @${parameters_list_file_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
245 elseif(CMAKE_HOST_UNIX)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
246 set(param_tmp ${parameters_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
247 endif(CMAKE_HOST_WIN32)
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
248 #get_imported_files(depends_tmp ${ARGN})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
249 add_custom_command(OUTPUT "${object_tmp}"
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
250 COMMAND "${DC}"
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
251 ARGS ${param_tmp}
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
252 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
253 DEPENDS ${files${id_tmp}_tmp} ${depends_tmp}
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
254 COMMENT ""
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
255 )
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
256 set(objects_tmp ${objects_tmp} ${object_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
257 math(EXPR id_tmp "${id_tmp} + 1")
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
258 endwhile(id_tmp LESS ${count_objects_tmp})
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
259
b426da0c9720 CMake: New option D_MODULES_PER_OBJECT.
SokoL_SD
parents: 166
diff changeset
260 set(${objects_list} ${objects_tmp})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
261 endif(NOT SINGLE_D_OBJECT)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
262 #add_custom_target(${target} DEPENDS "${${objects_list}}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
263 endmacro(compile_d_files objects_list)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
264
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
265
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
266 ## Add D target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
267 ## name -- target name.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
268 ## Params:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
269 ## TYPE -- target type.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
270 ## STATIC -- static library.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
271 ## SHARED -- shared library.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
272 ## BINARY -- executable.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
273 ## SOURCES -- sources of the target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
274 ## INCLUDES -- include paths.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
275 ## FLAGS -- build flags.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
276 ## LIBS -- libraries for link.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
277 ## LIB_PATHS -- libraries paths.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
278 ## DEPENDS -- target depends.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
279 macro(add_d_target name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
280 set(type_tmp SOURCES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
281 set(TYPE_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
282 set(INCLUDES_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
283 set(FLAGS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
284 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
285 set(GEN_FILES_tmp )
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
286 set(OBJECTS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
287 set(LIBS_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
288 set(LIB_PATHS_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
289 set(DEPENDS_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
290 set(OUTPUT_PATH_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
291 set(compile_flags_tmp ${D_FLAGS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
292 set(additional_commands_tmp )
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
293 set(detect_deps_tmp 1)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
294 set(link_flags_tmp )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
295
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
296 ## 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
297 set(params_tmp TYPE INCLUDES FLAGS SOURCES NO_DEPS_SOURCES OBJECTS LIBS LIB_PATHS DEPENDS OUTPUT_PATH)
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
298
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
299 foreach(arg_tmp ${ARGN})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
300 set(found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
301 if(${arg_tmp} STREQUAL "NOT_DETECT_DEPENDS")
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
302 set(detect_deps_tmp 0)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
303 set(found_type_tmp 1)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
304 endif(${arg_tmp} STREQUAL "NOT_DETECT_DEPENDS")
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
305 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
306 foreach(param_tmp ${params_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
307 if(arg_tmp STREQUAL param_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
308 set(type_tmp ${param_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
309 set(found_type_tmp 1)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
310 break(param_tmp ${params_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
311 endif(arg_tmp STREQUAL param_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
312 endforeach(param_tmp ${params_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
313 endif(NOT found_type_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
314 if(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
315 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
316 endif(NOT found_type_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
317 endforeach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
318
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
319 ## Init target type.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
320 if (OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
321 set(output_name_tmp "${OUTPUT_PATH_tmp}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
322 endif (OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
323 if("${TYPE_tmp}" STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
324 set(link_flags_tmp ${link_flags_tmp} -lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
325 if(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
326 if(ARCHIVE_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
327 set(output_name_tmp ${ARCHIVE_OUTPUT_DIRECTORY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
328 else(ARCHIVE_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
329 set(output_name_tmp ${CMAKE_CURRENT_BINARY_DIR}/lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
330 endif(ARCHIVE_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
331 endif(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
332 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
333 elseif("${TYPE_tmp}" STREQUAL "BINARY")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
334 set(build_binary_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
335 if(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
336 if(RUNTIME_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
337 set(output_name ${RUNTIME_OUTPUT_DIRECTORY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
338 else(RUNTIME_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
339 set(output_name_tmp ${CMAKE_CURRENT_BINARY_DIR}/bin)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
340 endif(RUNTIME_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
341 endif(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
342 set(output_name_tmp ${output_name_tmp}/${name}${CMAKE_EXECUTABLE_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
343 elseif("${TYPE_tmp}" STREQUAL "SHARED")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
344 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
345 message(FATAL_ERROR "DMD not support building shared library")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
346 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
347 if(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
348 if(LIBRARY_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
349 set(output_name_tmp ${LIBRARY_OUTPUT_DIRECTORY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
350 else(LIBRARY_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
351 set(output_name_tmp ${CMAKE_CURRENT_BINARY_DIR}/lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
352 endif(LIBRARY_OUTPUT_DIRECTORY)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
353 endif(NOT OUTPUT_PATH_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
354 set(build_binary 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
355 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
356 set(link_flags_tmp ${compile_flags_tmp} -L-shared)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
357 else("${TYPE_tmp}" STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
358 message(FATAL_ERROR "D target ${TYPE_tmp} not supported")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
359 endif("${TYPE_tmp}" STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
360
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
361 ## Include paths.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
362 foreach(inc_tmp ${INCLUDES_tmp} ${D_INCLUDES})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
363 set(compile_flags_tmp ${compile_flags_tmp} -I${inc_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
364 endforeach(inc_tmp ${INCLUDES_tmp} ${D_INCLUDES})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
365
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
366 ## Libraries and paths of them.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
367 set(libs_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
368 if(build_binary_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
369 if(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
370 foreach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
371 make_native_path(lib_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
372 string(REPLACE "/" "\\" lib_path_tmp "${lib_path_tmp}//")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
373 set(lib_path_tmp \"${lib_path_tmp}\")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
374 set(link_flags_tmp ${link_flags_tmp} -L+${lib_path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
375 endforeach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
376 #set(additional_commands_tmp COMMAND set ARGS LIB=)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
377 #foreach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
378 #MAKE_NATIVE_PATH(lib_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
379 #set(additional_commands_tmp ${additional_commands_tmp}${lib_path_tmp};)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
380 #endforeach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
381 else(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
382 foreach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
383 set(link_flags_tmp ${link_flags_tmp} -L-L${lib_path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
384 endforeach(lib_path_tmp ${LIB_PATHS_tmp} ${D_LIB_PATHS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
385 endif(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
386 foreach(lib_tmp ${LIBS_tmp} ${D_LIBS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
387 if(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
388 set(link_flags_tmp ${link_flags_tmp} -L+${lib_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
389 else(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
390 set(link_flags_tmp ${link_flags_tmp} -L-l${lib_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
391 endif(D_IS_MARS AND CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
392 endforeach(lib_tmp ${LIBS_tmp} ${D_LIBS})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
393 endif(build_binary_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
394
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
395 set(not_obj_tmp ${ONE_BUILD_COMMAND})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
396 ## Ldc not support -lib flag.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
397 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
398 set(not_obj_tmp OFF)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
399 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
400
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
401 if(build_binary_tmp AND NOT D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
402 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
403 endif(build_binary_tmp AND NOT D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
404
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
405 if(CMAKE_BUILD_TYPE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
406 string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
407 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
408 endif(CMAKE_BUILD_TYPE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
409
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
410 if(detect_deps_tmp)
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
411 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
412 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
413 set(SOURCES_tmp ${tmp})
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
414 endif(detect_deps_tmp)
212
bc1525b955d8 a small fix in cmake for the build_example macro.
SokoL_SD
parents: 203
diff changeset
415 set(SOURCES_tmp ${SOURCES_tmp} ${NO_DEPS_SOURCES_tmp})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
416
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
417 set(used_ar_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
418 get_filename_component(output_path_tmp ${output_name_tmp} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
419 if (NOT not_obj_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
420 compile_d_files(${name} objs_tmp ${SOURCES_tmp} FLAGS ${compile_flags_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
421 set(SOURCES_tmp ${objs_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
422 if(NOT D_IS_MARS AND ${TYPE_tmp} STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
423 set(parameters_tmp rcs ${output_name_tmp} ${SOURCES_tmp} ${OBJECTS_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
424 set(parameters_list_file_tmp ${tmp_dir_tmp}/parameters)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
425 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
426 file(REMOVE ${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
427 foreach(arg_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
428 file(APPEND ${parameters_list_file_tmp} "${arg_tmp}\n")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
429 endforeach(arg_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
430 set(param_tmp @${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
431 elseif(CMAKE_HOST_UNIX)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
432 set(param_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
433 endif(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
434 add_custom_command(
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
435 OUTPUT "${output_name_tmp}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
436 COMMAND "${CMAKE_AR}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
437 ARGS ${param_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
438 DEPENDS ${SOURCES_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
439 COMMENT "Linking ${lib_name}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
440 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
441 set(used_ar_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
442 endif(NOT D_IS_MARS AND ${TYPE_tmp} STREQUAL "STATIC")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
443 endif (NOT not_obj_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
444
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
445 if (NOT used_ar_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
446 set(output_name_native_tmp ${output_name_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
447 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
448 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
449 make_native_path(output_name_native_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
450 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
451 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
452 set(parameters_list_file_tmp ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${name}.dir/parameters)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
453 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
454 file(REMOVE ${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
455 foreach(arg_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
456 file(APPEND ${parameters_list_file_tmp} "${arg_tmp}\n")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
457 endforeach(arg_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
458 set(param_tmp @${parameters_list_file_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
459 elseif(CMAKE_HOST_UNIX)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
460 set(param_tmp ${parameters_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
461 endif(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
462 #get_imported_files(depends_tmp ${SOURCES_tmp})
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 ${additional_commands_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
466 COMMAND ${DC}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
467 ARGS ${param_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
468 DEPENDS ${SOURCES_tmp} ${depends_tmp}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
469 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
470 COMMENT "Linking ${name}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
471 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
472 endif(NOT used_ar_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
473 add_custom_target(${name} ALL DEPENDS ${DEPENDS_tmp} ${output_name_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
474 endmacro(add_d_target name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
475
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
476 ## Add static library target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
477 macro(add_d_static_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
478 add_d_target(${name} TYPE STATIC SOURCES ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
479 endmacro(add_d_static_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
480
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
481 ## Add binary target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
482 macro(add_d_program name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
483 add_d_target(${name} TYPE BINARY SOURCES ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
484 endmacro(add_d_program name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
485
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
486 ## Add shared library target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
487 macro(add_d_shared_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
488 add_d_target(${name} TYPE SHARED SOURCES ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
489 endmacro(add_d_shared_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
490
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
491 ## Add library target.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
492 ## If it support library would shared.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
493 macro(add_d_lib name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
494 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
495 add_d_target(${name} TYPE STATIC ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
496 else(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
497 add_d_target(${name} TYPE SHARED ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
498 endif(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
499 endmacro(add_d_lib 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 ##
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
502 macro(get_imported_files imported)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
503 execute_process(COMMAND ${DC} -c -o- -v ${compile_flags_tmp} ${ARGN}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
504 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
505 OUTPUT_VARIABLE dc_output_tmp
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 212
diff changeset
506
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
507 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
508 string(REGEX MATCHALL "import[^\\(]*([^\\)]*)" dc_output_tmp "${dc_output_tmp}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
509 set(${imported})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
510 foreach(import_tmp ${dc_output_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
511 string(REGEX REPLACE "import[^\\(]*\\(([^\\)]*)" "\\1" import_tmp ${import_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
512 set(${imported} ${${imported}} ${import_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
513 endforeach(import_tmp ${dc_output_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
514 endmacro(get_imported_files imported)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
515
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
516 macro(filter_paths result)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
517 set(${result})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
518 set(read_now_tmp paths)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
519 set(include_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
520 set(paths_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
521 foreach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
522 set(founded_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
523 if(${arg_tmp} STREQUAL "INCLUDE_PATHS")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
524 set(read_now_tmp includes)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
525 set(founded_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
526 elseif(${arg_tmp} STREQUAL "INCLUDE_CURRENT_DIR")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
527 set(locale_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
528 set(read_now_tmp paths)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
529 set(founded_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
530 endif(${arg_tmp} STREQUAL "INCLUDE_PATHS")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
531 if(NOT founded_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
532 set(${read_now_tmp}_tmp ${${read_now_tmp}_tmp} ${arg_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
533 endif(NOT founded_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
534 endforeach(arg_tmp ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
535 regex_safe_string(include_tmp ${includes_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
536 set(regex_include_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
537 set(is_first_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
538 foreach(include_tmp ${includes_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
539 if(is_first_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
540 set(is_first_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
541 else(is_first_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
542 set(regex_includes_tmp ${regex_includes_tmp}|)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
543 endif(is_first_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
544 set(regex_includes_tmp ${regex_includes_tmp}${include_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
545 endforeach(include_tmp ${include_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
546 foreach(path_tmp ${paths_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
547 file(TO_CMAKE_PATH path_tmp ${path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
548 string(REGEX MATCH "(${regex_includes_tmp})[^/]*" found "${path_tmp}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
549 set(full_path_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
550 if(locale_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
551 string(SUBSTRING "${path_tmp}" 0 1 first_sym_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
552 set(full_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
553 if(${first_sym_tmp} STREQUAL "/")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
554 set(full_path_tmp 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
555 endif(${first_sym_tmp} STREQUAL "/")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
556 endif(locale_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
557 if(NOT found AND full_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
558 else(NOT found AND full_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
559 set(${result} ${${result}} ${path_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
560 endif(NOT found AND full_path_tmp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
561 endforeach(path_tmp ${paths_tmp})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
562 endmacro(filter_paths )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
563
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
564 macro(get_files_depends out)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
565 get_imported_files(${out} ${ARGN})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
566 filter_paths(${out} ${${out}} INCLUDE_CURRENT_DIR INCLUDE_PATHS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
567 set(${out} ${ARGN} ${${out}})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents:
diff changeset
568 endmacro(get_files_depends out)