annotate CMakeLists.txt @ 4:0a29ce1ae854

CMake build script. Small fixes in examples.
author SokoL_SD
date Wed, 13 May 2009 19:01:55 +0000
parents e78566595089
children 834feae7809b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
1 cmake_minimum_required(VERSION 2.6)
1
e78566595089 initial import
mandel
parents:
diff changeset
2 PROJECT(qtd CXX C)
e78566595089 initial import
mandel
parents:
diff changeset
3 FIND_PACKAGE(Qt4 REQUIRED)
e78566595089 initial import
mandel
parents:
diff changeset
4
e78566595089 initial import
mandel
parents:
diff changeset
5 include_directories(${QT_INCLUDES} include)
e78566595089 initial import
mandel
parents:
diff changeset
6
4
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
7 option(BUILD_QT_OPENGL "Build QtOpenGL" "ON")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
8 option(BUILD_EXAMPLES "Build examples" "ON")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
9
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
10 set(PACKAGES Core Gui)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
11 if(BUILD_QT_OPENGL)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
12 set(PACKAGES ${PACKAGES} OpenGL)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
13 endif(BUILD_QT_OPENGL)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
14
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
15 set(packages_big ${PACKAGES})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
16 set(packages)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
17 foreach(package ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
18 string(TOLOWER ${package} package)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
19 set(packages ${packages} ${package})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
20 endforeach(package ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
21
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
22 #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY CMakeFiles)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
23
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
24 find_program(DC dmd ldc)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
25 ## Parsing D compiler version.
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
26 if (DC)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
27 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
28 string(REGEX MATCH "Digital Mars D Compiler v[0-9]\\.[0-9]+" dmd_version "${d_output}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
29 if (dmd_version)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
30 set(D_IS_MARS true)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
31 set(D_COMPILER_NAME "Digital Mars D Compiler")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
32 string(REGEX REPLACE "Digital Mars D Compiler v([0-9])\\.[0-9]+" "\\1" D_VERSION "${dmd_version}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
33 string(REGEX REPLACE "Digital Mars D Compiler v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${dmd_version}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
34 else (dmd_version)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
35 string(REGEX MATCH "LLVM-based D Compiler" is_ldc "${d_output}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
36 if (is_ldc)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
37 exec_program(${DC} ARGS "--version" OUTPUT_VARIABLE d_output)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
38 string(REGEX MATCH "based on DMD v[0-9]\\.[0-9]+ and llvm [0-9]\\.[0-9]+" ldc_version "${d_output}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
39 set(D_IS_LLVM true)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
40 if(ldc_version)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
41 set(D_IS_LLVM true)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
42 set(D_COMPILER_NAME "LLVM-based D Compiler")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
43 string(REGEX REPLACE "based on DMD v([0-9])\\.[0-9]+ and llvm [0-9]\\.[0-9]+" "\\1" D_VERSION "${ldc_version}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
44 string(REGEX REPLACE "based on DMD v[0-9]\\.([0-9]+) and llvm [0-9]\\.[0-9]+" "\\1" D_FRONTEND "${ldc_version}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
45 else(ldc_version)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
46 message(FATAL_ERROR "LDC compiler was found, but the version can not be processed")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
47 endif(ldc_version)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
48 else (is_ldc)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
49 message(FATAL_ERROR "D compliler not founded")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
50 endif(is_ldc)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
51 endif(dmd_version)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
52 message(STATUS "D compiler founded -- ${D_COMPILER_NAME} v${D_VERSION}.${D_FRONTEND}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
53 else (DC)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
54 message(FATAL_ERROR "D compliler not founded")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
55 endif (DC)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
56
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
57 # Check D compiler version
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
58 if(D_VERSION EQUAL "1")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
59 if (D_FRONTEND LESS "041")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
60 message(STATUS "Minimum required version of D compiler is 1.041 (or compiler based on this version)")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
61 endif(D_FRONTEND LESS "041")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
62 set(D_TARGET d1-tango)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
63 elseif(D_VERSION EQUAL "2")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
64 set(D_TARGET ) ## TODO: hm... I don`t known this parameter for D2 ^(
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
65 endif(D_VERSION EQUAL "1")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
66
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
67 if(D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
68 set(SEPARETLY_D_OBJECTS true)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
69 elseif(D_IS_LLVM)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
70 set(SEPARETLY_D_OBJECTS true)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
71 endif(D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
72
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
73 # Debug and release flags.
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
74 if (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
75 #set(CMAKE_BUILD_TYPE Debug)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
76 #set( SUFFIXLIB "${SUFFIXLIB}-debug" )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
77 #set( SUFFIXBIN "${SUFFIXBIN}-debug" )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
78 add_definitions(-DDEBUG)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
79 set(D_FLAGS -g -gc -debug)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
80 else (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
81 #set(CMAKE_BUILD_TYPE Release)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
82 add_definitions(-UNO_DEBUG)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
83 set(D_FLAGS -O -release -inline)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
84 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
85 set(D_FLAGS ${D_FLAGS} -L/subsystem:windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
86 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
87 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
88 set(D_FLAGS ${D_FLAGS} -I${CMAKE_BINARY_DIR} -I${CMAKE_SOURCE_DIR})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
89
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
90 MACRO(MAKE_WINDOWS_PATH pathname)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
91 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
92 # An extra \\ escape is necessary to get a \ through CMake's processing.
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
93 STRING(REPLACE "/" "\\" ${pathname} "${${pathname}}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
94 # Enclose with UNESCAPED quotes. This means we need to escape our
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
95 # quotes once here, i.e. with \"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
96 SET(${pathname} \"${${pathname}}\")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
97 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
98 ENDMACRO(MAKE_WINDOWS_PATH)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
99
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
100 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
101 set(implib implib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
102 find_program(IMPLIB ${implib})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
103 if (NOT IMPLIB)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
104 message(FATAL_ERROR "implib not found. You can donwload it from http://ftp.digitalmars.com/bup.zip")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
105 endif (NOT IMPLIB)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
106 set(D_OBJECT_SUFFIX .obj)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
107 if(D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
108 set(D_LIB_SUFFIX .lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
109 set(D_LIB_PREFIX )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
110 elseif(D_IS_LDC)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
111 set(D_LIB_SUFFIX .a)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
112 set(D_LIB_PREFIX lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
113 endif(D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
114 set(GEN_OPT ${GEN_OPT} --cpp_shared)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
115 add_definitions(-DCPP_SHARED)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
116 elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
117 set(D_LIB_SUFFIX .a)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
118 set(D_LIB_PREFIX lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
119 set(D_OBJECT_SUFFIX .o)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
120 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
121
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
122 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
123 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
124
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
125 add_subdirectory(generator)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
126
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
127 macro(OBJ_PATH path)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
128 unset(test)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
129 string(REGEX MATCH "${CMAKE_CURRENT_BINARY_DIR}/.*" test "${${path}}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
130 if(NOT ${test} EQUAL "")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
131 string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" first)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
132 string(LENGTH "${${path}}" last)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
133 math(EXPR first "${first} + 1")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
134 math(EXPR len "${last} - ${first}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
135 string(SUBSTRING "${${path}}" ${first} ${len} ${path})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
136 else(NOT ${test} EQUAL "")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
137 string(REGEX MATCH "${CMAKE_CURRENT_SOURCE_DIR}/.*" test "${${path}}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
138 if(NOT ${test} EQUAL "")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
139 string(LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" first)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
140 string(LENGTH "${${path}}" last)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
141 math(EXPR first "${first} + 1")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
142 math(EXPR len "${last} - ${first}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
143 string(SUBSTRING "${${path}}" ${first} ${len} ${path})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
144 endif(NOT ${test} EQUAL "")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
145 endif(NOT ${test} EQUAL "")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
146 endmacro(OBJ_PATH)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
147
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
148 macro(compile_d_files target objects_list)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
149 unset(${objects_list})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
150 set(tmp_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
151 file(MAKE_DIRECTORY ${tmp_dir})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
152 if(${SEPARETLY_D_OBJECTS})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
153 foreach (d_source ${ARGN})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
154 OBJ_PATH(d_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
155 set(d_obj ${tmp_dir}/${d_source}${D_OBJECT_SUFFIX})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
156 set(${objects_list} ${${objects_list} ${d_obj})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
157 get_filename_component(path ${d_obj} PATH)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
158 file(MAKE_DIRECTORY ${path})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
159 set(d_obj_out ${d_obj})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
160 OBJ_PATH(d_obj_out)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
161 add_custom_command(OUTPUT "${d_obj}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
162 COMMAND "${DC}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
163 ARGS ${D_FLAGS} -c ${d_source} -of${d_obj}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
164 COMMENT "Building ${d_obj_out}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
165 DEPENDS ${d_source}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
166 )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
167 endforeach(d_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
168 else(${SEPARETLY_D_OBJECTS})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
169 set(${objects_list} ${tmp_dir}/${target}${D_OBJECT_SUFFIX})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
170 set(d_obj_out ${${objects_list}})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
171 OBJ_PATH(d_obj_out)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
172 set(parameters_list_file ${tmp_dir}/parameters)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
173 SET (parameters ${D_FLAGS} -c ${ARGN} -of${${objects_list}})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
174 FILE (REMOVE ${parameters_list_file})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
175 FOREACH(arg ${parameters})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
176 FILE (APPEND ${parameters_list_file} "${arg}\n")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
177 ENDFOREACH(arg)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
178 add_custom_command(OUTPUT "${${objects_list}}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
179 COMMAND "${DC}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
180 ARGS @${parameters_list_file}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
181 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
182 DEPENDS ${ARGN}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
183 COMMENT ""
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
184 )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
185 endif(${SEPARETLY_D_OBJECTS})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
186 endmacro(compile_d_files objects_list)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
187
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
188 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
189 add_custom_target(allpackages ALL)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
190
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
191 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles)
1
e78566595089 initial import
mandel
parents:
diff changeset
192
4
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
193 foreach(package ${packages})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
194 unset(d_objs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
195 unset(cpp_objs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
196 unset(d_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
197 unset(cpp_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
198 unset(lib_name)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
199 unset(link_cpp)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
200 unset(link_d)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
201 unset(cpp_files)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
202 unset(d_files)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
203 unset(classes)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
204 unset(d_generated_files)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
205
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
206 include (${CMAKE_SOURCE_DIR}/build/${package}.txt)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
207
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
208 set(${package}_link_example "${link_example}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
209 set(${link_example} "")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
210
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
211 set(CUR_TMP_PATH CMakeFiles/${package}.dir)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
212
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
213 set(classes ArrayOps ${classes})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
214 foreach(class ${classes})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
215 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
216 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
217 endforeach(class)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
218 add_sources_for_generating(${cpp_sources})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
219
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
220 foreach(d_source ${d_files})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
221 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/${d_source}.d)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
222 endforeach(d_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
223 foreach(d_source ${d_generated_files})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
224 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
225 endforeach(d_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
226 foreach (cpp_source ${cpp_files})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
227 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
228 endforeach(cpp_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
229
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
230 compile_d_files(${package}_dobjs objects ${d_sources})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
231 set(d_objs ${d_objs} ${objects})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
232
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
233 set(lib_name ${D_LIB_PREFIX}qtd${package}${D_LIB_SUFFIX})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
234
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
235 add_library(cpp_${package} SHARED ${cpp_sources})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
236 add_dependencies(cpp_${package} dgen)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
237 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
238 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
239 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
240 ADD_CUSTOM_COMMAND(
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
241 TARGET cpp_${package}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
242 POST_BUILD
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
243 COMMAND ${CMAKE_COMMAND} -E remove
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
244 ${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_IMPORT_LIBRARY_PREFIX}cpp${package}${CMAKE_IMPORT_LIBRARY_SUFFIX}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
245 COMMAND ${CMAKE_COMMAND} -E copy
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
246 ${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_IMPORT_LIBRARY_PREFIX}cpp_${package}.dll${CMAKE_IMPORT_LIBRARY_SUFFIX}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
247 ${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_IMPORT_LIBRARY_PREFIX}cpp${package}${CMAKE_IMPORT_LIBRARY_SUFFIX}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
248 )
1
e78566595089 initial import
mandel
parents:
diff changeset
249
4
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
250 target_link_libraries(cpp_${package} ${link_cpp} )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
251 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
252 set(cpp_lib_native ${cpp_lib})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
253 MAKE_WINDOWS_PATH(cpp_lib_native)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
254 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
255 set(d_implib_native ${d_implib})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
256 MAKE_WINDOWS_PATH(d_implib_native)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
257 set(cpp_${package}_implib cpp${package})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
258 add_custom_command(
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
259 OUTPUT "${d_implib}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
260 COMMAND "${IMPLIB}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
261 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
262 DEPENDS "cpp_${package}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
263 COMMENT "Creating implib ${lib_name}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
264 )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
265 add_custom_command(
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
266 OUTPUT "${lib_name}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
267 COMMAND "${DC}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
268 ARGS -lib ${d_objs} ${d_implib} -oflib/${lib_name}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
269 DEPENDS ${d_objs} ${d_implib}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
270 COMMENT "Linking ${lib_name}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
271 )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
272 else(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
273 set_property(TARGET cpp_${package} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
274 foreach(cpp_source ${cpp_sources})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
275 set(cpp_source ${cpp_source})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
276 OBJ_PATH(cpp_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
277 set(cpp_objs ${cpp_objs} CMakeFiles/cpp_${package}.dir/${cpp_source}.o)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
278 endforeach(cpp_source)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
279
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
280 add_custom_command(
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
281 OUTPUT "${lib_name}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
282 COMMAND "${CMAKE_AR}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
283 ARGS rcs lib/${lib_name} ${d_objs} ${cpp_objs}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
284 DEPENDS ${d_objs} cpp_${package}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
285 COMMENT "Linking ${lib_name}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
286 )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
287 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
288 add_custom_target(${package} DEPENDS ${lib_name})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
289 foreach(depend ${depends})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
290 add_dependencies(cpp_${package} cpp_${depend})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
291 add_dependencies(${package} ${depend})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
292 endforeach(depend ${depends})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
293 add_dependencies(allpackages ${package})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
294 set(depends ${depends} ${package})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
295 endforeach(package)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
296
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
297 foreach(package_big ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
298 string(TOLOWER ${package_big} package)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
299 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
300 set(libs_path ${CMAKE_BINARY_DIR}/lib/qtd${package}.lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
301 MAKE_WINDOWS_PATH(libs_path)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
302 set(${package}_lib_param -L+${libs_path})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
303 foreach(link ${${package}_link_example})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
304 set(link ${CMAKE_SOURCE_DIR}/lib/${link}.lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
305 MAKE_WINDOWS_PATH(link)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
306 set(link -L+${link})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
307 set(${package}_lib_param ${${package}_lib_param} ${link})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
308 endforeach(link ${link_example})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
309 else (${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
310 set(${package}_lib_param -L-lqtd${package} -L-lQt${package_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
311 foreach(link ${link_example})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
312 set(${package}_lib_param ${${package}_lib_param} ${link})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
313 endforeach(link ${link_example})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
314 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
315 endforeach(package_big ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
316
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
317 macro(build_example name)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
318 unset(is_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
319 unset(is_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
320 set(qtd_libs ${core_lib_param} ${gui_lib_param})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
321 foreach(param ${ARGN})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
322 if(is_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
323 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" param_package "${param}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
324 if(${param_package} STREQUAL ${param})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
325 unset(is_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
326 set(is_sources 1)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
327 else(${param_package} STREQUAL ${param})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
328 unset(is_founded)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
329 foreach(package_big ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
330 string(TOLOWER ${package_big} package)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
331 if(${param_package} STREQUAL ${package_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
332 set(qtd_libs ${qtd_libs} ${${package}_lib_param})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
333 set(is_founded 1)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
334 break(package_big ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
335 endif(${param_package} STREQUAL ${package_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
336 endforeach(package_big ${packages_big})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
337 if(NOT is_founded)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
338 message(STATUS "Module ${param_package} not founded for example ${name}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
339 return(build_example name)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
340 endif(NOT is_founded)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
341 endif(${param_package} STREQUAL ${param})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
342 endif(is_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
343 if(NOT is_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
344 if(NOT is_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
345 if(${param} STREQUAL PACKAGES)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
346 set(is_libs 1)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
347 set(qtd_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
348 else(${param} STREQUAL PACKAGES)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
349 set(is_sources 1)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
350 endif(${param} STREQUAL PACKAGES)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
351 endif(NOT is_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
352 if(is_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
353 set(sources ${sources} ${param})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
354 endif(is_sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
355 endif(NOT is_libs)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
356 endforeach(param ${ARGN})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
357 if(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
358 set(libs_path )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
359 else(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
360 set(libs_path -L-L${CMAKE_BINARY_DIR}/lib)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
361 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
362 compile_d_files(${name}_dobjs objects ${sources} )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
363 set(output ${CMAKE_CURRENT_BINARY_DIR}/${name}${CMAKE_EXECUTABLE_SUFFIX})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
364 set(output_native ${output})
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
365 make_windows_path(output_native)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
366 add_custom_command(OUTPUT "${output}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
367 COMMAND "${DC}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
368 ARGS ${D_FLAGS} ${libs_path} ${qtd_libs} ${objects}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
369 -of${output_native}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
370 DEPENDS ${objects}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
371 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
372 COMMENT "Building example ${name}"
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
373 )
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
374 add_custom_target(example_${name} ALL DEPENDS "${output}")
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
375 add_dependencies(example_${name} allpackages)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
376 endmacro(build_example sources)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
377
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
378 if(BUILD_QT_OPENGL)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
379 add_subdirectory(demos)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
380 add_subdirectory(examples)
0a29ce1ae854 CMake build script.
SokoL_SD
parents: 1
diff changeset
381 endif(BUILD_QT_OPENGL)