e@376: cmake_minimum_required(VERSION 2.6) SokoL_SD@132: PROJECT(qtd CXX C) SokoL_SD@235: maxter@344: # Debug and release flags. maxter@344: if (NOT CMAKE_BUILD_TYPE) maxter@344: set(CMAKE_BUILD_TYPE Release) Eldar@375: endif () maxter@344: maxter@344: if(${CMAKE_BUILD_TYPE} MATCHES [dD][eE][bB][uU][gG]) maxter@344: set(CMAKE_BUILD_TYPE Debug) maxter@344: #set( SUFFIXLIB "${SUFFIXLIB}-debug" ) maxter@344: #set( SUFFIXBIN "${SUFFIXBIN}-debug" ) maxter@344: add_definitions(-DDEBUG) maxter@344: elseif (NOT ${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) maxter@357: message(STATUS "Only debug and release configurations are supported. The configuration is changed to 'Release'") maxter@344: set(CMAKE_BUILD_TYPE Release) Eldar@375: endif () maxter@344: maxter@344: if (${CMAKE_BUILD_TYPE} MATCHES [rR][eE][lL][eE][aA][sS]) maxter@344: #add_definitions(-UNO_DEBUG) Eldar@375: endif() maxter@344: SokoL_SD@235: ########################################################## SokoL_SD@264: ## Build generator. SokoL_SD@235: ########################################################## maxter@344: if (NOT SECOND_RUN) SokoL_SD@235: SokoL_SD@242: option(ALLOW_IN_SOURCE_BUILDS "Allow in-source builds" "OFF") maxter@344: if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT ALLOW_IN_SOURCE_BUILDS) maxter@344: message(FATAL_ERROR "In-source builds are not allowed. " maxter@357: "Please create a directory and run cmake from there, passing the path " maxter@344: "to this source directory as the last argument. " maxter@344: "This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. Please delete them. " maxter@344: "Or you can restart cmake with `-DALLOW_IN_SOURCE_BUILDS=1`, but it is not recommended." maxter@344: ) Eldar@375: endif () SokoL_SD@239: SokoL_SD@132: FIND_PACKAGE(Qt4 REQUIRED) maxter@344: set(QT_USE_QTMAIN false) maxter@344: set(QT_USE_QTGUI false) SokoL_SD@132: SokoL_SD@132: ##-------------------------------------------- SokoL_SD@132: ## Settings. SokoL_SD@132: ##-------------------------------------------- SokoL_SD@132: SokoL_SD@132: ## Options. SokoL_SD@136: option(BUILD_EXAMPLES "Build examples" "OFF") SokoL_SD@136: option(BUILD_SHARED_LIBRARIES "Build shared library (very experemental and only for ldc)" "OFF") SokoL_SD@132: option(BUILD_TOOLS "Build tools" "ON") SokoL_SD@132: #option(GENERATE_DI_FILES "Generate *.di files with DC -H command" "OFF") maxter@344: set(GENERATE_DI_FILES OFF) ## Very experimental option. Temporarily disabled. SokoL_SD@274: option(VERBOSE_DEBUG "Verbose debug" "OFF") SokoL_SD@273: Eldar@378: set(all_packages Core Gui OpenGL Xml Svg Network WebKit Qwt CACHE INTERNAL "") SokoL_SD@132: SokoL_SD@132: ## Init D toolkit. SokoL_SD@132: set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) SokoL_SD@132: FIND_PACKAGE(D REQUIRED) SokoL_SD@132: SokoL_SD@132: if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") SokoL_SD@132: set(CMAKE_INSTALL_PREFIX maxter@344: ${DC_PATH} CACHE PATH "QtD install prefix" SokoL_SD@132: ) Eldar@375: endif() SokoL_SD@132: SokoL_SD@132: # Check D compiler version SokoL_SD@132: if(D_VERSION EQUAL "1") eldar@282: if (D_FRONTEND LESS "050") maxter@344: message(STATUS "Minimum required version of D compiler is 1.050 (or compiler based on this version)") eldar@282: endif(D_FRONTEND LESS "050") maxter@344: set(D_TARGET d1-tango CACHE INTERNAL "") SokoL_SD@132: elseif(D_VERSION EQUAL "2") SokoL_SD@235: set(D_TARGET d2-phobos CACHE INTERNAL "") Eldar@375: endif() SokoL_SD@132: SokoL_SD@237: # System specific settings. SokoL_SD@132: if(CMAKE_HOST_WIN32) SokoL_SD@132: set(implib implib) SokoL_SD@132: find_program(IMPLIB ${implib}) SokoL_SD@132: if (NOT IMPLIB) maxter@344: message(FATAL_ERROR "implib is not found. You can donwload it from http://ftp.digitalmars.com/bup.zip") Eldar@375: endif () SokoL_SD@132: if(D_IS_MARS) SokoL_SD@132: set(GEN_OPT ${GEN_OPT} --cpp_shared) Eldar@375: endif() Eldar@375: endif() Eldar@375: add_definitions(-DCPP_SHARED) SokoL_SD@235: SokoL_SD@235: set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ./) SokoL_SD@235: set(GEN_OPT ${GEN_OPT} --d-target=${D_TARGET}) SokoL_SD@235: SokoL_SD@235: set(packages CACHE INTERNAL "") SokoL_SD@235: foreach(package_big ${all_packages}) maxter@344: string(TOLOWER ${package_big} package) maxter@344: string(TOUPPER ${package_big} package_upper) Eldar@378: set(package_default_option "ON") Eldar@378: if(${package_big} STREQUAL "Qwt") Eldar@378: set(package_default_option "OFF") Eldar@378: endif() Eldar@378: option(BUILD_QT_${package_upper} "Build Qt${package_big}" ${package_default_option}) SokoL_SD@243: if(BUILD_QT_${package_upper}) Eldar@375: set(packages ${packages} ${package_big}) Eldar@375: endif() Eldar@375: endforeach() SokoL_SD@235: Eldar@378: set(QWT_INCLUDE_PATH "/usr/include/qwt-qt4" CACHE STRING "Qwt include path") Eldar@378: Eldar@378: set(inc_paths "") Eldar@378: Eldar@378: if(CMAKE_HOST_WIN32) Eldar@378: set(sep ";") Eldar@378: else() Eldar@378: set(sep ":") Eldar@378: endif() Eldar@378: Eldar@378: if(BUILD_QT_QWT) Eldar@378: set(inc_paths ${inc_paths}${sep}${QWT_INCLUDE_PATH}) Eldar@378: endif() Eldar@378: SokoL_SD@235: add_subdirectory(generator) SokoL_SD@235: SokoL_SD@235: add_custom_target(main ALL) SokoL_SD@235: add_dependencies(main dgen) SokoL_SD@235: SokoL_SD@235: if(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles") SokoL_SD@235: set(make_util nmake) SokoL_SD@235: elseif(${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles" OR SokoL_SD@235: ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") SokoL_SD@235: set(make_util $(MAKE)) Eldar@375: else() SokoL_SD@264: message(FATAL_ERROR "${CMAKE_GENERATOR} is not supported") Eldar@375: endif() SokoL_SD@235: SokoL_SD@239: if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) SokoL_SD@239: set(cd_path ${CMAKE_SOURCE_DIR}) Eldar@375: else() SokoL_SD@239: set(cd_path ${CMAKE_BINARY_DIR}/build) Eldar@375: endif() SokoL_SD@239: SokoL_SD@235: make_native_path(cd_path) maxter@344: add_custom_command(TARGET main POST_BUILD maxter@344: COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build maxter@344: COMMAND cd ARGS ${cd_path} && ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DSECOND_RUN=1 ${CMAKE_SOURCE_DIR} && ${make_util} maxter@344: COMMENT "" maxter@344: ) SokoL_SD@235: SokoL_SD@264: ## "Make install" command. SokoL_SD@235: set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) SokoL_SD@235: add_custom_target(install maxter@344: COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install maxter@344: COMMENT "" maxter@344: ) SokoL_SD@235: add_dependencies(install preinstall) SokoL_SD@235: SokoL_SD@235: ########################################################## SokoL_SD@264: ## Build QtD. SokoL_SD@235: ########################################################## SokoL_SD@235: else(NOT SECOND_RUN) SokoL_SD@235: SokoL_SD@235: PROJECT(qtd CXX C) SokoL_SD@240: if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) SokoL_SD@240: load_cache(${CMAKE_BINARY_DIR}/.. INCLUDE_INTERNALS all_packages QTD_VERSION_STR QTD_VERSION) Eldar@375: endif() SokoL_SD@235: set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) SokoL_SD@235: FIND_PACKAGE(D REQUIRED) SokoL_SD@235: FIND_PACKAGE(Qt4 REQUIRED) SokoL_SD@235: SokoL_SD@235: set(QTD_VERSION_STR ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}) SokoL_SD@235: math(EXPR QTD_VERSION "(${QT_VERSION_MAJOR} << 16) + (${QT_VERSION_MINOR} << 8) + ${QT_VERSION_PATCH}") SokoL_SD@235: SokoL_SD@235: include_directories(${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) Eldar@378: if(${BUILD_QT_QWT}) Eldar@378: include_directories(${QWT_INCLUDE_PATH}) Eldar@378: endif() SokoL_SD@235: SokoL_SD@235: # System specifc settings. SokoL_SD@235: if(CMAKE_HOST_WIN32) SokoL_SD@132: string(REGEX REPLACE ".dll([A-Za-z\\.0-9]+)" "\\1" CMAKE_IMPORT_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") Eldar@375: endif() SokoL_SD@132: SokoL_SD@229: if(CMAKE_HOST_WIN32 AND D_IS_MARS) maxter@357: set(D_FLAGS -version=cpp_shared) Eldar@375: endif() Eldar@375: add_definitions(-DCPP_SHARED) Eldar@375: set(CPP_SHARED 1 CACHE INTERNAL "") Eldar@370: SokoL_SD@229: SokoL_SD@273: if(UNITTEST) SokoL_SD@273: add_d_versions(QtdUnittest) maxter@344: set(D_FLAGS ${D_FLAGS} -unittest) Eldar@375: endif() SokoL_SD@273: SokoL_SD@274: if(VERBOSE_DEBUG) SokoL_SD@274: add_d_debugs(QtdVerbose) Eldar@375: endif() SokoL_SD@274: maxter@344: if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") maxter@344: add_d_debugs(QtdDebug) Eldar@375: endif() maxter@344: SokoL_SD@132: ## Bootstrap settings for QtD. SokoL_SD@235: set(DRCC ${CMAKE_BINARY_DIR}/tools/drcc/drcc CACHE INTERNAL "") SokoL_SD@235: set(DUIC ${CMAKE_BINARY_DIR}/tools/duic/duic CACHE INTERNAL "") maxter@344: set(QTD_IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/d${D_VERSION} CACHE INTERNAL "") SokoL_SD@235: set(QTD_LIBRARIES_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "") SokoL_SD@132: SokoL_SD@132: ##-------------------------------------------- SokoL_SD@182: ## Macros and functions. SokoL_SD@132: ##-------------------------------------------- SokoL_SD@132: SokoL_SD@235: macro(load_generated_classes ) SokoL_SD@237: include(${CMAKE_BINARY_DIR}/cpp/qt_${package}/qt_${package}.txt) Eldar@375: endmacro() SokoL_SD@235: SokoL_SD@182: macro(qtd_add_resource output) SokoL_SD@182: set (params NAME OPTIONS) SokoL_SD@182: qtd_parse_params (RESOURCES params ${ARGN}) SokoL_SD@182: if(NAME_tmp) maxter@344: set(OPTIONS_tmp ${OPTIONS_tmp} -name ${NAME_tmp}) SokoL_SD@182: endif(NAME_tmp) maxter@344: qtd_command ("${output}" "${DRCC}" "${OPTIONS_tmp}" "qrc_" maxter@344: "Generate" ${RESOURCES_tmp}) Eldar@375: endmacro() SokoL_SD@182: SokoL_SD@182: macro(qtd_wrap_ui output) SokoL_SD@182: set (params OPTIONS) SokoL_SD@182: qtd_parse_params (UI params ${ARGN}) maxter@344: qtd_command ("${output}" "${DUIC}" "${OPTIONS_tmp}" "uic_" maxter@344: "Generate" ${UI_tmp}) Eldar@375: endmacro() SokoL_SD@182: SokoL_SD@182: macro(qtd_command output command options prefix comment) SokoL_SD@182: foreach(file "${ARGN}") Eldar@375: ## Test if the input file exists Eldar@375: get_filename_component(file_path ${file} PATH) Eldar@375: get_filename_component(file_name ${file} NAME_WE) Eldar@375: get_filename_component(file_ext ${file} EXT) SokoL_SD@182: Eldar@375: set(out ${CMAKE_CURRENT_BINARY_DIR}/${file_path}${prefix}${file_name}.d) Eldar@375: add_custom_command(OUTPUT "${out}" maxter@344: COMMAND "${command}" maxter@344: ARGS ${options} ${file} -o ${out} maxter@344: WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} maxter@344: DEPENDS ${file} maxter@344: COMMENT "${comment} ${file}" maxter@344: ) Eldar@375: set(${output} ${${output}} ${out}) Eldar@375: endforeach() Eldar@375: endmacro() SokoL_SD@182: SokoL_SD@264: ## Parses the parameters list. SokoL_SD@182: macro(qtd_parse_params default params) SokoL_SD@182: set(type_tmp ${default}) maxter@344: set(params_tmp ${default} ${${params}}) maxter@344: foreach(param_tmp ${params_tmp}) Eldar@375: set(${param_tmp}_tmp ) Eldar@375: endforeach() SokoL_SD@182: foreach(arg_tmp ${ARGN}) Eldar@375: set(found_type_tmp) Eldar@375: if(NOT found_type_tmp) Eldar@375: foreach(param_tmp ${params_tmp}) Eldar@375: if(arg_tmp STREQUAL param_tmp) Eldar@375: set(type_tmp ${param_tmp}) Eldar@375: set(found_type_tmp 1) Eldar@375: break(param_tmp ${params_tmp}) Eldar@375: endif() Eldar@375: endforeach() Eldar@375: endif() Eldar@375: if(NOT found_type_tmp) Eldar@375: set(${type_tmp}_tmp ${${type_tmp}_tmp} ${arg_tmp}) Eldar@375: endif() Eldar@375: endforeach() Eldar@375: endmacro() SokoL_SD@132: SokoL_SD@264: ## Adds a new example. SokoL_SD@132: ## name -- example name. SokoL_SD@132: ## Options: maxter@344: ## PACKAGES -- list of packages for link to example (for example, QtCore QtGui QtOpenGL). maxter@344: ## Default value is "QtCore QtGui". SokoL_SD@132: ## params -- sources d files. SokoL_SD@132: ## Usage: maxter@344: ## build_example(ExampleName PACKAGES QtCore QtGui QtXml main.d another_d_file.d) SokoL_SD@132: macro(build_example name) SokoL_SD@182: set (params UIC RESOURCES PACKAGES) SokoL_SD@182: qtd_parse_params (SOURCES params ${ARGN}) SokoL_SD@182: SokoL_SD@182: if(NOT PACKAGES_tmp) Eldar@375: set(PACKAGES_tmp QtCore QtGui) Eldar@375: endif() maxter@344: SokoL_SD@182: if(RESOURCES_tmp) Eldar@375: if(NOT BUILD_TOOLS) Eldar@375: message(STATUS "Example '${name}' requires drcc. Example will not be built") Eldar@375: return(build_example name) Eldar@375: endif() Eldar@375: qtd_add_resource(res_sources ${RESOURCES_tmp} NAME ${name} ) Eldar@375: endif() SokoL_SD@182: SokoL_SD@182: if(UIC_tmp) Eldar@375: if(NOT BUILD_TOOLS) Eldar@375: message(STATUS "Example '${name}' requires drcc. Example will not be built") Eldar@375: return(build_example name) Eldar@375: endif() Eldar@375: qtd_wrap_ui(uic_sources ${UIC_tmp}) Eldar@375: endif() SokoL_SD@182: SokoL_SD@182: foreach(package ${PACKAGES_tmp}) Eldar@370: string(REGEX REPLACE "Qt([A-Za-z0-9])" "\\1" req "${package}") Eldar@370: set(is_found) Eldar@370: foreach(package_big ${packages_big}) Eldar@370: string(TOLOWER ${package_big} package) Eldar@370: if(${req} STREQUAL ${package_big}) Eldar@370: set(is_found 1) Eldar@370: break(package_big ${packages_big}) Eldar@370: endif() Eldar@370: endforeach() Eldar@370: if(NOT is_found) Eldar@370: message(STATUS "Example '${name}' requires the package '${req}', but it is not active. Example will not be built") Eldar@370: return(build_example name) Eldar@370: else() Eldar@370: set(qtd_libs cpp_${package} ${${package}_lib_param} ${qtd_libs}) Eldar@370: endif() Eldar@370: endforeach() SokoL_SD@203: add_d_program(${name} ${SOURCES_tmp} NO_DEPS_SOURCES ${res_sources} ${uic_sources} maxter@344: DEPENDS ${res_sources} INCLUDES ${QTD_IMPORT_PATH} ${CMAKE_CURRENT_BINARY_DIR} maxter@344: LIB_PATHS ${QTD_LIBRARIES_PATH} ${CMAKE_SOURCE_DIR}/lib ${QT_LIBRARY_DIR} LIBS ${qtd_libs}) SokoL_SD@264: ## TODO: Uncomment. SokoL_SD@235: #if(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) ## maxter@344: # add_custom_command(TARGET example_${name} POST_BUILD COMMAND "${STRIP}" ARGS "${output}") SokoL_SD@235: #endif(STRIP AND ${CMAKE_BUILD_TYPE} EQUAL "Release" AND CMAKE_HOST_UNIX) SokoL_SD@237: add_dependencies(examples ${name}) SokoL_SD@237: add_dependencies(${name} allpackages tools) Eldar@375: endmacro() SokoL_SD@132: SokoL_SD@132: ##-------------------------------------------- SokoL_SD@264: ## Build and install the QtD libraries. SokoL_SD@132: ##-------------------------------------------- SokoL_SD@132: SokoL_SD@132: file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) SokoL_SD@132: add_custom_target(allpackages) SokoL_SD@132: link_directories(${CMAKE_BINARY_DIR}/CMakeFiles) SokoL_SD@132: SokoL_SD@132: foreach(package_big ${all_packages}) maxter@344: string(TOLOWER ${package_big} package) SokoL_SD@264: string(TOUPPER ${package} package_upper) SokoL_SD@264: ## Load settings for the package. SokoL_SD@132: set(required) SokoL_SD@132: set(d_objs) SokoL_SD@132: set(cpp_objs) SokoL_SD@132: set(d_sources) SokoL_SD@132: set(cpp_sources) SokoL_SD@132: set(lib_name) SokoL_SD@132: set(link_cpp) SokoL_SD@132: set(link_d) SokoL_SD@132: set(cpp_files) SokoL_SD@227: set(cpp_generated_files) maxter@344: set(d_qt_files) maxter@344: set(d_qtd_files) SokoL_SD@132: set(classes) SokoL_SD@132: set(d_generated_files) SokoL_SD@132: set(link_example) maxter@344: include (${CMAKE_SOURCE_DIR}/build/${package}.txt) SokoL_SD@132: SokoL_SD@132: set(all_req_found 1) SokoL_SD@132: if(BUILD_QT_${package_upper}) Eldar@378: foreach(req ${required}) Eldar@370: set(req_found) Eldar@378: foreach(pack ${packages_big}) Eldar@378: if(${pack} STREQUAL ${req}) Eldar@378: set(req_found 1) Eldar@370: endif() Eldar@378: endforeach(pack ${packages}) Eldar@378: if(NOT req_found) Eldar@378: set(req_found) Eldar@378: foreach(pack ${all_packages}) Eldar@378: if(${pack} STREQUAL ${req}) Eldar@378: set(req_found 1) Eldar@378: endif(${pack} STREQUAL ${req}) Eldar@378: endforeach(pack ${all_packages}) Eldar@378: if(req_found) Eldar@378: message(STATUS "Package '${package_big}' requires '${req}', but it is not active") Eldar@378: else() Eldar@378: message(STATUS "Package '${package_big}' requires '${req}', but it is not found") Eldar@378: endif() Eldar@378: set(all_req_found) Eldar@378: endif() Eldar@378: endforeach(req ${required}) SokoL_SD@132: else(BUILD_QT_${package_upper}) Eldar@378: set(all_req_found) SokoL_SD@132: endif(BUILD_QT_${package_upper}) maxter@344: SokoL_SD@132: if("${all_req_found}" EQUAL 1) maxter@344: set(packages_big ${packages_big} ${package_big}) maxter@344: set(packages ${packages} ${package}) maxter@344: ## Load a package sources list. maxter@344: foreach(d_source ${package}/ArrayOps2 ${d_generated_files}) maxter@344: set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}.d) maxter@344: if(EXISTS ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) maxter@344: set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${d_source}_aux.d) Eldar@370: endif() maxter@344: endforeach(d_source ${d_generated_files}) maxter@344: set(classes ArrayOps ${classes}) maxter@344: foreach(class ${classes}) maxter@344: set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}.d) maxter@344: set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/qt_${package}/${class}_shell.cpp) maxter@344: if(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) maxter@344: set(d_sources ${d_sources} ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) maxter@344: endif(EXISTS ${CMAKE_BINARY_DIR}/qt/${package}/${class}_aux.d) maxter@344: endforeach(class ${classes}) maxter@344: set(files_for_gen ${files_for_gen} ${cpp_sources} ${d_sources}) maxter@344: maxter@344: foreach (cpp_source ${cpp_files}) maxter@344: set(cpp_sources ${cpp_sources} ${CMAKE_SOURCE_DIR}/cpp/${cpp_source}.cpp) maxter@344: endforeach(cpp_source ${cpp_files}) maxter@344: foreach (cpp_source ${cpp_generated_files}) maxter@344: set(cpp_sources ${cpp_sources} ${CMAKE_BINARY_DIR}/cpp/${cpp_source}.cpp) maxter@344: endforeach(cpp_source ${cpp_generated_files}) maxter@344: foreach(d_source ${d_qt_files}) maxter@344: set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qt/${d_source}.d) maxter@344: endforeach(d_source ${d_qt_files}) maxter@344: foreach(d_source ${d_qtd_files}) maxter@344: set(d_sources ${d_sources} ${CMAKE_SOURCE_DIR}/d${D_VERSION}/qtd/${d_source}.d) maxter@344: endforeach(d_source ${d_qtd_files}) SokoL_SD@132: maxter@344: if(NOT GENERATE_DI_FILES) maxter@344: foreach(d_source ${d_sources}) maxter@344: get_filename_component(path ${d_source} PATH) maxter@344: get_filename_component(name ${d_source} NAME_WE) maxter@344: regex_safe_string(cbd_safe_tmp ${CMAKE_CURRENT_BINARY_DIR}) maxter@344: regex_safe_string(csd_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}) maxter@363: regex_safe_string(ver_safe_tmp ${CMAKE_CURRENT_SOURCE_DIR}/d${D_VERSION}) maxter@344: set(regexp_str_tmp "(${ver_safe_tmp}/|${cbd_safe_tmp}/|${csd_safe_tmp}/|)(.+)") maxter@344: string(REGEX REPLACE ${regexp_str_tmp} "\\2" ins_path "${path}") maxter@344: install(FILES ${d_source} DESTINATION include/d/${ins_path} COMPONENT qtd RENAME ${name}.di) maxter@344: endforeach(d_source ${d_sources}) maxter@344: endif(NOT GENERATE_DI_FILES) SokoL_SD@132: maxter@357: ### Build the CPP part. maxter@344: if(CPP_SHARED) maxter@344: set(cpp_method SHARED) Eldar@370: else() maxter@344: set(cpp_method STATIC) Eldar@370: endif() maxter@344: add_library(cpp_${package} ${cpp_method} ${cpp_sources}) Eldar@370: # FIXME, do less redundant Eldar@370: if(CMAKE_HOST_WIN32) Eldar@370: set_target_properties(cpp_${package} PROPERTIES Eldar@370: RUNTIME_OUTPUT_DIRECTORY lib Eldar@370: ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles Eldar@370: LINK_FLAGS -Wl,-enable-auto-import Eldar@370: COMPILE_DEFINITIONS QTD_${package_upper} Eldar@370: ) Eldar@370: else() Eldar@370: set_target_properties(cpp_${package} PROPERTIES Eldar@370: LIBRARY_OUTPUT_DIRECTORY lib Eldar@370: ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles Eldar@370: COMPILE_DEFINITIONS QTD_${package_upper} Eldar@370: ) Eldar@370: endif() maxter@357: maxter@344: set(link_cpp ${link_cpp} ${QT_QT${package_upper}_LIBRARY}) Eldar@370: if(NOT CPP_SHARED) maxter@344: ## Get an objects list. It will be used in building the D part. maxter@344: foreach(cpp_source ${cpp_sources}) maxter@344: set(cpp_source ${cpp_source}) maxter@344: obj_path(cpp_source) maxter@344: set(cpp_objs ${cpp_objs} ${CMAKE_BINARY_DIR}/CMakeFiles/cpp_${package}.dir/${cpp_source}${CMAKE_CXX_OUTPUT_EXTENSION}) maxter@344: endforeach(cpp_source ${cpp_sources}) Eldar@370: endif() SokoL_SD@132: maxter@344: ## Settings for the D part. maxter@344: set(lib_name qtd${package}) maxter@344: if(BUILD_SHARED_LIBRARIES) maxter@344: set(lib lib/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) maxter@344: set(build_type SHARED) Eldar@370: else() maxter@344: set(lib lib/${D_LIB_PREFIX}${lib_name}${D_LIB_SUFFIX}) maxter@344: set(build_type STATIC) Eldar@370: endif() SokoL_SD@132: maxter@344: ## Package dependencies. maxter@344: foreach(req ${required}) maxter@344: set(is_found) maxter@344: foreach(pack ${packages_big}) Eldar@370: if("${pack}" STREQUAL "${req}") Eldar@370: set(is_found 1) Eldar@370: break(pack ${packages_big}) Eldar@370: endif() Eldar@370: endforeach() maxter@344: if(NOT is_found) Eldar@370: message(FATAL_ERROR "Package ${package_big} requires ${req}, but it is not found") Eldar@370: endif() maxter@344: string(TOUPPER ${req} req_upper) maxter@344: string(TOLOWER ${req} req_lower) maxter@344: set(link_cpp ${link_cpp} cpp_${req_lower} ${QT_QT${req_upper}_LIBRARY}) Eldar@370: endforeach() maxter@344: target_link_libraries(cpp_${package} ${link_cpp} ) maxter@344: set(d_objs ${d_objs} ${objects}) SokoL_SD@132: maxter@372: if(CPP_SHARED) maxter@374: set(cpp_lib ${CMAKE_BINARY_DIR}/lib/libcpp_${package}${CMAKE_SHARED_LIBRARY_SUFFIX}) maxter@344: install(FILES ${cpp_lib} COMPONENT qtd DESTINATION lib) maxter@372: maxter@372: if(CMAKE_HOST_WIN32) maxter@372: ## Create an implib library which will be linked to the D part. maxter@372: set(cpp_lib_native ${cpp_lib}) maxter@372: make_native_path(cpp_lib_native) maxter@372: set(d_implib ${CMAKE_BINARY_DIR}/CMakeFiles/${package}.dir/cpp_${package}.lib) maxter@372: set(d_implib_native ${d_implib}) maxter@372: make_native_path(d_implib_native) maxter@372: add_custom_command( maxter@372: OUTPUT "${d_implib}" maxter@372: COMMAND "${IMPLIB}" maxter@372: ARGS /system /PAGESIZE:64 ${d_implib_native} ${cpp_lib_native} maxter@372: DEPENDS "cpp_${package}" maxter@372: COMMENT "Creating implib ${lib_name}" maxter@372: ) maxter@372: endif() Eldar@370: else() maxter@344: set(${package}_lib_param Qt${package_big}) Eldar@370: endif() maxter@372: maxter@344: ## Link the D part. maxter@344: add_d_target(${lib_name} NOT_DETECT_DEPENDS TYPE ${build_type} INCLUDES ${QTD_IMPORT_PATH} SOURCES ${d_sources} OBJECTS ${cpp_objs} ${d_implib} maxter@344: OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib DEPENDS ${d_implib} ) maxter@344: install(FILES ${CMAKE_BINARY_DIR}/${lib} COMPONENT qtd DESTINATION lib) maxter@344: ## Paths for the QtD libs. It is necessary for examples. maxter@344: set(${package}_lib_param qtd${package} ${${package}_lib_param} ${link_example}) SokoL_SD@132: maxter@344: ## Generate dependences for make (or nmake). maxter@344: add_custom_target(${package}) maxter@344: add_dependencies(${package} ${lib_name}) maxter@357: maxter@344: add_dependencies(${lib_name} cpp_${package}) maxter@344: foreach(depend ${required}) maxter@344: string(TOLOWER ${depend} depend) maxter@344: add_dependencies(cpp_${package} cpp_${depend}) maxter@344: add_dependencies(${package} ${depend}) maxter@344: endforeach(depend ${required}) maxter@344: add_dependencies(allpackages ${package}) maxter@344: maxter@363: ## TODO: Do we need to generate *.di files? maxter@344: if(GENERATE_DI_FILES) maxter@344: regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) maxter@344: regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) maxter@344: set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") maxter@344: foreach(source ${d_sources}) maxter@344: # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} maxter@344: # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) maxter@344: string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") maxter@344: string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") maxter@344: set(interface_file_path ${CMAKE_BINARY_DIR}/d/${inc_path}) maxter@344: set(interface_file "${interface_file_path}/${file_name}.di") maxter@344: if(NOT "${file_name}" STREQUAL "QGlobal") maxter@344: add_custom_command(OUTPUT "${interface_file}" maxter@344: COMMAND "${DC}" maxter@344: ARGS ${D_FLAGS} -o- -H -Hd${interface_file_path} ${source} maxter@344: COMMENT "Generating header for ${source}" maxter@344: DEPENDS ${source} maxter@344: WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} maxter@344: ) maxter@344: else(NOT "${file_name}" STREQUAL "QGlobal") ## The DMD frontend crashes on this file. maxter@344: add_custom_command(OUTPUT "${interface_file}" maxter@344: COMMAND ${CMAKE_COMMAND} -E make_directory ${interface_file_path} maxter@344: COMMAND ${CMAKE_COMMAND} -E remove -f ${interface_file} maxter@344: COMMAND ${CMAKE_COMMAND} -E copy ${source} ${interface_file} maxter@344: COMMENT "" maxter@344: DEPENDS ${source} maxter@344: WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} maxter@344: ) maxter@344: endif(NOT "${file_name}" STREQUAL "QGlobal" AND GENERATE_DI_FILES) maxter@344: set(interfaces_list ${interfaces_list} ${interface_file_path}/${file_name}.di) maxter@344: install(FILES ${interface_file} COMPONENT qtd DESTINATION include/d/${inc_path}) maxter@344: endforeach(source) maxter@344: endif(GENERATE_DI_FILES) SokoL_SD@132: endif("${all_req_found}" EQUAL 1) SokoL_SD@132: endforeach(package_big ${packages_big}) maxter@344: if(GENERATE_DI_FILES) SokoL_SD@132: add_custom_target(generate_headers ALL DEPENDS ${interfaces_list}) SokoL_SD@132: endif(GENERATE_DI_FILES) SokoL_SD@132: SokoL_SD@132: set(CPACK_COMPONENTS_ALL qtd qtd_tools) SokoL_SD@132: SokoL_SD@132: ##-------------------------------------------- SokoL_SD@132: ## Build other parts of the QtD. SokoL_SD@132: ##-------------------------------------------- SokoL_SD@237: SokoL_SD@132: if(BUILD_TOOLS) SokoL_SD@237: add_custom_target(tools ALL) SokoL_SD@132: add_subdirectory(tools) SokoL_SD@132: add_dependencies(tools drcc duic) SokoL_SD@132: endif(BUILD_TOOLS) SokoL_SD@132: SokoL_SD@132: if(BUILD_EXAMPLES) SokoL_SD@237: add_custom_target(examples ALL) SokoL_SD@237: add_dependencies(examples allpackages tools) SokoL_SD@132: add_subdirectory(demos) SokoL_SD@132: add_subdirectory(examples) SokoL_SD@132: endif(BUILD_EXAMPLES) SokoL_SD@132: SokoL_SD@239: set(SECOND_RUN 0 CACHE INTERNAL "") SokoL_SD@235: maxter@344: endif(NOT SECOND_RUN) Eldar@375: Eldar@375: ##-------------------------------------------- Eldar@375: ## CPack. Eldar@375: ##-------------------------------------------- Eldar@375: set(CPACK_PACKAGE_VERSION_PATCH 1) Eldar@375: set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QtD is a D binding to the Qt application and UI framework.") Eldar@375: set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt") Eldar@375: set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/license.txt") Eldar@375: set(CPACK_PACKAGE_VENDOR "QtD team") Eldar@375: set(CPACK_PACKAGE_CONTACT "e@mail.com") e@376: set(CPACK_PACKAGE_VERSION "0.6") Eldar@375: set(CPACK_PACKAGE_INSTALL_DIRECTORY "qtd ${CPACK_PACKAGE_VERSION}") Eldar@375: set(CPACK_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") Eldar@375: set(CPACK_SOURCE_PACKAGE_FILE_NAME "qtd-${CPACK_PACKAGE_VERSION}") Eldar@375: if(CMAKE_HOST_WIN32) Eldar@375: set(CPACK_GENERATOR "ZIP") Eldar@375: elseif(CMAKE_HOST_UNIX) Eldar@375: set(CPACK_GENERATOR "TBZ2;DEB") Eldar@375: endif() Eldar@375: include(CPack)