comparison CMakeLists.txt @ 357:9784459f0750

An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables Q_CLASSINFO implementation Now Qtd can be built on Windows
author Max Samukha <maxter@spambox.com>
date Wed, 02 Jun 2010 19:38:05 +0300
parents 96a75b1e5b26
children 3b0545d4d479
comparison
equal deleted inserted replaced
356:12cec2d14e1c 357:9784459f0750
10 set(CMAKE_BUILD_TYPE Debug) 10 set(CMAKE_BUILD_TYPE Debug)
11 #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) 11 #set( SUFFIXLIB "${SUFFIXLIB}-debug" )
12 #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) 12 #set( SUFFIXBIN "${SUFFIXBIN}-debug" )
13 add_definitions(-DDEBUG) 13 add_definitions(-DDEBUG)
14 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) 14 elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
15 message(STATUS "Only debug and release configurations are supproted. The configuration is changed to 'Release'") 15 message(STATUS "Only debug and release configurations are supported. The configuration is changed to 'Release'")
16 set(CMAKE_BUILD_TYPE Release) 16 set(CMAKE_BUILD_TYPE Release)
17 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) 17 endif (${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG])
18 18
19 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) 19 if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS])
20 #add_definitions(-UNO_DEBUG) 20 #add_definitions(-UNO_DEBUG)
26 if (NOT SECOND_RUN) 26 if (NOT SECOND_RUN)
27 27
28 option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF") 28 option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF")
29 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) 29 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
30 message(FATAL_ERROR "In-source builds are not allowed. " 30 message(FATAL_ERROR "In-source builds are not allowed. "
31 "Please create a directory and run cmake from there, passing the path" 31 "Please create a directory and run cmake from there, passing the path "
32 "to this source directory as the last argument. " 32 "to this source directory as the last argument. "
33 "This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. Please delete them. " 33 "This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. Please delete them. "
34 "Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not recommended." 34 "Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not recommended."
35 ) 35 )
36 endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) 36 endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS)
178 if(CMAKE_HOST_WIN32) 178 if(CMAKE_HOST_WIN32)
179 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") 179 string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
180 endif(CMAKE_HOST_WIN32) 180 endif(CMAKE_HOST_WIN32)
181 181
182 if(CMAKE_HOST_WIN32 AND D_IS_MARS) 182 if(CMAKE_HOST_WIN32 AND D_IS_MARS)
183 set(D_FLAGS -version=cpp_shared)
184 add_definitions(-DCPP_SHARED)
183 set(CPP_SHARED 1 CACHE INTERNAL "") 185 set(CPP_SHARED 1 CACHE INTERNAL "")
184 endif(CMAKE_HOST_WIN32 AND D_IS_MARS) 186 endif(CMAKE_HOST_WIN32 AND D_IS_MARS)
185
186 if(D_IS_MARS)
187 set(D_FLAGS -version=cpp_shared)
188 add_definitions(-DCPP_SHARED)
189 endif(D_IS_MARS)
190 187
191 if(UNITTEST) 188 if(UNITTEST)
192 add_d_versions(QtdUnittest) 189 add_d_versions(QtdUnittest)
193 set(D_FLAGS ${D_FLAGS} -unittest) 190 set(D_FLAGS ${D_FLAGS} -unittest)
194 endif(UNITTEST) 191 endif(UNITTEST)
436 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") 433 string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}")
437 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) 434 install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di)
438 endforeach(d_source ${d_sources}) 435 endforeach(d_source ${d_sources})
439 endif(NOT GENERATE_DI_FILES) 436 endif(NOT GENERATE_DI_FILES)
440 437
441 ## Build the CPP part. 438 ### Build the CPP part.
442 if(CPP_SHARED) 439 if(CPP_SHARED)
443 set(cpp_method SHARED) 440 set(cpp_method SHARED)
444 else(CPP_SHARED) 441 else(CPP_SHARED)
445 set(cpp_method STATIC) 442 set(cpp_method STATIC)
446 endif(CPP_SHARED) 443 endif(CPP_SHARED)
447 add_library(cpp_${package} ${cpp_method} ${cpp_sources}) 444 add_library(cpp_${package} ${cpp_method} ${cpp_sources})
448 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib) 445 set_property(TARGET cpp_${package} PROPERTY RUNTIME_OUTPUT_DIRECTORY lib)
449 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles) 446 set_property(TARGET cpp_${package} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles)
447 set_property(TARGET cpp_${package} PROPERTY COMPILE_DEFINITIONS QTD_${package_upper})
448
450 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) 449 set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY})
451 if(CPP_SHARED) 450 if(CPP_SHARED)
452 else(CPP_SHARED) 451 else(CPP_SHARED)
453 ## Get an objects list. It will be used in building the D part. 452 ## Get an objects list. It will be used in building the D part.
454 foreach(cpp_source ${cpp_sources}) 453 foreach(cpp_source ${cpp_sources})
496 set(d_implib_native ${d_implib}) 495 set(d_implib_native ${d_implib})
497 make_native_path(d_implib_native) 496 make_native_path(d_implib_native)
498 add_custom_command( 497 add_custom_command(
499 OUTPUT "${d_implib}" 498 OUTPUT "${d_implib}"
500 COMMAND "${IMPLIB}" 499 COMMAND "${IMPLIB}"
501 ARGS /system /PAGESIZE:32 ${d_implib_native} ${cpp_lib_native} 500 ARGS /system /PAGESIZE:64 ${d_implib_native} ${cpp_lib_native}
502 DEPENDS "cpp_${package}" 501 DEPENDS "cpp_${package}"
503 COMMENT "Creating implib ${lib_name}" 502 COMMENT "Creating implib ${lib_name}"
504 ) 503 )
505 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) 504 install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib)
506 else(CPP_SHARED) 505 else(CPP_SHARED)
514 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) 513 set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example})
515 514
516 ## Generate dependences for make (or nmake). 515 ## Generate dependences for make (or nmake).
517 add_custom_target(${package}) 516 add_custom_target(${package})
518 add_dependencies(${package} ${lib_name}) 517 add_dependencies(${package} ${lib_name})
518
519 add_dependencies(${lib_name} cpp_${package}) 519 add_dependencies(${lib_name} cpp_${package})
520 foreach(depend ${required}) 520 foreach(depend ${required})
521 string(TOLOWER ${depend} depend) 521 string(TOLOWER ${depend} depend)
522 add_dependencies(cpp_${package} cpp_${depend}) 522 add_dependencies(cpp_${package} cpp_${depend})
523 add_dependencies(${package} ${depend}) 523 add_dependencies(${package} ${depend})