diff options
-rw-r--r-- | CMakeLists.txt | 21 | ||||
-rw-r--r-- | cmake/QtBaseGlobalTargets.cmake | 18 | ||||
-rw-r--r-- | cmake/QtBuild.cmake | 23 | ||||
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 40 | ||||
-rw-r--r-- | cmake/QtModuleConfig.cmake.in | 4 | ||||
-rw-r--r-- | cmake/QtPostProcess.cmake | 27 | ||||
-rw-r--r-- | src/corelib/Qt5CoreMacros.cmake | 23 |
7 files changed, 96 insertions, 60 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ecc88a27e3..f0a8ef2a96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,13 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/3rdparty/kwin" ) -## Qt specific setup common for all modules: -include(QtSetup) +## Find the build internals package. +list(APPEND CMAKE_PREFIX_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/cmake" +) +find_package(QtBuildInternals) -## Enable feature summary at the end of the configure run: -include(FeatureSummary) +qt_build_repo_begin(SKIP_CMAKE_MODULE_PATH_ADDITION) ## QtBase specific configure tests: include(QtBaseConfigureTests) @@ -52,13 +54,4 @@ if (BUILD_EXAMPLES) add_subdirectory(examples) endif() -## Delayed actions on some of the Qt targets: -include(QtPostProcess) - -## Print a feature summary: -feature_summary(WHAT PACKAGES_FOUND - REQUIRED_PACKAGES_NOT_FOUND - RECOMMENDED_PACKAGES_NOT_FOUND - OPTIONAL_PACKAGES_NOT_FOUND - RUNTIME_PACKAGES_NOT_FOUND - FATAL_ON_MISSING_REQUIRED_PACKAGES) +qt_build_repo_end() diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index e7c8e2f0e8..7bb4795d35 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -122,3 +122,21 @@ qt_copy_or_install(DIRECTORY cmake/ PATTERN "tests" EXCLUDE PATTERN "3rdparty" EXCLUDE ) + +# Configure and install the QtBuildInternals package. +set(__build_internals_path_suffix "${INSTALL_CMAKE_NAMESPACE}BuildInternals") +qt_path_join(__build_internals_build_dir ${QT_CONFIG_BUILD_DIR} ${__build_internals_path_suffix}) +qt_path_join(__build_internals_install_dir ${QT_CONFIG_INSTALL_DIR} + ${__build_internals_path_suffix}) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake" + "${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake" + @ONLY + ) + +qt_install(FILES + "${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake" + "${__build_internals_build_dir}/QtBuildInternalsExtra.cmake" + DESTINATION "${__build_internals_install_dir}" + COMPONENT Devel +) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index bfbd0f69e4..cc5b9e63e1 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -160,6 +160,10 @@ endif() string(APPEND QT_CONFIG_INSTALL_DIR ${__config_path_part}) unset(__config_path_part) +# This is used to hold extra cmake code that should be put into QtBuildInternalsExtra.cmake file +# at the QtPostProcess stage. +set(QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "") + # Functions and macros: # Wraps install() command. In a prefix build, simply passes along arguments to install(). @@ -926,25 +930,6 @@ function(add_qt_module target) list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake") endif() - set(extra_cmake_code "") - - if(target STREQUAL Core) - # Propagate common variables via QtCore package. - string(APPEND extra_cmake_code "set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})") - string(APPEND extra_cmake_code " -option(BUILD_SHARED_LIBS \"Build Qt statically or dynamically\" ${BUILD_SHARED_LIBS})") - string(APPEND extra_cmake_code " -set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})") - string(APPEND extra_cmake_code " -set(_qt_core_cmake_dir \${CMAKE_CURRENT_LIST_DIR})") - - # Propagate developer builds to other modules via QtCore package. - if(FEATURE_developer_build) - string(APPEND extra_cmake_code " -set(FEATURE_developer_build ON CACHE BOOL \"Developer build.\" FORCE)") - endif() - endif() - configure_package_config_file( "${QT_CMAKE_DIR}/QtModuleConfig.cmake.in" "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake" diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake new file mode 100644 index 0000000000..a3b7bddb1a --- /dev/null +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -0,0 +1,40 @@ +if (CMAKE_VERSION VERSION_LESS 3.1.0) + message(FATAL_ERROR "Qt requires at least CMake version 3.1.0") +endif() + +###################################### +# +# Macros for building Qt modules +# +###################################### + +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake") + include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake) +endif() + +macro(qt_build_repo_begin) + if(${ARGC} EQUAL 1 AND "${ARGV0}" STREQUAL "SKIP_CMAKE_MODULE_PATH_ADDITION") + # No-op. + else() + # Set up the paths for the modules. + set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}") + list(APPEND CMAKE_MODULE_PATH ${QT_CMAKE_MODULE_PATH}) + endif() + + # Qt specific setup common for all modules: + include(QtSetup) + include(FeatureSummary) +endmacro() + +macro(qt_build_repo_end) + # Delayed actions on some of the Qt targets: + include(QtPostProcess) + + # Print a feature summary: + feature_summary(WHAT PACKAGES_FOUND + REQUIRED_PACKAGES_NOT_FOUND + RECOMMENDED_PACKAGES_NOT_FOUND + OPTIONAL_PACKAGES_NOT_FOUND + RUNTIME_PACKAGES_NOT_FOUND + FATAL_ON_MISSING_REQUIRED_PACKAGES) +endmacro() diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index 6a68fdf3b0..7baea8cf9c 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -5,10 +5,6 @@ include(CMakeFindDependencyMacro) get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(_import_prefix "${_import_prefix}" REALPATH) -# Extra cmake code begin -@extra_cmake_code@ -# Extra cmake code end - # Find required dependencies, if any. if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index 43a6617033..d900f8e88f 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -164,4 +164,31 @@ function(qt_internal_create_depends_files) endfunction() +function(qt_generate_build_internals_extra_cmake_code) + if(PROJECT_NAME STREQUAL "QtBase") + # Propagate common variables via BuildInternals package. + string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE + "set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})") + string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE " +option(BUILD_SHARED_LIBS \"Build Qt statically or dynamically\" ${BUILD_SHARED_LIBS})") + string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE " +set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})") + string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE " +set(QT_BUILD_INTERNALS_PATH \"\${CMAKE_CURRENT_LIST_DIR}\")") + + # Propagate developer builds to other modules via BuildInternals package. + if(FEATURE_developer_build) + string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE " +set(FEATURE_developer_build ON CACHE BOOL \"Developer build.\" FORCE)") + endif() + + qt_path_join(extra_file_path + ${QT_CONFIG_BUILD_DIR} + ${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake) + file(GENERATE OUTPUT "${extra_file_path}" + CONTENT "${QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE}") + endif() +endfunction() + qt_internal_create_depends_files() +qt_generate_build_internals_extra_cmake_code() diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index feab963a80..bae1518375 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -38,29 +38,6 @@ include(CMakeParseArguments) -macro(qt_build_repo_begin) - # Set up the paths for the modules. - set(QT_CMAKE_MODULE_PATH "${_qt_core_cmake_dir}/../${QT_CMAKE_EXPORT_NAMESPACE}") - list(APPEND CMAKE_MODULE_PATH ${QT_CMAKE_MODULE_PATH}) - - # Qt specific setup common for all modules: - include(QtSetup) - include(FeatureSummary) -endmacro() - -macro(qt_build_repo_end) - # Delayed actions on some of the Qt targets: - include(QtPostProcess) - - # Print a feature summary: - feature_summary(WHAT PACKAGES_FOUND - REQUIRED_PACKAGES_NOT_FOUND - RECOMMENDED_PACKAGES_NOT_FOUND - OPTIONAL_PACKAGES_NOT_FOUND - RUNTIME_PACKAGES_NOT_FOUND - FATAL_ON_MISSING_REQUIRED_PACKAGES) -endmacro() - # macro used to create the names of output files preserving relative dirs macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile ) string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength) |