summaryrefslogtreecommitdiffstats
path: root/cmake/QtBaseGlobalTargets.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-05-08 14:45:41 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-05-15 11:31:31 +0000
commit02a015375a639a4d27d19bbf435f20b725696768 (patch)
tree6efe36f0290cbe7d5eb4c44f847974c1bd44f645 /cmake/QtBaseGlobalTargets.cmake
parent6396d46f554e6eab2ba7f212bd7447961cd4c286 (diff)
Implement developer / non-prefix builds
A non-prefix build is a build where you don't have to run make install. To do a non-prefix build, pass -DFEATURE_developer_build=ON when invoking CMake on qtbase. Note that this of course also enables developer build features (private tests, etc). When doing a non-prefix build, the CMAKE_INSTALL_PREFIX cache variable will point to the qtbase build directory. Tests can be run without installing Qt (QPA plugins are picked up from the build dir). This patch stops installation of any files by forcing the make "install" target be a no-op. When invoking cmake on the qtsvg module (or any other module), the CMAKE_INSTALL_PREFIX variable should be set to the qtbase build directory. The developer-build feature is propagated via the QtCore Config file, so that when building other modules, you don't have to specify it on the command line again. As a result of the change, all libraries, plugins, tools, include dirs, CMake Config files, CMake Targets files, Macro files, etc, will be placed in the qtbase build directory, mimicking the file layout of an installed Qt file layout. Only examples and tests are kept in the separate module build directories, which is equivalent to how qmake does it. The following global variables contain paths for the appropriate prefix or non prefix builds: QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR. These should be used by developers when deciding where files should be placed. All usages of install() are replaced by qt_install(), which has some additional logic on how to handle associationg of CMake targets to export names. When installing files, some consideration should be taken if qt_copy_or_install() needs to be used instead of qt_install(), which takes care of copying files from the source dir to the build dir when doing non-prefix builds. Tested with qtbase and qtsvg, developer builds, non-developer builds and static developer builds on Windows, Linux and macOS. Task-number: QTBUG-75581 Change-Id: I0ed27fb6467662dd24fb23aee6b95dd2c9c4061f Reviewed-by: Kevin Funk <kevin.funk@kdab.com> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'cmake/QtBaseGlobalTargets.cmake')
-rw-r--r--cmake/QtBaseGlobalTargets.cmake92
1 files changed, 51 insertions, 41 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index af320a05b3..e7c8e2f0e8 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -9,41 +9,47 @@ target_include_directories(Platform
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>
)
target_compile_definitions(Platform INTERFACE ${QT_PLATFORM_DEFINITIONS})
-set(config_install_dir "${INSTALL_LIBDIR}/cmake/${INSTALL_CMAKE_NAMESPACE}")
+
+set(__GlobalConfig_path_suffix "${INSTALL_CMAKE_NAMESPACE}")
+qt_path_join(__GlobalConfig_build_dir ${QT_CONFIG_BUILD_DIR} ${__GlobalConfig_path_suffix})
+qt_path_join(__GlobalConfig_install_dir ${QT_CONFIG_INSTALL_DIR} ${__GlobalConfig_path_suffix})
# Generate and install Qt5 config file.
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/QtConfig.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
- INSTALL_DESTINATION "${config_install_dir}"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
+ INSTALL_DESTINATION "${__GlobalConfig_install_dir}"
)
+
write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake
+ ${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
-install(FILES
- "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
- "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake"
- DESTINATION "${config_install_dir}"
- COMPONENT Devel
-)
# Generate and install Qt5Tools config file.
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/QtToolsConfig.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}ToolsConfig.cmake"
- INSTALL_DESTINATION "${config_install_dir}"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfig.cmake"
+ INSTALL_DESTINATION "${__GlobalConfig_install_dir}"
)
write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}ToolsConfigVersion.cmake
+ ${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
-install(FILES
- "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}ToolsConfig.cmake"
- "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}ToolsConfigVersion.cmake"
- DESTINATION "${config_install_dir}Tools"
+
+qt_install(FILES
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}Config.cmake"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ConfigVersion.cmake"
+ DESTINATION "${__GlobalConfig_install_dir}"
+ COMPONENT Devel
+)
+
+qt_install(FILES
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfig.cmake"
+ "${__GlobalConfig_build_dir}/${INSTALL_CMAKE_NAMESPACE}ToolsConfigVersion.cmake"
+ DESTINATION "${__GlobalConfig_install_dir}Tools"
COMPONENT Devel
)
@@ -62,7 +68,7 @@ qt_feature_module_begin(LIBRARY Core
PRIVATE_FILE src/corelib/global/qconfig_p.h
)
include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
-qt_feature_module_end(GlobalConfig)
+qt_feature_module_end(GlobalConfig OUT_VAR_PREFIX "__GlobalConfig_")
add_library(Qt::GlobalConfig ALIAS GlobalConfig)
@@ -76,38 +82,42 @@ target_include_directories(GlobalConfigPrivate INTERFACE
)
add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
-install(TARGETS Platform GlobalConfig GlobalConfigPrivate EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets")
-install(EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets" NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}:: DESTINATION "${config_install_dir}")
-export(EXPORT "${INSTALL_CMAKE_NAMESPACE}Targets")
+set(__export_targets Platform GlobalConfig GlobalConfigPrivate)
+set(__export_name "${INSTALL_CMAKE_NAMESPACE}Targets")
+qt_install(TARGETS ${__export_targets} EXPORT "${__export_name}")
+qt_install(EXPORT ${__export_name}
+ NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
+ DESTINATION "${__GlobalConfig_install_dir}")
-qt_internal_export_modern_cmake_config_targets_file(TARGETS Platform GlobalConfig GlobalConfigPrivate
+qt_internal_export_modern_cmake_config_targets_file(TARGETS ${__export_targets}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}
- CONFIG_INSTALL_DIR ${config_install_dir})
+ CONFIG_INSTALL_DIR
+ ${__GlobalConfig_install_dir})
## Install some QtBase specific CMake files:
-install(FILES
- cmake/QtBuild.cmake
- cmake/QtCompilerFlags.cmake
- cmake/QtCompilerOptimization.cmake
- cmake/QtFeature.cmake
- cmake/QtPlatformSupport.cmake
- cmake/QtPostProcess.cmake
- cmake/QtSetup.cmake
- cmake/QtModuleConfig.cmake.in
- cmake/QtModuleDependencies.cmake.in
- cmake/QtModuleToolsDependencies.cmake.in
- cmake/QtModuleToolsConfig.cmake.in
- DESTINATION "${config_install_dir}"
+qt_copy_or_install(FILES
+ cmake/QtBuild.cmake
+ cmake/QtCompilerFlags.cmake
+ cmake/QtCompilerOptimization.cmake
+ cmake/QtFeature.cmake
+ cmake/QtPlatformSupport.cmake
+ cmake/QtPostProcess.cmake
+ cmake/QtSetup.cmake
+ cmake/QtModuleConfig.cmake.in
+ cmake/QtModuleDependencies.cmake.in
+ cmake/QtModuleToolsDependencies.cmake.in
+ cmake/QtModuleToolsConfig.cmake.in
+ DESTINATION "${__GlobalConfig_install_dir}"
)
+
+
# TODO: Check whether this is the right place to install these
-install(DIRECTORY cmake/3rdparty
- DESTINATION "${config_install_dir}"
-)
+qt_copy_or_install(DIRECTORY cmake/3rdparty DESTINATION "${__GlobalConfig_install_dir}")
# Install our custom Find modules, which will be used by the find_dependency() calls
# inside the generated ModuleDependencies cmake files.
-install(DIRECTORY cmake/
- DESTINATION "${config_install_dir}"
+qt_copy_or_install(DIRECTORY cmake/
+ DESTINATION "${__GlobalConfig_install_dir}"
FILES_MATCHING PATTERN "Find*.cmake"
PATTERN "tests" EXCLUDE
PATTERN "3rdparty" EXCLUDE