annotate CMakeLists.txt @ 241:e792a5287673

fixes
author SokoL_SD
date Mon, 20 Jul 2009 08:40:33 +0000
parents 8b1a982c9ac3
children f2f4c9cbadc2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
1 cmake_minimum_required(VERSION 2.6)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
2 PROJECT(qtd CXX C)
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
3
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
4 ##########################################################
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
5 ## Building generator && settings.
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
6 ##########################################################
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
7 if(NOT SECOND_RUN)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
8
239
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
9 option(FORCE_IN_SOURCE_BUILD "Force the in-source building" "OFF")
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
10 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT FORCE_IN_SOURCE_BUILD)
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
11 message(FATAL_ERROR "In-source builds are not allowed.
241
SokoL_SD
parents: 240
diff changeset
12 Please create a directory and run cmake from there, passing the path
239
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
13 to this source directory as the last argument.
241
SokoL_SD
parents: 240
diff changeset
14 This process created the file `CMakeCache.txt` and the directory `CMakeFiles'.
239
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
15 Please delete them.
241
SokoL_SD
parents: 240
diff changeset
16
SokoL_SD
parents: 240
diff changeset
17 Or you can restart cmake with `-DFORCE_IN_SOURCE_BUILD=1`, but it is not
239
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
18 recomended.
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
19 ")
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
20 endif()
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
21
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
22
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
23 FIND_PACKAGE(Qt4 REQUIRED)
227
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
24 set (QT_USE_QTMAIN false)
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
25 set (QT_USE_QTGUI false)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
26
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
27 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
28 ## Settings.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
29 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
30
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
31 ## Options.
136
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
32 option(BUILD_EXAMPLES "Build examples" "OFF")
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
33 option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
34 option(BUILD_TOOLS "Build tools" "ON")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
35 #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF")
136
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
36 set(GENERATE_DI_FILES OFF) ## Very experemental option. Temporary disabled.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
37
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
38 set(all_packages Core Gui OpenGL Xml Svg Network WebKit CACHE INTERNAL "")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
39
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
40 ## Init D toolkit.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
41 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
42 FIND_PACKAGE(D REQUIRED)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
43
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
44 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
45 set(CMAKE_INSTALL_PREFIX
241
SokoL_SD
parents: 240
diff changeset
46 ${DC_PATH} CACHE PATH "QtD install prefix"
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
47 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
48 endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
49
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
50 # Check D compiler version
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
51 if(D_VERSION EQUAL "1")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
52 if (D_FRONTEND LESS "041")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
53 message(STATUS "Minimum required version of D compiler is 1.041 (or compiler based on this version)")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
54 endif(D_FRONTEND LESS "041")
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
55 set(D_TARGET d1-tango CACHE INTERNAL "")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
56 elseif(D_VERSION EQUAL "2")
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
57 set(D_TARGET d2-phobos CACHE INTERNAL "")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
58 endif(D_VERSION EQUAL "1")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
59
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
60 # Debug and release flags.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
61 if (NOT CMAKE_BUILD_TYPE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
62 set(CMAKE_BUILD_TYPE Release)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
63 endif (NOT CMAKE_BUILD_TYPE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
64 if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
65 set(CMAKE_BUILD_TYPE Debug)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
66 #set( SUFFIXLIB "${SUFFIXLIB}-debug" )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
67 #set( SUFFIXBIN "${SUFFIXBIN}-debug" )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
68 add_definitions(-DDEBUG)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
69 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
70 message(STATUS "Only debug and release configurations are supproted now. Configuration will change to 'Release'")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
71 set(CMAKE_BUILD_TYPE Release)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
72 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
73 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
74 #add_definitions(-UNO_DEBUG)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
75 endif(${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS] )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
76
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
77 # System specific settings.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
78 if(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
79 set(implib implib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
80 find_program(IMPLIB ${implib})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
81 if (NOT IMPLIB)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
82 message(FATAL_ERROR "implib not found. You can donwload it from http://ftp.digitalmars.com/bup.zip")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
83 endif (NOT IMPLIB)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
84 if(D_IS_MARS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
85 set(GEN_OPT ${GEN_OPT} --cpp_shared)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
86 add_definitions(-DCPP_SHARED)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
87 endif(D_IS_MARS)
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
88 endif(CMAKE_HOST_WIN32)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
89
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
90 set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
91 set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
92
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
93 set(packages CACHE INTERNAL "")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
94 foreach(package_big ${all_packages})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
95 string(TOLOWER ${package_big} package)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
96 string(TOUPPER ${package_big} package_upper)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
97 option(BUILD_QT_${package_upper} "Build Qt${package_big}" "ON")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
98 set(packages ${packages} ${package})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
99 endforeach(package_big ${all_packages})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
100
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
101 add_subdirectory(generator)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
102
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
103 add_custom_target(main ALL)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
104 add_dependencies(main dgen)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
105
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
106 if(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
107 set(make_util nmake)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
108 elseif(${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles" OR
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
109 ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
110 set(make_util $(MAKE))
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
111 else(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
112 message(FATAL_ERROR "${CMAKE_GENERATOR} isn't supported")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
113 endif(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
114
239
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
115 if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
116 set(cd_path ${CMAKE_SOURCE_DIR})
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
117 else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
118 set(cd_path ${CMAKE_BINARY_DIR}/build)
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
119 endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
120
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
121 make_native_path(cd_path)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
122 add_custom_command(TARGET main POST_BUILD
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
123 COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
124 COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util}
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
125 COMMENT ""
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
126 )
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
127
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
128 ## Make commands.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
129 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
130 add_custom_target(install
240
8b1a982c9ac3 another fix for cmake
SokoL_SD
parents: 239
diff changeset
131 COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
132 COMMENT ""
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
133 )
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
134 add_dependencies(install preinstall)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
135
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
136 ##--------------------------------------------
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
137 ## CPack.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
138 ##--------------------------------------------
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
139 set(CPACK_PACKAGE_VERSION_PATCH 1)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
140 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
141 QtD is a D binding to the Qt application and UI framework.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
142 This package installs binding and static library for qt port on D programming language.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
143 ")
241
SokoL_SD
parents: 240
diff changeset
144 SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt")
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
145 SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
146 set(CPACK_PACKAGE_VENDOR "QtD team")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
147 set(CPACK_PACKAGE_CONTACT "e@mail.ru" )
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
148 SET(CPACK_PACKAGE_VERSION "0.1")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
149 set(CPACK_PACKAGE_INSTALL_DIRECTORY "qtd ${CPACK_PACKAGE_VERSION}")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
150 set(CPACK_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
151 set(CPACK_SOURCE_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
152 if(CMAKE_HOST_WIN32)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
153 set(CPACK_GENERATOR "ZIP")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
154 elseif(CMAKE_HOST_UNIX)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
155 set(CPACK_GENERATOR "TBZ2;DEB;RPM")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
156 endif(CMAKE_HOST_WIN32)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
157 include(CPack)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
158
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
159 ##########################################################
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
160 ## Building QtD.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
161 ##########################################################
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
162 else(NOT SECOND_RUN)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
163
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
164 PROJECT(qtd CXX C)
240
8b1a982c9ac3 another fix for cmake
SokoL_SD
parents: 239
diff changeset
165 if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
8b1a982c9ac3 another fix for cmake
SokoL_SD
parents: 239
diff changeset
166 load_cache(${CMAKE_BINARY_DIR}/.. INCLUDE_INTERNALS all_packages QTD_VERSION_STR QTD_VERSION)
241
SokoL_SD
parents: 240
diff changeset
167 endif(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
168 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
169 FIND_PACKAGE(D REQUIRED)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
170 FIND_PACKAGE(Qt4 REQUIRED)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
171
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
172 set(QTD_VERSION_STR ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
173 math(EXPR QTD_VERSION "(${QT_VERSION_MAJOR} << 16) + (${QT_VERSION_MINOR} << 8) + ${QT_VERSION_PATCH}")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
174
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
175 include_directories(${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
176
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
177 # System specifc settings.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
178 if(CMAKE_HOST_WIN32)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
179 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
180 endif(CMAKE_HOST_WIN32)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
181
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
182 if(CMAKE_HOST_WIN32 AND D_IS_MARS)
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
183 set(CPP_SHARED 1 CACHE INTERNAL "")
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
184 endif(CMAKE_HOST_WIN32 AND D_IS_MARS)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
185
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
186 if(D_IS_MARS)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
187 set(D_FLAGS -version=cpp_shared)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
188 add_definitions(-DCPP_SHARED)
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
189 endif(D_IS_MARS)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
190
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
191 ## Bootstrap settings for QtD.
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
192 set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc CACHE INTERNAL "")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
193 set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic CACHE INTERNAL "")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
194 set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION} CACHE INTERNAL "")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
195 set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "")
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
196
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
197 ##--------------------------------------------
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
198 ## Macros and functions.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
199 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
200
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
201 macro(load_generated_classes )
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
202 include(${CMAKE_BINARY_DIR}/cpp/qt_${package}/qt_${package}.txt)
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
203 endmacro(load_generated_classes )
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
204
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
205 macro(qtd_add_resource output)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
206 set (params NAME OPTIONS)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
207 qtd_parse_params (RESOURCES params ${ARGN})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
208 if(NAME_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
209 set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
210 endif(NAME_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
211 qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_"
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
212 "Generate" ${RESOURCES_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
213 endmacro(qtd_add_resource output)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
214
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
215 macro(qtd_wrap_ui output)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
216 set (params OPTIONS)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
217 qtd_parse_params (UI params ${ARGN})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
218 qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_"
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
219 "Generate" ${UI_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
220 endmacro(qtd_wrap_ui output)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
221
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
222 macro(qtd_command output command options prefix comment)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
223 foreach(file "${ARGN}")
241
SokoL_SD
parents: 240
diff changeset
224 ## Test an exist of the input file.
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
225 get_filename_component(file_path ${file} PATH)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
226 get_filename_component(file_name ${file} NAME_WE)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
227 get_filename_component(file_ext ${file} EXT)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
228
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
229 set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
230 add_custom_command(OUTPUT "${out}"
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
231 COMMAND "${command}"
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
232 ARGS ${options} ${file} -o ${out}
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
233 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
234 DEPENDS ${file}
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
235 COMMENT "${comment} ${file}"
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
236 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
237 set(${output} ${${output}} ${out})
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
238 endforeach(file "${ARGN}")
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
239 endmacro(qtd_command output command options files prefix comment)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
240
241
SokoL_SD
parents: 240
diff changeset
241 ## Parsing the parameters list.
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
242 macro(qtd_parse_params default params)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
243 set(type_tmp ${default})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
244 set(params_tmp ${default} ${${params}})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
245 foreach(param_tmp ${params_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
246 set(${param_tmp}_tmp )
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
247 endforeach(param_tmp ${params_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
248 foreach(arg_tmp ${ARGN})
241
SokoL_SD
parents: 240
diff changeset
249 set(found_type_tmp)
SokoL_SD
parents: 240
diff changeset
250 if(NOT found_type_tmp)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
251 foreach(param_tmp ${params_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
252 if(arg_tmp STREQUAL param_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
253 set(type_tmp ${param_tmp})
241
SokoL_SD
parents: 240
diff changeset
254 set(found_type_tmp 1)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
255 break(param_tmp ${params_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
256 endif(arg_tmp STREQUAL param_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
257 endforeach(param_tmp ${params_tmp})
241
SokoL_SD
parents: 240
diff changeset
258 endif(NOT found_type_tmp)
SokoL_SD
parents: 240
diff changeset
259 if(NOT found_type_tmp)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
260 set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp})
241
SokoL_SD
parents: 240
diff changeset
261 endif(NOT found_type_tmp)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
262 endforeach(arg_tmp ${ARGN})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
263 endmacro(qtd_parse_params default)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
264
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
265 ## Build example macro.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
266 ## name -- example name.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
267 ## Options:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
268 ## PACKAGES -- list of packages to link to exaple (for example, QtCore QtGui QtOpenGL).
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
269 ## Default value is "QtCore QtGui".
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
270 ## params -- sources d files.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
271 ## Usage:
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
272 ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
273 macro(build_example name)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
274 set (params UIC RESOURCES PACKAGES)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
275 qtd_parse_params (SOURCES params ${ARGN})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
276
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
277 if(NOT PACKAGES_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
278 set(PACKAGES_tmp QtCore QtGui)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
279 endif(NOT PACKAGES_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
280
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
281 if(RESOURCES_tmp)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
282 if(NOT BUILD_TOOLS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
283 message(STATUS "Example '${name}' required drcc. Example will not build")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
284 return(build_example name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
285 endif(NOT BUILD_TOOLS)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
286 qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} )
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
287 endif(RESOURCES_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
288
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
289 if(UIC_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
290 if(NOT BUILD_TOOLS)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
291 message(STATUS "Example '${name}' required drcc. Example will not build")
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
292 return(build_example name)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
293 endif(NOT BUILD_TOOLS)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
294 qtd_wrap_ui(uic_sources ${UIC_tmp})
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
295 endif(UIC_tmp)
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
296
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
297 foreach(package ${PACKAGES_tmp})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
298 string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
299 set(is_founded)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
300 foreach(package_big ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
301 string(TOLOWER ${package_big} package)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
302 if(${req} STREQUAL ${package_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
303 set(is_founded 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
304 break(package_big ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
305 endif(${req} STREQUAL ${package_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
306 endforeach(package_big ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
307 if(NOT is_founded)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
308 message(STATUS "Example '${name}' required package '${req}', but its not active. Example will not build")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
309 return(build_example name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
310 else(NOT is_founded)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
311 set(qtd_libs ${${package}_lib_param} ${qtd_libs})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
312 endif(NOT is_founded)
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
313 endforeach(package ${PACKAGES_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: 195
diff changeset
314 add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources}
182
973564c7e388 CMake: add an UIC option in the build_example macro.
SokoL_SD
parents: 177
diff changeset
315 DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR}
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
316 LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib LIBS ${qtd_libs})
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
317 ## TODO: Enable.
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
318 #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ##
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
319 # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}")
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
320 #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX)
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
321 add_dependencies(examples ${name})
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
322 add_dependencies(${name} allpackages tools)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
323 endmacro(build_example sources)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
324
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
325 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
326 ## Build and install library.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
327 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
328
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
329 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
330 add_custom_target(allpackages)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
331 link_directories(${CMAKE_BINARY_DIR}/CMakeFiles)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
332
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
333 foreach(package_big ${all_packages})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
334 string(TOLOWER ${package_big} package)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
335 ## Loading settings for package.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
336 set(required)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
337 set(d_objs)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
338 set(cpp_objs)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
339 set(d_sources)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
340 set(cpp_sources)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
341 set(lib_name)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
342 set(link_cpp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
343 set(link_d)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
344 set(cpp_files)
227
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
345 set(cpp_generated_files)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
346 set(d_files)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
347 set(classes)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
348 set(d_generated_files)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
349 set(d_version_files)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
350 set(link_example)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
351 include (${CMAKE_SOURCE_DIR}/build/${package}.txt)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
352
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
353 set(all_req_found 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
354 string(TOUPPER ${package} package_upper)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
355 if(BUILD_QT_${package_upper})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
356 foreach(req ${required})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
357 set(req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
358 foreach(pack ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
359 if(${pack} STREQUAL ${req})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
360 set(req_found 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
361 endif(${pack} STREQUAL ${req})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
362 endforeach(pack ${packages})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
363 if(NOT req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
364 set(req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
365 foreach(pack ${all_packages})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
366 if(${pack} STREQUAL ${req})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
367 set(req_found 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
368 endif(${pack} STREQUAL ${req})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
369 endforeach(pack ${all_packages})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
370 if(req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
371 message(STATUS "Package '${package_big}' required '${req}', but its not active")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
372 else(req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
373 message(STATUS "Package '${package_big}' required '${req}', but its not found")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
374 endif(req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
375 set(all_req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
376 endif(NOT req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
377 endforeach(req ${required})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
378 else(BUILD_QT_${package_upper})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
379 set(all_req_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
380 endif(BUILD_QT_${package_upper})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
381
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
382 ## TODO: cleanup.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
383 if("${all_req_found}" EQUAL 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
384 set(packages_big ${packages_big} ${package_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
385 set(packages ${packages} ${package})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
386 ## Loading package sources list.
177
69ee80d8bd10 CMake: correct ArrayOps2.d path.
SokoL_SD
parents: 175
diff changeset
387 foreach(d_source ${package}/ArrayOps2 ${d_generated_files})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
388 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
389 endforeach(d_source ${d_generated_files})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
390 set(classes ArrayOps ${classes})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
391 foreach(class ${classes})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
392 set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
393 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
394 endforeach(class ${classes})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
395 set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
396
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
397 foreach (cpp_source ${cpp_files})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
398 set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp)
227
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
399 endforeach(cpp_source ${cpp_files})
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
400 foreach (cpp_source ${cpp_generated_files})
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
401 set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp)
846b89285e2b Generate moc for UrlHandler_shell.cpp.
SokoL_SD
parents: 225
diff changeset
402 endforeach(cpp_source ${cpp_generated_files})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
403 foreach(d_source ${d_version_files})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
404 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}/qt/${d_source}.d)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
405 endforeach(d_source ${d_version_files})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
406 foreach(d_source ${d_files})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
407 set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/qt/${d_source}.d)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
408 endforeach(d_source ${d_files})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
409
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
410 if(NOT GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
411 foreach(d_source ${d_sources})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
412 get_filename_component(path ${d_source} PATH)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
413 get_filename_component(name ${d_source} NAME_WE)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
414 regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
415 regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
416 regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/qt/d${D_VERSION})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
417 set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
418 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
419 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
420 install(FILES ${path}/${name}_enum.d DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}_enum.di OPTIONAL)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
421 endforeach(d_source ${d_sources})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
422 endif(NOT GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
423
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
424 ## Link CPP library.
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
425 if(CPP_SHARED)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
426 set(cpp_method SHARED)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
427 else(CPP_SHARED)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
428 set(cpp_method STATIC)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
429 endif(CPP_SHARED)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
430 add_library(cpp_${package} ${cpp_method} ${cpp_sources})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
431 set_property(TARGET cpp_${package} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles)
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
432 if(CPP_SHARED)
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
433 else(CPP_SHARED)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
434 foreach(cpp_source ${cpp_sources})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
435 set(cpp_source ${cpp_source})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
436 obj_path(cpp_source)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
437 set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
438 endforeach(cpp_source ${cpp_sources})
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
439 endif(CPP_SHARED)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
440
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
441 ## Link D library.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
442 set(lib_name qtd${package})
136
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
443 if(BUILD_SHARED_LIBRARIES)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
444 set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
445 set(build_type SHARED)
136
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
446 else(BUILD_SHARED_LIBRARIES)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
447 set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
448 set(build_type STATIC)
136
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
449 endif(BUILD_SHARED_LIBRARIES)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
450
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
451 foreach(req ${required})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
452 set(is_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
453 foreach(pack ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
454 if("${pack}" STREQUAL "${req}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
455 set(is_found 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
456 break(pack ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
457 endif("${pack}" STREQUAL "${req}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
458 endforeach(pack ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
459 if(NOT is_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
460 message(FATAL_ERROR "Package ${package_big} required ${req}, but its not found")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
461 endif(NOT is_found)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
462 string(TOUPPER ${req} req_upper)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
463 string(TOLOWER ${req} req_lower)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
464 set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
465 endforeach(req ${require})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
466 set(d_objs ${d_objs} ${objects})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
467
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
468 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
469 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
470 string(TOUPPER ${package} package_upper)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
471 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
472 target_link_libraries(cpp_${package} ${link_cpp} )
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
473 if(CPP_SHARED)
136
798e54c1f66e CMake: disable building examples by default. You can use -DBUILD_EXAMPLES switch for enable that.
SokoL_SD
parents: 135
diff changeset
474 set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}.dll)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
475 set(cpp_lib_native ${cpp_lib})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
476 make_native_path(cpp_lib_native)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
477 set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
478 set(d_implib_native ${d_implib})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
479 make_native_path(d_implib_native)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
480 add_custom_command(
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
481 OUTPUT "${d_implib}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
482 COMMAND "${IMPLIB}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
483 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
484 DEPENDS "cpp_${package}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
485 COMMENT "Creating implib ${lib_name}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
486 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
487 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib)
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
488 else(CPP_SHARED)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
489 set(${package}_lib_param Qt${package_big}) ## Paths for QtD libs. Needed by examples.
229
aac81791596b Improve CMake script.
SokoL_SD
parents: 228
diff changeset
490 endif(CPP_SHARED)
215
8aaa84d48451 Improve examples.
SokoL_SD
parents: 203
diff changeset
491 add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib}
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
492 OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} )
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
493
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
494 install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
495 ## Paths for QtD libs. Needed by examples.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
496 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
497
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
498 ## Dependences.
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
499 add_custom_target(${package})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
500 add_dependencies(${package} ${lib_name})
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
501 add_dependencies(${lib_name} cpp_${package})
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
502 foreach(depend ${required})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
503 string(TOLOWER ${depend} depend)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
504 add_dependencies(cpp_${package} cpp_${depend})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
505 add_dependencies(${package} ${depend})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
506 endforeach(depend ${required})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
507 add_dependencies(allpackages ${package})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
508
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
509 if(GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
510 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
511 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
512 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
513 foreach(source ${d_sources})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
514 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
515 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
516 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
517 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
518 set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
519 set(interface_file "${interface_file_path}/${file_name}.di")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
520 if(NOT "${file_name}" STREQUAL "QGlobal")
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
521 add_custom_command(OUTPUT "${interface_file}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
522 COMMAND "${DC}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
523 ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
524 COMMENT "Generating header for ${source}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
525 DEPENDS ${source}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
526 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
527 )
241
SokoL_SD
parents: 240
diff changeset
528 else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file.
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
529 add_custom_command(OUTPUT "${interface_file}"
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
530 COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
531 COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
532 COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
533 COMMENT ""
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
534 DEPENDS ${source}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
535 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
536 )
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
537 endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
538 set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
539 install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
540 endforeach(source)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
541 endif(GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
542 endif("${all_req_found}" EQUAL 1)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
543 endforeach(package_big ${packages_big})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
544 if(GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
545 add_custom_target(generate_headers ALL DEPENDS ${interfaces_list})
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
546 endif(GENERATE_DI_FILES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
547
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
548 set(CPACK_COMPONENTS_ALL qtd qtd_tools)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
549
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
550 ##--------------------------------------------
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
551 ## Build other parts of the QtD.
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
552 ##--------------------------------------------
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
553
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
554 if(BUILD_TOOLS)
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
555 add_custom_target(tools ALL)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
556 add_subdirectory(tools)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
557 add_dependencies(tools drcc duic)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
558 endif(BUILD_TOOLS)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
559
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
560 if(BUILD_EXAMPLES)
237
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
561 add_custom_target(examples ALL)
62d0dce52dac CMake: improvements && fixes
SokoL_SD
parents: 235
diff changeset
562 add_dependencies(examples allpackages tools)
132
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
563 add_subdirectory(demos)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
564 add_subdirectory(examples)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
565 endif(BUILD_EXAMPLES)
a860544c5ee8 CMake: initial version of CMakeD script.
SokoL_SD
parents: 124
diff changeset
566
239
4716eaf4a67e Hack for building in a source directory
SokoL_SD
parents: 237
diff changeset
567 set(SECOND_RUN 0 CACHE INTERNAL "")
235
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
568
b796329e8c38 We need to start cmake twice. It is necessary for getting a class list from the generator and using this list for building other parts of QtD.
SokoL_SD
parents: 229
diff changeset
569 endif(NOT SECOND_RUN)