summaryrefslogtreecommitdiffstats
path: root/cmake/QtFeature.cmake
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-01-14 11:35:53 +0100
committerTobias Hunger <tobias.hunger@qt.io>2019-01-17 16:16:55 +0000
commit6a1ee4de07cbaaeb0583b191fee6258e0a4003e4 (patch)
treee86409147fc72c1f714773baf810380b1aa33da8 /cmake/QtFeature.cmake
parent3ec578020c9e088c7356da07d9112ece37bbf496 (diff)
CMake: Store Qt features in CMake Cache
This is less self-contained than what we have, but significantly speeds up cmake configure/generate runs. This patch also warns when a feature is already defined. Change-Id: I8cab63e208ba98756b47d362a39b462f5ec55e20 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake/QtFeature.cmake')
-rw-r--r--cmake/QtFeature.cmake73
1 files changed, 27 insertions, 46 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index 7b8f11e896..aa18b380a6 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -180,7 +180,10 @@ macro(qt_feature_set_value feature cache emit_if condition label)
message(SEND_ERROR "Feature \"${feature}\": Forcing to \"${cache}\" breaks its condition.")
endif()
- set(QT_FEATURE_${feature} "${result}" PARENT_SCOPE)
+ if (DEFINED "QT_FEATURE_${feature}")
+ message(FATAL_ERROR "Feature ${feature} is already defined when evaluating configure.cmake features for ${target}.")
+ endif()
+ set(QT_FEATURE_${feature} "${result}" CACHE INTERNAL "Qt feature: ${feature}")
endmacro()
function(qt_evaluate_feature feature)
@@ -379,8 +382,6 @@ function(qt_feature_module_end target)
unset(__QtFeature_private_extra PARENT_SCOPE)
unset(__QtFeature_public_extra PARENT_SCOPE)
-
- qt_push_features_into_parent_scope()
endfunction()
function(qt_config_compile_test name)
@@ -400,55 +401,35 @@ function(qt_config_compile_test_x86simd extension label)
set(TEST_subarch_${extension} "${TEST_X86SIMD_${extension}}" CACHE INTERNAL "${label}" )
endfunction()
-function(qt_pull_features_into_current_scope)
- cmake_parse_arguments(arg "PUBLIC_FEATURES;PRIVATE_FEATURES" "" "" ${ARGN})
- foreach(target IN ITEMS ${arg_UNPARSED_ARGUMENTS})
- if(NOT "${target}" MATCHES "^Qt::[a-zA-z][a-zA-Z0-9_]*$")
- message(FATAL_ERROR "${target} does not match Qt::[a-zA-z][a-zA-Z0-9_]*. INVALID NAME.")
- endif()
- if(NOT TARGET ${target})
- message(FATAL_ERROR "${target} not found.")
- endif()
+function(qt_make_features_available target)
+ if(NOT "${target}" MATCHES "^Qt::[a-zA-z][a-zA-Z0-9_]*$")
+ message(FATAL_ERROR "${target} does not match Qt::[a-zA-z][a-zA-Z0-9_]*. INVALID NAME.")
+ endif()
+ if(NOT TARGET ${target})
+ message(FATAL_ERROR "${target} not found.")
+ endif()
- get_target_property(target_type "${target}" TYPE)
- if("${target_type}" STREQUAL "INTERFACE_LIBRARY")
- set(property_prefix "INTERFACE_")
- else()
- set(property_prefix "")
- endif()
- foreach(visibility IN ITEMS PUBLIC PRIVATE)
- if(NOT ${arg_${visibility}_FEATURES})
+ get_target_property(target_type "${target}" TYPE)
+ if("${target_type}" STREQUAL "INTERFACE_LIBRARY")
+ set(property_prefix "INTERFACE_")
+ else()
+ set(property_prefix "")
+ endif()
+ foreach(visibility IN ITEMS PUBLIC PRIVATE)
+ set(value ON)
+ foreach(state IN ITEMS ENABLED DISABLED)
+ get_target_property(features "${target}" ${property_prefix}QT_${state}_${visibility}_FEATURES)
+ if("${features}" STREQUAL "features-NOTFOUND")
continue()
endif()
-
- set(value ON)
- foreach(state IN ITEMS ENABLED DISABLED)
- get_target_property(features "${target}" ${property_prefix}QT_${state}_${visibility}_FEATURES)
- if("${features}" STREQUAL "features-NOTFOUND")
- continue()
+ foreach(feature IN ITEMS ${features})
+ if (DEFINED "QT_FEATURE_${feature}")
+ message(FATAL_ERROR "Feature ${feature} is already defined when importing features from ${target}.")
endif()
- foreach(feature IN ITEMS ${features})
- set(QT_FEATURE_${feature} ${value} PARENT_SCOPE)
- endforeach()
- set(value OFF)
+ set(QT_FEATURE_${feature} "${value}" CACHE INTERNAL "Qt feature: ${feature}")
endforeach()
+ set(value OFF)
endforeach()
endforeach()
endfunction()
-macro(qt_push_features_into_parent_scope)
- get_cmake_property(_variableNames VARIABLES)
-
- foreach(_var IN ITEMS ${_variableNames})
- if(_var MATCHES "^QT_FEATURE_[a-z][a-z0-9_]*$")
- set("${_var}" "${${_var}}" PARENT_SCOPE)
- endif()
- endforeach()
-endmacro()
-
-macro(qt_load_global_features)
- if(NOT TARGET Qt::GlobalConfig)
- find_package(Qt${PROJECT_VERSION_MAJOR}GlobalConfig QUIET)
- endif()
- qt_pull_features_into_current_scope(PUBLIC_FEATURES PRIVATE_FEATURES Qt::GlobalConfig)
-endmacro()