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>
This commit is contained in:
parent
b705021b4e
commit
4f26758978
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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")
|
||||
|
@ -232,12 +232,15 @@ add_qt_module(Core
|
||||
WrapDoubleConversion
|
||||
tinycbor Threads::Threads ZLIB::ZLIB
|
||||
QtHarfBuzz
|
||||
Qt::GlobalConfigPrivate
|
||||
PUBLIC_LIBRARIES Qt::Platform
|
||||
DEFINES
|
||||
QT_NO_USING_NAMESPACE
|
||||
QT_NO_FOREACH
|
||||
)
|
||||
|
||||
configure_file(global/qconfig.cpp.in global/qconfig.cpp)
|
||||
|
||||
# Handle QObject: Automoc does not work for this as it would
|
||||
# require to spill internals into users:
|
||||
add_library(Core_qobject OBJECT)
|
||||
@ -254,7 +257,7 @@ target_include_directories(Core_qobject PRIVATE
|
||||
"${PROJECT_BINARY_DIR}/include/QtCore"
|
||||
"${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}"
|
||||
"${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}/QtCore")
|
||||
target_link_libraries(Core_qobject PRIVATE Qt::Platform)
|
||||
target_link_libraries(Core_qobject PRIVATE Qt::Platform Qt::GlobalConfig)
|
||||
target_link_libraries(Core PRIVATE Core_qobject)
|
||||
|
||||
# Comments trigger moc for these, so skip automoc:
|
||||
@ -263,21 +266,6 @@ set_source_files_properties( tools/qsharedpointer.cpp PROPERTIES SKIP_AUTOMOC ON
|
||||
set_property(TARGET Core APPEND PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig.h")
|
||||
set_property(TARGET Core APPEND PROPERTY PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig_p.h")
|
||||
|
||||
# As a special feature, the global features are attached to QtCore as
|
||||
# custom properties. That's symmetric to qconfig.cpp/h being part of
|
||||
# QtCore and not of a QtGlobal library.
|
||||
|
||||
foreach(visibility PUBLIC PRIVATE)
|
||||
foreach(state ENABLED DISABLED)
|
||||
get_target_property(props Qt_global_Config INTERFACE_QT_${state}_${visibility}_FEATURES)
|
||||
set(propertyName "QT_GLOBAL_${state}_${visibility}_FEATURES")
|
||||
set_property(TARGET Core PROPERTY ${propertyName} "${props}")
|
||||
set_property(TARGET Core APPEND PROPERTY EXPORT_PROPERTIES "${propertyName}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
configure_file(global/qconfig.cpp.in global/qconfig.cpp)
|
||||
|
||||
# FIXME: tools still have a lot of special stuff that is not ported!
|
||||
|
||||
# FIXME: qmake condition: (linux*|hurd*):!cross_compile:!static:!*-armcc*
|
||||
|
Loading…
Reference in New Issue
Block a user