summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-01-10 10:50:38 +0100
committerTobias Hunger <tobias.hunger@qt.io>2019-01-17 08:33:27 +0000
commit4f26758978e84f959a28d90b2ff336bae32a2d3f (patch)
tree056a6c261a0dd79696a36ea5f962a9b8aa8ac27e /cmake
parentb705021b4eaed1e61d39dc481fd5373722c6f460 (diff)
CMake: Introduce Qt::GlobalConfig to hold the global features
This simplifies the handling of features a bit as it removes the special code to store two sets of features in Qt::Core. Change-Id: I536d41cfc76a02af054e3cfbad6bda50b1e9e49a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBaseGlobalTargets.cmake29
-rw-r--r--cmake/QtBuild.cmake9
-rw-r--r--cmake/QtFeature.cmake15
-rw-r--r--cmake/tests/features/CMakeLists.txt6
4 files changed, 37 insertions, 22 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index b53fd0f368..714508ec7c 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -15,8 +15,6 @@ target_include_directories("${name}"
)
target_compile_definitions("${name}" INTERFACE ${QT_PLATFORM_DEFINITIONS})
set(config_install_dir "${INSTALL_LIBDIR}/cmake/${name}${PROJECT_VERSION_MAJOR}")
-install(TARGETS "${name}" EXPORT "${name}${PROJECT_VERSION_MAJOR}Targets")
-install(EXPORT "${name}${PROJECT_VERSION_MAJOR}Targets" NAMESPACE Qt:: DESTINATION "${config_install_dir}")
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/QtConfig.cmake.in"
@@ -37,15 +35,36 @@ install(FILES
## Library to hold global features:
-add_library(Qt_global_Config INTERFACE)
-
+## These features are stored and accessed via Qt::GlobalConfig, but the
+## files always lived in Qt::Core, so we keep it that way
+add_library(GlobalConfig INTERFACE)
+target_include_directories(GlobalConfig INTERFACE
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore>
+ $<INSTALL_INTERFACE:include>
+ $<INSTALL_INTERFACE:include/QtCore>
+)
qt_feature_module_begin(LIBRARY Core
PUBLIC_FILE src/corelib/global/qconfig.h
PRIVATE_FILE src/corelib/global/qconfig_p.h
)
include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
-qt_feature_module_end(Qt_global_Config)
+qt_feature_module_end(GlobalConfig)
+add_library(Qt::GlobalConfig ALIAS GlobalConfig)
+
+add_library(GlobalConfigPrivate INTERFACE)
+target_link_libraries(GlobalConfigPrivate INTERFACE GlobalConfig)
+target_include_directories(GlobalConfigPrivate INTERFACE
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}/QtCore>
+ $<INSTALL_INTERFACE:include/QtCore/${PROJECT_VERSION}>
+ $<INSTALL_INTERFACE:include/QtCore/${PROJECT_VERSION}/QtCore>
+)
+add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
+
+install(TARGETS "${name}" GlobalConfig GlobalConfigPrivate EXPORT "${name}${PROJECT_VERSION_MAJOR}Targets")
+install(EXPORT "${name}${PROJECT_VERSION_MAJOR}Targets" NAMESPACE Qt:: DESTINATION "${config_install_dir}")
## Install some QtBase specific CMake files:
install(FILES
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 446746c011..d35254c48f 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -272,11 +272,6 @@ function(extend_target target)
list(APPEND dbus_sources "${sources}")
endforeach()
- # Import features
- if(NOT "${target}" STREQUAL "Core")
- qt_pull_features_into_current_scope(PUBLIC_FEATURES PRIVATE_FEATURES FEATURE_PROPERTY_INFIX "GLOBAL_" Qt::Core)
- endif()
-
foreach(dep ${arg_FEATURE_DEPENDENCIES} ${arg_LIBRARIES} ${arg_PUBLIC_LIBRARIES})
if("${dep}" MATCHES "^Qt::((.+)(Private)|(.+))$")
if (${CMAKE_MATCH_COUNT} EQUAL 3)
@@ -292,9 +287,9 @@ function(extend_target target)
endif()
if("x${CMAKE_MATCH_3}" STREQUAL "xPrivate")
- qt_pull_features_into_current_scope(PRIVATE_FEATURES ${depTarget})
+ qt_pull_features_into_current_scope(PRIVATE_FEATURES "Qt::${depTarget}")
endif()
- qt_pull_features_into_current_scope(PUBLIC_FEATURES ${depTarget})
+ qt_pull_features_into_current_scope(PUBLIC_FEATURES "Qt::${depTarget}")
endif()
endforeach()
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index 380626b35a..ba4ca41c5b 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -401,11 +401,12 @@ function(qt_config_compile_test_x86simd extension label)
endfunction()
function(qt_pull_features_into_current_scope)
- cmake_parse_arguments(arg "PUBLIC_FEATURES;PRIVATE_FEATURES" "FEATURE_PROPERTY_INFIX" "" ${ARGN})
+ cmake_parse_arguments(arg "PUBLIC_FEATURES;PRIVATE_FEATURES" "" "" ${ARGN})
foreach(target IN ITEMS ${arg_UNPARSED_ARGUMENTS})
if(NOT TARGET ${target})
continue()
endif()
+
get_target_property(target_type "${target}" TYPE)
if("${target_type}" STREQUAL "INTERFACE_LIBRARY")
set(property_prefix "INTERFACE_")
@@ -419,11 +420,11 @@ function(qt_pull_features_into_current_scope)
set(value ON)
foreach(state IN ITEMS ENABLED DISABLED)
- get_target_property(features "${target}" ${property_prefix}QT_${arg_FEATURE_PROPERTY_INFIX}${state}_${visibility}_FEATURES)
+ get_target_property(features "${target}" ${property_prefix}QT_${state}_${visibility}_FEATURES)
if("${features}" STREQUAL "features-NOTFOUND")
continue()
endif()
- foreach(feature ${features})
+ foreach(feature IN ITEMS ${features})
set(QT_FEATURE_${feature} ${value} PARENT_SCOPE)
endforeach()
set(value OFF)
@@ -437,7 +438,7 @@ macro(qt_push_features_into_parent_scope)
list (SORT _variableNames)
list(REMOVE_DUPLICATES _variableNames)
- foreach(_var ${_variableNames})
+ foreach(_var IN ITEMS ${_variableNames})
if(_var MATCHES "^QT_FEATURE_[a-z][a-z0-9_]*$")
set("${_var}" "${${_var}}" PARENT_SCOPE)
endif()
@@ -445,8 +446,8 @@ macro(qt_push_features_into_parent_scope)
endmacro()
macro(qt_load_global_features)
- if(NOT TARGET Qt::Core)
- find_package(Qt${PROJECT_VERSION_MAJOR}Core QUIET)
+ if(NOT TARGET Qt::GlobalConfig)
+ find_package(Qt${PROJECT_VERSION_MAJOR}GlobalConfig QUIET)
endif()
- qt_pull_features_into_current_scope(PUBLIC_FEATURES PRIVATE_FEATURES FEATURE_PROPERTY_INFIX "GLOBAL_" Qt::Core)
+ qt_pull_features_into_current_scope(PUBLIC_FEATURES PRIVATE_FEATURES Qt::GlobalConfig)
endmacro()
diff --git a/cmake/tests/features/CMakeLists.txt b/cmake/tests/features/CMakeLists.txt
index 32cff572bd..0fff2b8be9 100644
--- a/cmake/tests/features/CMakeLists.txt
+++ b/cmake/tests/features/CMakeLists.txt
@@ -14,14 +14,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../;${CMAKE_CURREN
include(QtSetup)
## Library to hold global features:
-add_library(Qt_global_Config INTERFACE)
+add_library(GlobalConfig INTERFACE)
-qt_feature_module_begin(LIBRARY Core
+qt_feature_module_begin(LIBRARY GlobalConfig
PUBLIC_FILE src/corelib/global/qconfig.h
PRIVATE_FILE src/corelib/global/qconfig_p.h
)
include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
-qt_feature_module_end(Qt_global_Config)
+qt_feature_module_end(GlobalConfig)
assert(QT_FEATURE_top_a STREQUAL "ON")
assert(QT_FEATURE_top_b STREQUAL "OFF")