2020-08-12 07:17:21 +00:00
include ( QtFeatureCommon )
2020-08-19 14:49:13 +00:00
include ( CheckCXXCompilerFlag )
2020-08-12 07:17:21 +00:00
2018-10-24 13:20:27 +00:00
function ( qt_feature_module_begin )
2018-12-11 15:02:39 +00:00
qt_parse_all_arguments ( arg "qt_feature_module_begin"
2020-02-24 14:06:30 +00:00
" N O _ M O D U L E ; O N L Y _ E V A L U A T E _ F E A T U R E S "
" L I B R A R Y ; P R I V A T E _ F I L E ; P U B L I C _ F I L E " " P U B L I C _ D E P E N D E N C I E S ; P R I V A T E _ D E P E N D E N C I E S " $ { A R G N } )
2018-10-24 13:20:27 +00:00
2020-02-24 14:06:30 +00:00
if ( NOT arg_ONLY_EVALUATE_FEATURES )
if ( "${arg_LIBRARY}" STREQUAL "" AND ( NOT ${ arg_NO_MODULE } ) )
message ( FATAL_ERROR
" q t _ f e a t u r e _ b e g i n _ m o d u l e n e e d s a L I B R A R Y n a m e ! ( o r s p e c i f y N O _ M O D U L E ) " )
endif ( )
if ( "${arg_PUBLIC_FILE}" STREQUAL "" )
message ( FATAL_ERROR "qt_feature_begin_module needs a PUBLIC_FILE name!" )
endif ( )
if ( "${arg_PRIVATE_FILE}" STREQUAL "" )
message ( FATAL_ERROR "qt_feature_begin_module needs a PRIVATE_FILE name!" )
endif ( )
2020-03-02 17:06:46 +00:00
set ( __QtFeature_only_evaluate_features OFF PARENT_SCOPE )
else ( )
set ( __QtFeature_only_evaluate_features ON PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
set ( __QtFeature_library "${arg_LIBRARY}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
set ( __QtFeature_public_features "" PARENT_SCOPE )
2019-03-20 16:36:25 +00:00
set ( __QtFeature_private_features "" PARENT_SCOPE )
set ( __QtFeature_internal_features "" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
2018-12-11 15:02:39 +00:00
set ( __QtFeature_private_file "${arg_PRIVATE_FILE}" PARENT_SCOPE )
set ( __QtFeature_public_file "${arg_PUBLIC_FILE}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
set ( __QtFeature_private_extra "" PARENT_SCOPE )
set ( __QtFeature_public_extra "" PARENT_SCOPE )
2019-03-14 10:27:38 +00:00
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
set ( __QtFeature_config_definitions "" PARENT_SCOPE )
2019-03-14 10:27:38 +00:00
set ( __QtFeature_define_definitions "" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-12-11 15:02:39 +00:00
function ( qt_feature feature )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
set ( original_name "${feature}" )
qt_feature_normalize_name ( "${feature}" feature )
set_property ( GLOBAL PROPERTY QT_FEATURE_ORIGINAL_NAME_ ${ feature } "${original_name}" )
2018-12-11 15:02:39 +00:00
qt_parse_all_arguments ( arg "qt_feature"
2018-10-24 13:20:27 +00:00
" P R I V A T E ; P U B L I C "
" L A B E L ; P U R P O S E ; S E C T I O N ; " " A U T O D E T E C T ; C O N D I T I O N ; E N A B L E ; D I S A B L E ; E M I T _ I F " $ { A R G N } )
2018-12-11 15:02:39 +00:00
set ( _QT_FEATURE_DEFINITION_ ${ feature } ${ ARGN } PARENT_SCOPE )
2018-10-25 12:28:06 +00:00
2018-10-25 11:16:42 +00:00
# Register feature for future use:
2018-12-11 15:02:39 +00:00
if ( arg_PUBLIC )
list ( APPEND __QtFeature_public_features "${feature}" )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
if ( arg_PRIVATE )
list ( APPEND __QtFeature_private_features "${feature}" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-20 16:36:25 +00:00
if ( NOT arg_PUBLIC AND NOT arg_PRIVATE )
list ( APPEND __QtFeature_internal_features "${feature}" )
endif ( )
2018-10-25 11:16:42 +00:00
2018-10-24 13:20:27 +00:00
set ( __QtFeature_public_features ${ __QtFeature_public_features } PARENT_SCOPE )
set ( __QtFeature_private_features ${ __QtFeature_private_features } PARENT_SCOPE )
2019-03-20 16:36:25 +00:00
set ( __QtFeature_internal_features ${ __QtFeature_internal_features } PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
function ( qt_evaluate_to_boolean expressionVar )
if ( ${ ${expressionVar } } )
set ( ${ expressionVar } ON PARENT_SCOPE )
else ( )
set ( ${ expressionVar } OFF PARENT_SCOPE )
endif ( )
endfunction ( )
function ( qt_evaluate_config_expression resultVar )
set ( result "" )
set ( nestingLevel 0 )
set ( skipNext OFF )
set ( expression "${ARGN}" )
list ( LENGTH expression length )
math ( EXPR length "${length}-1" )
foreach ( memberIdx RANGE ${ length } )
if ( ${ skipNext } )
set ( skipNext OFF )
continue ( )
endif ( )
list ( GET expression ${ memberIdx } member )
if ( "${member}" STREQUAL "(" )
if ( ${ nestingLevel } GREATER 0 )
list ( APPEND result ${ member } )
endif ( )
math ( EXPR nestingLevel "${nestingLevel} + 1" )
continue ( )
elseif ( "${member}" STREQUAL ")" )
math ( EXPR nestingLevel "${nestingLevel} - 1" )
if ( nestingLevel LESS 0 )
break ( )
endif ( )
if ( ${ nestingLevel } EQUAL 0 )
qt_evaluate_config_expression ( result ${ result } )
else ( )
list ( APPEND result ${ member } )
endif ( )
continue ( )
elseif ( ${ nestingLevel } GREATER 0 )
list ( APPEND result ${ member } )
continue ( )
elseif ( "${member}" STREQUAL "NOT" )
list ( APPEND result ${ member } )
continue ( )
elseif ( "${member}" STREQUAL "AND" )
qt_evaluate_to_boolean ( result )
if ( NOT ${ result } )
break ( )
endif ( )
set ( result "" )
elseif ( "${member}" STREQUAL "OR" )
qt_evaluate_to_boolean ( result )
if ( ${ result } )
break ( )
endif ( )
set ( result "" )
elseif ( "${member}" STREQUAL "STREQUAL" AND memberIdx LESS ${ length } )
# Unfortunately the semantics for STREQUAL in if() are broken when the
# RHS is an empty string and the parameters to if are coming through a variable.
2018-10-25 11:16:42 +00:00
# So we expect people to write the empty string with single quotes and then we
2018-10-24 13:20:27 +00:00
# do the comparison manually here.
list ( LENGTH result lhsIndex )
math ( EXPR lhsIndex "${lhsIndex}-1" )
list ( GET result ${ lhsIndex } lhs )
list ( REMOVE_AT result ${ lhsIndex } )
set ( lhs "${${lhs}}" )
math ( EXPR rhsIndex "${memberIdx}+1" )
set ( skipNext ON )
list ( GET expression ${ rhsIndex } rhs )
# We can't pass through an empty string with double quotes through various
# stages of substitution, so instead it is represented using single quotes
# and resolve here.
string ( REGEX REPLACE "'(.*)'" "\\1" rhs "${rhs}" )
string ( COMPARE EQUAL "${lhs}" "${rhs}" stringCompareResult )
list ( APPEND result ${ stringCompareResult } )
else ( )
string ( FIND "${member}" "QT_FEATURE_" idx )
if ( idx EQUAL 0 )
# Remove the QT_FEATURE_ prefix
string ( SUBSTRING "${member}" 11 -1 feature )
qt_evaluate_feature ( ${ feature } )
endif ( )
list ( APPEND result ${ member } )
endif ( )
endforeach ( )
2019-06-04 15:34:27 +00:00
# The 'TARGET Gui' case is handled by qt_evaluate_to_boolean, by passing those tokens verbatim
# to if().
2018-10-24 13:20:27 +00:00
if ( "${result}" STREQUAL "" )
set ( result ON )
else ( )
qt_evaluate_to_boolean ( result )
endif ( )
set ( ${ resultVar } ${ result } PARENT_SCOPE )
endfunction ( )
2020-11-25 15:10:08 +00:00
function ( _qt_internal_dump_expression_values expression_dump expression )
set ( dump "" )
set ( skipNext FALSE )
set ( isTargetExpression FALSE )
set ( keywords "EQUAL" "LESS" "LESS_EQUAL" "GREATER" "GREATER_EQUAL" "STREQUAL" "STRLESS"
" S T R L E S S _ E Q U A L " " S T R G R E A T E R " " S T R G R E A T E R _ E Q U A L " " V E R S I O N _ E Q U A L " " V E R S I O N _ L E S S "
" V E R S I O N _ L E S S _ E Q U A L " " V E R S I O N _ G R E A T E R " " V E R S I O N _ G R E A T E R _ E Q U A L " " M A T C H E S "
" E X I S T S " " C O M M A N D " " D E F I N E D " " N O T " " A N D " " O R " " T A R G E T " " E X I S T S " " I N _ L I S T " " ( " " ) " )
list ( LENGTH expression length )
math ( EXPR length "${length}-1" )
if ( ${ length } LESS 0 )
return ( )
endif ( )
foreach ( memberIdx RANGE ${ length } )
if ( ${ skipNext } )
set ( skipNext FALSE )
continue ( )
endif ( )
list ( GET expression ${ memberIdx } member )
if ( NOT "${member}" IN_LIST keywords )
string ( FIND "${member}" "QT_FEATURE_" idx )
if ( idx EQUAL 0 )
if ( NOT DEFINED ${ member } )
list ( APPEND dump "${member} not evaluated" )
else ( )
list ( APPEND dump "${member} = \" ${ ${member } }\ "" )
endif ( )
elseif ( isTargetExpression )
set ( targetExpression "TARGET;${member}" )
if ( ${ targetExpression } )
list ( APPEND dump "TARGET ${member} found" )
else ( )
list ( APPEND dump "TARGET ${member} not found" )
endif ( )
else ( )
list ( APPEND dump "${member} = \" ${ ${member } }\ "" )
endif ( )
set ( isTargetExpression FALSE )
set ( skipNext FALSE )
elseif ( "${member}" STREQUAL "TARGET" )
set ( isTargetExpression TRUE )
elseif ( "${member}" STREQUAL "STREQUAL" )
set ( skipNext TRUE )
else ( )
set ( skipNext FALSE )
set ( isTargetExpression FALSE )
endif ( )
endforeach ( )
string ( JOIN "\n " ${ expression_dump } ${ dump } )
set ( ${ expression_dump } "${${expression_dump}}" PARENT_SCOPE )
endfunction ( )
2021-07-08 15:21:12 +00:00
# Stores the user provided value to FEATURE_${feature} if provided.
# If not provided, stores ${computed} instead.
# ${computed} is also stored when reconfiguring and the condition does not align with the user
# provided value.
#
function ( qt_feature_check_and_save_user_provided_value resultVar feature condition computed label )
2020-11-04 15:00:50 +00:00
if ( DEFINED "FEATURE_${feature}" )
2021-07-08 15:21:12 +00:00
# Revisit new user provided value
set ( user_value "${FEATURE_${feature}}" )
set ( result "${user_value}" )
2020-12-11 15:11:35 +00:00
2021-07-08 15:21:12 +00:00
# If the build is marked as dirty and the user_value doesn't meet the new condition,
# reset it to the computed one.
2020-12-11 15:11:35 +00:00
get_property ( dirty_build GLOBAL PROPERTY _qt_dirty_build )
2021-07-08 15:21:12 +00:00
if ( NOT condition AND result AND dirty_build )
set ( result "${computed}" )
message ( WARNING " Reset FEATURE_ ${ feature } value to ${ result } , because it doesn't \
2020-12-11 15:11:35 +00:00
m e e t i t s c o n d i t i o n a f t e r r e c o n f i g u r a t i o n . " )
endif ( )
2020-11-04 15:00:50 +00:00
set ( bool_values OFF NO FALSE N ON YES TRUE Y )
2021-07-08 15:21:12 +00:00
if ( ( result IN_LIST bool_values ) OR ( result GREATER_EQUAL 0 ) )
# All good!
2018-10-26 09:49:58 +00:00
else ( )
2021-07-08 15:21:12 +00:00
message ( FATAL_ERROR
" S a n i t y c h e c k f a i l e d : F E A T U R E _ $ { f e a t u r e } h a s i n v a l i d v a l u e \ " $ { r e s u l t } \ " ! " )
2018-10-26 09:49:58 +00:00
endif ( )
2020-12-11 15:11:35 +00:00
2018-10-26 09:49:58 +00:00
# Fix-up user-provided values
2021-07-08 15:21:12 +00:00
set ( "FEATURE_${feature}" "${result}" CACHE BOOL "${label}" FORCE )
2018-10-26 09:49:58 +00:00
else ( )
# Initial setup:
2021-07-08 15:21:12 +00:00
set ( result "${computed}" )
set ( "FEATURE_${feature}" "${result}" CACHE BOOL "${label}" )
2018-10-26 09:49:58 +00:00
endif ( )
set ( "${resultVar}" "${result}" PARENT_SCOPE )
endfunction ( )
2021-07-08 15:21:12 +00:00
# Saves the final user value to QT_FEATURE_${feature}, after checking that the condition is met.
macro ( qt_feature_check_and_save_internal_value
f e a t u r e s a v e d _ u s e r _ v a l u e c o n d i t i o n l a b e l c o n d i t i o n E x p r e s s i o n )
2021-09-20 15:30:08 +00:00
if ( ${ saved_user_value } )
set ( result ON )
else ( )
set ( result OFF )
endif ( )
2018-10-26 09:49:58 +00:00
2021-07-08 15:21:12 +00:00
if ( ( NOT condition ) AND result )
2020-11-25 15:10:08 +00:00
_qt_internal_dump_expression_values ( conditionDump "${conditionExpression}" )
string ( JOIN " " conditionString ${ conditionExpression } )
2021-07-08 15:21:12 +00:00
qt_configure_add_report_error ( "Feature \" ${ feature } \": Forcing to \"${result}\" breaks its \
2021-01-14 17:28:57 +00:00
c o n d i t i o n : \ n $ { c o n d i t i o n S t r i n g } \ n C o n d i t i o n v a l u e s d u m p : \ n $ { c o n d i t i o n D u m p } \ n " R E C O R D _ O N _ F E A T U R E _ E V A L U A T I O N )
2018-10-26 09:49:58 +00:00
endif ( )
2019-01-14 10:35:53 +00:00
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}" )
2020-12-11 15:11:35 +00:00
# Add feature to build feature collection
list ( APPEND QT_KNOWN_FEATURES "${feature}" )
set ( QT_KNOWN_FEATURES "${QT_KNOWN_FEATURES}" CACHE INTERNAL "" FORCE )
2018-10-26 09:49:58 +00:00
endmacro ( )
2021-07-08 15:21:12 +00:00
# The build system stores 2 CMake cache variables for each feature, to allow detecting value changes
# during subsequent reconfigurations.
#
#
# `FEATURE_foo` stores the user provided feature value for the current configuration run.
# It can be set directly by the user, or derived from INPUT_foo (also set by the user).
#
# If a value is not provided on initial configuration, the value will be auto-computed based on the
# various conditions of the feature.
# TODO: Document the various conditions and how they relate to each other.
#
#
# `QT_FEATURE_foo` stores the value of the feature from the previous configuration run.
# Its value is updated once with the newest user provided value after some checks are performed.
#
# This variable also serves as the main source of truth throughout the build system code to check
# if the feature is enabled, e.g. if(QT_FEATURE_foo)
#
# It is not meant to be set by the user. It is only modified by the build system.
#
# Comparing the values of QT_FEATURE_foo and FEATURE_foo, the build system can detect whether
# the user changed the value for a feature and thus recompute any dependent features.
#
2018-12-11 15:02:39 +00:00
function ( qt_evaluate_feature feature )
2020-12-11 15:11:35 +00:00
# If the feature was already evaluated as dependency nothing to do here.
2018-12-11 15:02:39 +00:00
if ( DEFINED "QT_FEATURE_${feature}" )
2018-10-24 13:20:27 +00:00
return ( )
endif ( )
2018-12-11 15:02:39 +00:00
if ( NOT DEFINED _QT_FEATURE_DEFINITION_ ${ feature } )
2018-11-02 10:42:58 +00:00
qt_debug_print_variables ( DEDUP MATCH "^QT_FEATURE" )
2018-12-11 15:02:39 +00:00
message ( FATAL_ERROR "Attempting to evaluate feature ${feature} but its definition is missing. Either the feature does not exist or a dependency to the module that defines it is missing" )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
cmake_parse_arguments ( arg
2018-10-24 13:20:27 +00:00
" P R I V A T E ; P U B L I C "
2018-12-11 15:02:39 +00:00
" L A B E L ; P U R P O S E ; S E C T I O N ; " " A U T O D E T E C T ; C O N D I T I O N ; E N A B L E ; D I S A B L E ; E M I T _ I F " $ { _ Q T _ F E A T U R E _ D E F I N I T I O N _ $ { f e a t u r e } } )
2018-10-24 13:20:27 +00:00
2018-12-11 15:02:39 +00:00
if ( "${arg_ENABLE}" STREQUAL "" )
set ( arg_ENABLE OFF )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
if ( "${arg_DISABLE}" STREQUAL "" )
set ( arg_DISABLE OFF )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
if ( "${arg_AUTODETECT}" STREQUAL "" )
set ( arg_AUTODETECT ON )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
if ( "${arg_CONDITION}" STREQUAL "" )
2018-10-25 12:28:06 +00:00
set ( condition ON )
else ( )
2018-12-11 15:02:39 +00:00
qt_evaluate_config_expression ( condition ${ arg_CONDITION } )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-13 12:55:56 +00:00
qt_evaluate_config_expression ( disable_result ${ arg_DISABLE } )
qt_evaluate_config_expression ( enable_result ${ arg_ENABLE } )
2020-08-21 13:10:46 +00:00
qt_evaluate_config_expression ( auto_detect ${ arg_AUTODETECT } )
2019-03-13 12:55:56 +00:00
if ( ${ disable_result } )
2021-07-08 15:21:12 +00:00
set ( computed OFF )
2020-08-21 13:10:46 +00:00
elseif ( ( ${ enable_result } ) OR ( ${ auto_detect } ) )
2021-07-08 15:21:12 +00:00
set ( computed ${ condition } )
2018-10-24 13:20:27 +00:00
else ( )
# feature not auto-detected and not explicitly enabled
2021-07-08 15:21:12 +00:00
set ( computed OFF )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
if ( "${arg_EMIT_IF}" STREQUAL "" )
2018-10-25 12:28:06 +00:00
set ( emit_if ON )
else ( )
2018-12-11 15:02:39 +00:00
qt_evaluate_config_expression ( emit_if ${ arg_EMIT_IF } )
2018-10-25 11:16:42 +00:00
endif ( )
2020-11-18 12:17:47 +00:00
# If FEATURE_ is not defined trying to use INPUT_ variable to enable/disable feature.
if ( ( NOT DEFINED "FEATURE_${feature}" ) AND ( DEFINED "INPUT_${feature}" )
AND ( NOT "${INPUT_${feature}}" STREQUAL "undefined" )
AND ( NOT "${INPUT_${feature}}" STREQUAL "" ) )
if ( INPUT_ ${ feature } )
set ( FEATURE_ ${ feature } ON )
else ( )
set ( FEATURE_ ${ feature } OFF )
endif ( )
endif ( )
2021-07-08 15:40:04 +00:00
# Warn about a feature which is not emitted, but the user explicitly provided a value for it.
2021-03-01 16:13:56 +00:00
if ( NOT emit_if AND DEFINED FEATURE_ ${ feature } )
set ( msg "" )
string ( APPEND msg
" F e a t u r e $ { f e a t u r e } i s i n s i g n i f i c a n t i n t h i s c o n f i g u r a t i o n , "
" i g n o r i n g r e l a t e d c o m m a n d l i n e option ( s ) . " )
qt_configure_add_report_entry ( TYPE WARNING MESSAGE "${msg}" )
2021-07-08 15:40:04 +00:00
# Remove the cache entry so that the warning is not persisted and shown on every
# reconfiguration.
unset ( FEATURE_ ${ feature } CACHE )
2021-03-01 16:13:56 +00:00
endif ( )
2021-07-08 15:40:04 +00:00
# Only save the user provided value if the feature was emitted.
if ( emit_if )
qt_feature_check_and_save_user_provided_value (
s a v e d _ u s e r _ v a l u e " $ { f e a t u r e } " " $ { c o n d i t i o n } " " $ { c o m p u t e d } " " $ { a r g _ L A B E L } " )
else ( )
# Make sure the feature internal value is OFF if not emitted.
set ( saved_user_value OFF )
endif ( )
2021-07-08 15:21:12 +00:00
qt_feature_check_and_save_internal_value (
" $ { f e a t u r e } " " $ { s a v e d _ u s e r _ v a l u e } " " $ { c o n d i t i o n } " " $ { a r g _ L A B E L } " " $ { a r g _ C O N D I T I O N } " )
2020-03-02 17:06:46 +00:00
# Store each feature's label for summary info.
set ( QT_FEATURE_LABEL_ ${ feature } "${arg_LABEL}" CACHE INTERNAL "" )
2018-10-24 13:20:27 +00:00
endfunction ( )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
function ( qt_feature_config feature config_var_name )
qt_feature_normalize_name ( "${feature}" feature )
qt_parse_all_arguments ( arg "qt_feature_config" "NEGATE" "NAME" "" ${ ARGN } )
# Store all the config related info in a unique variable key.
set ( key_name "_QT_FEATURE_CONFIG_DEFINITION_${feature}_${config_var_name}" )
set ( ${ key_name } "FEATURE;${feature};CONFIG_VAR_NAME;${config_var_name};${ARGN}" PARENT_SCOPE )
# Store the key for later evaluation.
list ( APPEND __QtFeature_config_definitions "${key_name}" )
set ( __QtFeature_config_definitions ${ __QtFeature_config_definitions } PARENT_SCOPE )
endfunction ( )
function ( qt_evaluate_qmake_config_values key )
if ( NOT DEFINED ${ key } )
qt_debug_print_variables ( DEDUP MATCH "^_QT_FEATURE_CONFIG_DEFINITION" )
message ( FATAL_ERROR
" A t t e m p t i n g t o e v a l u a t e f e a t u r e c o n f i g $ { k e y } b u t i t s d e f i n i t i o n i s m i s s i n g . " )
endif ( )
cmake_parse_arguments ( arg
" N E G A T E "
" F E A T U R E ; N A M E ; C O N F I G _ V A R _ N A M E "
" " $ { $ { k e y } } )
# If no custom name is specified, then the config value is the same as the feature name.
if ( NOT arg_NAME )
set ( arg_NAME "${arg_FEATURE}" )
endif ( )
2020-04-20 18:31:31 +00:00
set ( expected "NOT" )
if ( arg_NEGATE )
set ( expected "" )
2020-06-26 13:16:30 +00:00
if ( arg_NAME MATCHES "^no_(.*)" )
set ( arg_NAME "${CMAKE_MATCH_1}" )
else ( )
string ( PREPEND arg_NAME "no_" )
endif ( )
2020-04-20 18:31:31 +00:00
endif ( )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
# The feature condition is false, there is no need to export any config values.
if ( ${ expected } ${ QT_FEATURE_${arg_FEATURE } } )
return ( )
endif ( )
if ( arg_CONFIG_VAR_NAME STREQUAL "QMAKE_PUBLIC_CONFIG" )
list ( APPEND __QtFeature_qmake_public_config "${arg_NAME}" )
set ( __QtFeature_qmake_public_config "${__QtFeature_qmake_public_config}" PARENT_SCOPE )
endif ( )
if ( arg_CONFIG_VAR_NAME STREQUAL "QMAKE_PRIVATE_CONFIG" )
list ( APPEND __QtFeature_qmake_private_config "${arg_NAME}" )
set ( __QtFeature_qmake_private_config "${__QtFeature_qmake_private_config}" PARENT_SCOPE )
endif ( )
if ( arg_CONFIG_VAR_NAME STREQUAL "QMAKE_PUBLIC_QT_CONFIG" )
list ( APPEND __QtFeature_qmake_public_qt_config "${arg_NAME}" )
set ( __QtFeature_qmake_public_qt_config "${__QtFeature_qmake_public_qt_config}" PARENT_SCOPE )
endif ( )
endfunction ( )
2018-12-11 15:02:39 +00:00
function ( qt_feature_definition feature name )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
qt_feature_normalize_name ( "${feature}" feature )
2020-03-31 12:12:01 +00:00
qt_parse_all_arguments ( arg "qt_feature_definition" "NEGATE" "VALUE;PREREQUISITE" "" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2019-03-14 10:27:38 +00:00
# Store all the define related info in a unique variable key.
set ( key_name "_QT_FEATURE_DEFINE_DEFINITION_${feature}_${name}" )
set ( ${ key_name } "FEATURE;${feature};NAME;${name};${ARGN}" PARENT_SCOPE )
# Store the key for later evaluation and subsequent define generation:
list ( APPEND __QtFeature_define_definitions "${key_name}" )
set ( __QtFeature_define_definitions ${ __QtFeature_define_definitions } PARENT_SCOPE )
endfunction ( )
function ( qt_evaluate_feature_definition key )
if ( NOT DEFINED ${ key } )
qt_debug_print_variables ( DEDUP MATCH "^_QT_FEATURE_DEFINE_DEFINITION" )
message ( FATAL_ERROR "Attempting to evaluate feature define ${key} but its definition is missing. " )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-14 10:27:38 +00:00
cmake_parse_arguments ( arg
" N E G A T E ; "
2020-03-31 12:12:01 +00:00
" F E A T U R E ; N A M E ; V A L U E ; P R E R E Q U I S I T E " " " $ { $ { k e y } } )
2019-03-14 10:27:38 +00:00
set ( expected ON )
if ( arg_NEGATE )
set ( expected OFF )
2018-10-24 13:20:27 +00:00
endif ( )
2021-08-16 14:38:50 +00:00
set ( actual OFF )
if ( QT_FEATURE_ ${ arg_FEATURE } )
set ( actual ON )
endif ( )
2019-03-14 10:27:38 +00:00
set ( msg "" )
2021-08-16 14:38:50 +00:00
if ( actual STREQUAL expected )
2020-03-31 12:12:01 +00:00
set ( indent "" )
if ( arg_PREREQUISITE )
string ( APPEND msg "#if ${arg_PREREQUISITE}\n" )
set ( indent " " )
endif ( )
2019-03-14 10:27:38 +00:00
if ( arg_VALUE )
2020-03-31 12:12:01 +00:00
string ( APPEND msg "${indent}#define ${arg_NAME} ${arg_VALUE}\n" )
2019-03-14 10:27:38 +00:00
else ( )
2020-03-31 12:12:01 +00:00
string ( APPEND msg "${indent}#define ${arg_NAME}\n" )
endif ( )
if ( arg_PREREQUISITE )
string ( APPEND msg "#endif\n" )
2019-03-14 10:27:38 +00:00
endif ( )
2018-12-11 15:02:39 +00:00
string ( APPEND __QtFeature_public_extra "${msg}" )
2018-10-24 13:20:27 +00:00
endif ( )
set ( __QtFeature_public_extra ${ __QtFeature_public_extra } PARENT_SCOPE )
endfunction ( )
2018-12-11 15:02:39 +00:00
function ( qt_extra_definition name value )
qt_parse_all_arguments ( arg "qt_extra_definition" "PUBLIC;PRIVATE" "" "" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2018-12-11 15:02:39 +00:00
if ( arg_PUBLIC )
string ( APPEND __QtFeature_public_extra "\n#define ${name} ${value}\n" )
elseif ( arg_PRIVATE )
string ( APPEND __QtFeature_private_extra "\n#define ${name} ${value}\n" )
2018-10-24 13:20:27 +00:00
endif ( )
set ( __QtFeature_public_extra ${ __QtFeature_public_extra } PARENT_SCOPE )
set ( __QtFeature_private_extra ${ __QtFeature_private_extra } PARENT_SCOPE )
endfunction ( )
2018-12-11 15:02:39 +00:00
function ( qt_internal_generate_feature_line line feature )
2020-10-27 11:56:24 +00:00
string ( TOUPPER "${QT_FEATURE_${feature}}" value )
if ( value STREQUAL "ON" )
2018-12-11 15:02:39 +00:00
set ( line "#define QT_FEATURE_${feature} 1\n\n" PARENT_SCOPE )
2020-10-27 11:56:24 +00:00
elseif ( value STREQUAL "OFF" )
2018-12-11 15:02:39 +00:00
set ( line "#define QT_FEATURE_${feature} -1\n\n" PARENT_SCOPE )
2020-10-27 11:56:24 +00:00
elseif ( value STREQUAL "UNSET" )
2018-12-11 15:02:39 +00:00
set ( line "#define QT_FEATURE_${feature} 0\n\n" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
else ( )
2020-10-27 11:56:24 +00:00
message ( FATAL_ERROR "${feature} has unexpected value \" ${ QT_FEATURE_${feature } }\ "! "
" V a l i d v a l u e s a r e O N , O F F a n d U N S E T . " )
2018-10-24 13:20:27 +00:00
endif ( )
endfunction ( )
2018-12-11 15:02:39 +00:00
function ( qt_internal_feature_write_file file features extra )
set ( contents "" )
foreach ( it ${ features } )
qt_internal_generate_feature_line ( line "${it}" )
string ( APPEND contents "${line}" )
2018-10-24 13:20:27 +00:00
endforeach ( )
2018-12-11 15:02:39 +00:00
string ( APPEND contents "${extra}" )
2018-10-24 13:20:27 +00:00
2018-12-11 15:02:39 +00:00
file ( GENERATE OUTPUT "${file}" CONTENT "${contents}" )
2018-10-24 13:20:27 +00:00
endfunction ( )
2020-02-24 14:06:30 +00:00
# Helper function which evaluates features from a given list of configure.cmake paths
# and creates the feature cache entries.
# Should not be used directly, unless features need to be available in a directory scope before the
# associated module evaluates the features.
# E.g. qtbase/src.pro needs access to Core features before src/corelib/CMakeLists.txt is parsed.
function ( qt_feature_evaluate_features list_of_paths )
qt_feature_module_begin ( ONLY_EVALUATE_FEATURES )
foreach ( path ${ list_of_paths } )
include ( "${path}" )
endforeach ( )
qt_feature_module_end ( ONLY_EVALUATE_FEATURES )
endfunction ( )
2021-05-27 10:32:06 +00:00
function ( qt_feature_record_summary_entries list_of_paths )
# Clean up any stale state just in case.
qt_feature_unset_state_vars ( )
set ( __QtFeature_only_record_summary_entries TRUE )
foreach ( path ${ list_of_paths } )
include ( "${path}" )
endforeach ( )
qt_feature_unset_state_vars ( )
endfunction ( )
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>
2019-05-08 12:45:41 +00:00
function ( qt_feature_module_end )
2020-02-24 14:06:30 +00:00
set ( flags ONLY_EVALUATE_FEATURES )
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>
2019-05-08 12:45:41 +00:00
set ( options OUT_VAR_PREFIX )
set ( multiopts )
cmake_parse_arguments ( arg "${flags}" "${options}" "${multiopts}" ${ ARGN } )
set ( target ${ arg_UNPARSED_ARGUMENTS } )
# The value of OUT_VAR_PREFIX is used as a prefix for output variables that should be
# set in the parent scope.
if ( NOT arg_OUT_VAR_PREFIX )
set ( arg_OUT_VAR_PREFIX "" )
endif ( )
2019-03-20 16:36:25 +00:00
set ( all_features ${ __QtFeature_public_features } ${ __QtFeature_private_features } ${ __QtFeature_internal_features } )
2018-10-24 13:20:27 +00:00
list ( REMOVE_DUPLICATES all_features )
foreach ( feature ${ all_features } )
qt_evaluate_feature ( ${ feature } )
endforeach ( )
2019-04-08 15:23:57 +00:00
# Evaluate custom cache assignments.
foreach ( cache_var_name ${ __QtFeature_custom_enabled_cache_variables } )
CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple
CMAKE_OSX_ARCHITECTURES values and let the clang front end
deal with lipo-ing the final libraries.
For now, Qt can be configured to build universal macOS libraries by
passing 2 architectures to CMake, either via:
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
or
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
Currently we recommend specifying the intel x86_64 arch as the first
one, to get an intel slice configuration that is comparable to a
non-universal intel build.
Specifying the arm64 slice first could pessimize optimizations and
reduce the feature set for the intel slice due to the limitation
that we run configure tests only once.
The first specified architecture is the one used to do all the
configure tests.
It 'mostly' defines the common feature set of both architecture
slices, with the excepion of some special handling for sse2 and
neon instructions.
In the future we might want to run at least the Qt architecture config
test for all specified architectures, so that we can extract all the
supported sub-arches and instruction sets in a reliable way.
For now, we use the same sse2 hack as for iOS simulator_and_device
builds, otherwise QtGui fails to link due to missing
qt_memfill32_sse2 and other symbols.
The hack is somewhat augmented to ensure that reconfiguration
still succeeds (same issue happened with iOS). Previously the sse2
feature condition was broken due to force setting the feature
to be ON. Now the condition also checks for a special
QT_FORCE_FEATURE_sse2 variable which we set internally.
Note that we shouldn't build for arm64e, because the binaries
get killed when running on AS with the following message:
kernel: exec_mach_imgact: not running binary built against
preview arm64e ABI.
Aslo, by default, we disable the arm64 slice for qt sql plugins,
mostly because the CI provisioned sql libraries that we depend on only
contain x86_64 slices, and trying to build the sql plugins for both
slices will fail with linker errors.
This behavior can be disabled for all targets marked by
qt_internal_force_macos_intel_arch, by setting the
QT_FORCE_MACOS_ALL_ARCHES CMake option to ON.
To disble it per-target one can set
QT_FORCE_MACOS_ALL_ARCHES_${target} to ON.
Task-number: QTBUG-85447
Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-24 15:03:35 +00:00
set ( ${ cache_var_name } ON CACHE BOOL "Force enabled by platform requirements." FORCE )
2019-04-08 15:23:57 +00:00
endforeach ( )
foreach ( cache_var_name ${ __QtFeature_custom_disabled_cache_variables } )
CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple
CMAKE_OSX_ARCHITECTURES values and let the clang front end
deal with lipo-ing the final libraries.
For now, Qt can be configured to build universal macOS libraries by
passing 2 architectures to CMake, either via:
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
or
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
Currently we recommend specifying the intel x86_64 arch as the first
one, to get an intel slice configuration that is comparable to a
non-universal intel build.
Specifying the arm64 slice first could pessimize optimizations and
reduce the feature set for the intel slice due to the limitation
that we run configure tests only once.
The first specified architecture is the one used to do all the
configure tests.
It 'mostly' defines the common feature set of both architecture
slices, with the excepion of some special handling for sse2 and
neon instructions.
In the future we might want to run at least the Qt architecture config
test for all specified architectures, so that we can extract all the
supported sub-arches and instruction sets in a reliable way.
For now, we use the same sse2 hack as for iOS simulator_and_device
builds, otherwise QtGui fails to link due to missing
qt_memfill32_sse2 and other symbols.
The hack is somewhat augmented to ensure that reconfiguration
still succeeds (same issue happened with iOS). Previously the sse2
feature condition was broken due to force setting the feature
to be ON. Now the condition also checks for a special
QT_FORCE_FEATURE_sse2 variable which we set internally.
Note that we shouldn't build for arm64e, because the binaries
get killed when running on AS with the following message:
kernel: exec_mach_imgact: not running binary built against
preview arm64e ABI.
Aslo, by default, we disable the arm64 slice for qt sql plugins,
mostly because the CI provisioned sql libraries that we depend on only
contain x86_64 slices, and trying to build the sql plugins for both
slices will fail with linker errors.
This behavior can be disabled for all targets marked by
qt_internal_force_macos_intel_arch, by setting the
QT_FORCE_MACOS_ALL_ARCHES CMake option to ON.
To disble it per-target one can set
QT_FORCE_MACOS_ALL_ARCHES_${target} to ON.
Task-number: QTBUG-85447
Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-24 15:03:35 +00:00
set ( ${ cache_var_name } OFF CACHE BOOL "Force disabled by platform requirements." FORCE )
2019-04-08 15:23:57 +00:00
endforeach ( )
2018-10-24 13:20:27 +00:00
set ( enabled_public_features "" )
set ( disabled_public_features "" )
set ( enabled_private_features "" )
set ( disabled_private_features "" )
foreach ( feature ${ __QtFeature_public_features } )
if ( QT_FEATURE_ ${ feature } )
list ( APPEND enabled_public_features ${ feature } )
else ( )
list ( APPEND disabled_public_features ${ feature } )
endif ( )
endforeach ( )
foreach ( feature ${ __QtFeature_private_features } )
if ( QT_FEATURE_ ${ feature } )
list ( APPEND enabled_private_features ${ feature } )
else ( )
list ( APPEND disabled_private_features ${ feature } )
endif ( )
endforeach ( )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
foreach ( key ${ __QtFeature_config_definitions } )
qt_evaluate_qmake_config_values ( ${ key } )
unset ( ${ key } PARENT_SCOPE )
endforeach ( )
2019-03-14 10:27:38 +00:00
foreach ( key ${ __QtFeature_define_definitions } )
qt_evaluate_feature_definition ( ${ key } )
unset ( ${ key } PARENT_SCOPE )
endforeach ( )
2018-10-24 13:20:27 +00:00
foreach ( feature ${ all_features } )
2018-11-02 10:42:58 +00:00
unset ( _QT_FEATURE_DEFINITION_ ${ feature } PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endforeach ( )
2020-02-24 14:06:30 +00:00
if ( NOT arg_ONLY_EVALUATE_FEATURES )
qt_internal_feature_write_file ( "${CMAKE_CURRENT_BINARY_DIR}/${__QtFeature_private_file}"
" $ { _ _ Q t F e a t u r e _ p r i v a t e _ f e a t u r e s } " " $ { _ _ Q t F e a t u r e _ p r i v a t e _ e x t r a } "
)
2018-10-24 13:20:27 +00:00
2020-02-24 14:06:30 +00:00
qt_internal_feature_write_file ( "${CMAKE_CURRENT_BINARY_DIR}/${__QtFeature_public_file}"
" $ { _ _ Q t F e a t u r e _ p u b l i c _ f e a t u r e s } " " $ { _ _ Q t F e a t u r e _ p u b l i c _ e x t r a } "
)
endif ( )
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>
2019-05-08 12:45:41 +00:00
# Extra header injections which have to have forwarding headers created by
# qt_install_injections.
2019-05-16 07:46:29 +00:00
# Skip creating forwarding headers if qt_feature_module_begin was called with NO_MODULE, aka
# there is no include/<module_name> so there's no place to put the forwarding headers.
if ( __QtFeature_library )
set ( injections "" )
qt_compute_injection_forwarding_header ( "${__QtFeature_library}"
S O U R C E " $ { _ _ Q t F e a t u r e _ p u b l i c _ f i l e } "
O U T _ V A R i n j e c t i o n s )
qt_compute_injection_forwarding_header ( "${__QtFeature_library}"
S O U R C E " $ { _ _ Q t F e a t u r e _ p r i v a t e _ f i l e } " P R I V A T E
O U T _ V A R i n j e c t i o n s )
set ( ${ arg_OUT_VAR_PREFIX } extra_library_injections ${ injections } PARENT_SCOPE )
endif ( )
2018-10-24 13:20:27 +00:00
2020-02-24 14:06:30 +00:00
if ( NOT ( "${target}" STREQUAL "NO_MODULE" ) AND NOT arg_ONLY_EVALUATE_FEATURES )
2019-02-12 11:00:49 +00:00
get_target_property ( targetType "${target}" TYPE )
if ( "${targetType}" STREQUAL "INTERFACE_LIBRARY" )
set ( propertyPrefix "INTERFACE_" )
else ( )
set ( propertyPrefix "" )
2021-08-26 08:25:18 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_ENABLED_PUBLIC_FEATURES;QT_DISABLED_PUBLIC_FEATURES;QT_ENABLED_PRIVATE_FEATURES;QT_DISABLED_PRIVATE_FEATURES;QT_QMAKE_PUBLIC_CONFIG;QT_QMAKE_PRIVATE_CONFIG;QT_QMAKE_PUBLIC_QT_CONFIG" )
2019-02-12 11:00:49 +00:00
endif ( )
foreach ( visibility public private )
string ( TOUPPER "${visibility}" capitalVisibility )
foreach ( state enabled disabled )
string ( TOUPPER "${state}" capitalState )
2018-10-24 13:20:27 +00:00
2019-02-12 11:00:49 +00:00
set_property ( TARGET "${target}" PROPERTY ${ propertyPrefix } QT_ ${ capitalState } _ ${ capitalVisibility } _FEATURES "${${state}_${visibility}_features}" )
endforeach ( )
2018-10-24 13:20:27 +00:00
endforeach ( )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
set_property ( TARGET "${target}"
P R O P E R T Y $ { p r o p e r t y P r e f i x } Q T _ Q M A K E _ P U B L I C _ C O N F I G
" $ { _ _ Q t F e a t u r e _ q m a k e _ p u b l i c _ c o n f i g } " )
set_property ( TARGET "${target}"
P R O P E R T Y $ { p r o p e r t y P r e f i x } Q T _ Q M A K E _ P R I V A T E _ C O N F I G
" $ { _ _ Q t F e a t u r e _ q m a k e _ p r i v a t e _ c o n f i g } " )
set_property ( TARGET "${target}"
P R O P E R T Y $ { p r o p e r t y P r e f i x } Q T _ Q M A K E _ P U B L I C _ Q T _ C O N F I G
" $ { _ _ Q t F e a t u r e _ q m a k e _ p u b l i c _ q t _ c o n f i g } " )
# Config values were the old-school features before actual configure.json features were
# implemented. Therefore "CONFIG+=foo" values should be considered features as well,
# so that CMake can find them when building qtmultimedia for example.
if ( __QtFeature_qmake_public_config )
set_property ( TARGET "${target}"
A P P E N D P R O P E R T Y $ { p r o p e r t y P r e f i x } Q T _ E N A B L E D _ P U B L I C _ F E A T U R E S
$ { _ _ Q t F e a t u r e _ q m a k e _ p u b l i c _ c o n f i g } )
endif ( )
if ( __QtFeature_qmake_private_config )
set_property ( TARGET "${target}"
A P P E N D P R O P E R T Y $ { p r o p e r t y P r e f i x } Q T _ E N A B L E D _ P R I V A T E _ F E A T U R E S
$ { _ _ Q t F e a t u r e _ q m a k e _ p r i v a t e _ c o n f i g } )
endif ( )
if ( __QtFeature_qmake_public_qt_config )
set_property ( TARGET "${target}"
A P P E N D P R O P E R T Y $ { p r o p e r t y P r e f i x } Q T _ E N A B L E D _ P U B L I C _ F E A T U R E S
$ { _ _ Q t F e a t u r e _ q m a k e _ p u b l i c _ q t _ c o n f i g } )
endif ( )
2019-05-16 11:22:44 +00:00
qt_feature_copy_global_config_features_to_core ( ${ target } )
2019-02-12 11:00:49 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
2021-05-27 10:32:06 +00:00
qt_feature_unset_state_vars ( )
endfunction ( )
macro ( qt_feature_unset_state_vars )
2018-10-24 13:20:27 +00:00
unset ( __QtFeature_library PARENT_SCOPE )
unset ( __QtFeature_public_features PARENT_SCOPE )
2019-03-20 16:36:25 +00:00
unset ( __QtFeature_private_features PARENT_SCOPE )
unset ( __QtFeature_internal_features PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
unset ( __QtFeature_private_file PARENT_SCOPE )
unset ( __QtFeature_public_file PARENT_SCOPE )
unset ( __QtFeature_private_extra PARENT_SCOPE )
unset ( __QtFeature_public_extra PARENT_SCOPE )
2019-03-14 10:27:38 +00:00
unset ( __QtFeature_define_definitions PARENT_SCOPE )
2019-04-08 15:23:57 +00:00
unset ( __QtFeature_custom_enabled_features PARENT_SCOPE )
unset ( __QtFeature_custom_disabled_features PARENT_SCOPE )
2020-03-02 17:06:46 +00:00
unset ( __QtFeature_only_evaluate_features PARENT_SCOPE )
2021-05-27 10:32:06 +00:00
unset ( __QtFeature_only_record_summary_entries PARENT_SCOPE )
endmacro ( )
2018-10-24 13:20:27 +00:00
2019-05-16 11:22:44 +00:00
function ( qt_feature_copy_global_config_features_to_core target )
# CMake doesn't support setting custom properties on exported INTERFACE libraries
# See https://gitlab.kitware.com/cmake/cmake/issues/19261.
# To circumvent that, copy the properties from GlobalConfig to Core target.
# This way the global features actually get set in the generated CoreTargets.cmake file.
if ( target STREQUAL Core )
foreach ( visibility public private )
string ( TOUPPER "${visibility}" capitalVisibility )
foreach ( state enabled disabled )
string ( TOUPPER "${state}" capitalState )
set ( core_property_name "QT_${capitalState}_${capitalVisibility}_FEATURES" )
set ( global_property_name "INTERFACE_${core_property_name}" )
get_property ( core_values TARGET Core PROPERTY ${ core_property_name } )
get_property ( global_values TARGET GlobalConfig PROPERTY ${ global_property_name } )
set ( total_values ${ core_values } ${ global_values } )
set_property ( TARGET Core PROPERTY ${ core_property_name } ${ total_values } )
endforeach ( )
endforeach ( )
Export non-private and non-public features and CONFIG values
Before we only exported features that had outputType PUBLIC or PRIVATE
on the various "QT_ENABLED_PUBLIC_FEATURES" target properties.
Now we also export features that have output type privateConfig,
publicConfig and publicQtConfig.
The new properties names are:
- QT_QMAKE_PUBLIC_CONFIG for outputType == publicConfig
- QT_QMAKE_PRIVATE_CONFIG for outputType == privateConfig
- QT_QMAKE_PUBLIC_QT_CONFIG for outputType == publicQtConfig
These need to be exported for 2 reasons:
- other modules that need to check the config values
- in preparation for generating proper qmake .prl and .pri
information for each module
Note that the config values are now considered actual features
when doing condition evaluation. So if there exists a feature "ssse3"
with outputType privateConfig, its enabled state can be checked via
QT_FEATURE_ssse3 in consuming modules (but not in the declaring
module).
These config values are also placed in the respective
QT_ENABLED_PUBLIC_FEATURES, QT_ENABLED_PRIVATE_FEATURES properties
when exporting a target, so the properties will now contain both
features and config values.
In order to make this work, feature name normalization has to happen
at CMake time, rather than done by the python script.
This means that features like "developer-build" need to retain the
dash in the qt_feature(), qt_feature_definition() and
qt_feature_config() calls, rather than generating "developer_build"
as the script did before.
The normalization is done at CMake time. Feature conditions,
CMake code, and -DFEATURE_foo=bar options passed on the command line
should still use the underscore version, but the original name is used
for the QT_QMAKE_PUBLIC_CONFIG properties.
Note that "c++11" like features are normalized to "cxx11".
Implementation wise, the configurejson2cmake script is adjusted to
parse these new output types.
Also QtBuild and QtFeature are adjusted to save the config values
in properties, and re-export them from GlobalConfig to Core.
Task-number: QTBUG-75666
Task-number: QTBUG-78178
Change-Id: Ibd4b152e372bdf2d09ed117644f2f2ac53ec5e75
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-08-28 13:15:50 +00:00
set ( config_property_names
Q T _ Q M A K E _ P U B L I C _ C O N F I G Q T _ Q M A K E _ P R I V A T E _ C O N F I G Q T _ Q M A K E _ P U B L I C _ Q T _ C O N F I G )
foreach ( property_name ${ config_property_names } )
set ( core_property_name "${property_name}" )
set ( global_property_name "INTERFACE_${core_property_name}" )
get_property ( core_values TARGET Core PROPERTY ${ core_property_name } )
get_property ( global_values TARGET GlobalConfig PROPERTY ${ global_property_name } )
set ( total_values ${ core_values } ${ global_values } )
set_property ( TARGET Core PROPERTY ${ core_property_name } ${ total_values } )
endforeach ( )
2019-05-16 11:22:44 +00:00
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( qt_config_compile_test name )
2019-12-02 12:21:23 +00:00
if ( DEFINED "TEST_${name}" )
return ( )
endif ( )
2020-02-26 09:39:47 +00:00
cmake_parse_arguments ( arg "" "LABEL;PROJECT_PATH;C_STANDARD;CXX_STANDARD"
2021-06-03 11:51:48 +00:00
" C O M P I L E _ O P T I O N S ; L I B R A R I E S ; C O D E ; P A C K A G E S ; C M A K E _ F L A G S " $ { A R G N } )
2019-09-21 14:22:36 +00:00
if ( arg_PROJECT_PATH )
2019-09-24 08:49:13 +00:00
message ( STATUS "Performing Test ${arg_LABEL}" )
2020-04-02 08:33:04 +00:00
set ( flags "" )
qt_get_platform_try_compile_vars ( platform_try_compile_vars )
list ( APPEND flags ${ platform_try_compile_vars } )
# If the repo has its own cmake modules, include those in the module path, so that various
# find_package calls work.
if ( EXISTS "${PROJECT_SOURCE_DIR}/cmake" )
2021-10-12 15:15:12 +00:00
set ( must_append_module_path_flag TRUE )
2021-09-30 13:05:52 +00:00
set ( flags_copy "${flags}" )
set ( flags )
foreach ( flag IN LISTS flags_copy )
if ( flag MATCHES "^-DCMAKE_MODULE_PATH:STRING=" )
2021-10-12 15:15:12 +00:00
set ( must_append_module_path_flag FALSE )
set ( flag "${flag}\\;${PROJECT_SOURCE_DIR}/cmake" )
2021-09-30 13:05:52 +00:00
endif ( )
list ( APPEND flags "${flag}" )
endforeach ( )
2021-10-12 15:15:12 +00:00
if ( must_append_module_path_flag )
list ( APPEND flags "-DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/cmake" )
endif ( )
2020-04-02 08:33:04 +00:00
endif ( )
# Pass which packages need to be found.
if ( arg_PACKAGES )
set ( packages_list "" )
# Parse the package names, version, etc. An example would be:
# PACKAGE Foo 6 REQUIRED
# PACKAGE Bar 2 COMPONENTS Baz
foreach ( p ${ arg_PACKAGES } )
if ( p STREQUAL PACKAGE )
if ( package_entry )
2020-04-07 10:15:10 +00:00
# Encode the ";" into "\;" to separate the arguments of a find_package call.
string ( REPLACE ";" "\\;" package_entry_string "${package_entry}" )
2020-04-02 08:33:04 +00:00
list ( APPEND packages_list "${package_entry_string}" )
endif ( )
set ( package_entry "" )
else ( )
list ( APPEND package_entry "${p}" )
endif ( )
endforeach ( )
# Parse final entry.
if ( package_entry )
2020-04-07 10:15:10 +00:00
string ( REPLACE ";" "\\;" package_entry_string "${package_entry}" )
2020-04-02 08:33:04 +00:00
list ( APPEND packages_list "${package_entry_string}" )
endif ( )
2020-04-07 10:15:10 +00:00
# Encode the ";" again.
string ( REPLACE ";" "\\;" packages_list "${packages_list}" )
2020-04-02 08:33:04 +00:00
2020-04-07 10:15:10 +00:00
# The flags are separated by ';', the find_package entries by '\;',
# and the package parts of an entry by '\\;'.
2020-04-02 08:33:04 +00:00
# Example:
# WrapFoo\\;6\\;COMPONENTS\\;bar\;WrapBaz\\;5
list ( APPEND flags "-DQT_CONFIG_COMPILE_TEST_PACKAGES:STRING=${packages_list}" )
# Inside the project, the value of QT_CONFIG_COMPILE_TEST_PACKAGES is used in a foreach
# loop that calls find_package() for each package entry, and thus the variable expansion
# ends up calling something like find_package(WrapFoo;6;COMPONENTS;bar) aka
# find_package(WrapFoo 6 COMPONENTS bar).
endif ( )
# Pass which libraries need to be linked against.
if ( arg_LIBRARIES )
2020-04-09 07:59:35 +00:00
set ( link_flags "" )
set ( library_targets "" )
# Separate targets from link flags or paths. This is to prevent configuration failures
# when the targets are not found due to missing packages.
foreach ( lib ${ arg_LIBRARIES } )
string ( FIND "${lib}" "::" is_library_target )
if ( is_library_target EQUAL -1 )
list ( APPEND link_flags "${lib}" )
else ( )
list ( APPEND library_targets "${lib}" )
endif ( )
endforeach ( )
if ( link_flags )
list ( APPEND flags "-DQT_CONFIG_COMPILE_TEST_LIBRARIES:STRING=${link_flags}" )
endif ( )
if ( library_targets )
list ( APPEND flags
" - D Q T _ C O N F I G _ C O M P I L E _ T E S T _ L I B R A R Y _ T A R G E T S : S T R I N G = $ { l i b r a r y _ t a r g e t s } " )
endif ( )
2020-04-02 08:33:04 +00:00
endif ( )
2021-10-05 09:09:07 +00:00
# Pass override values for CMAKE_SYSTEM_{PREFIX|FRAMEWORK}_PATH.
if ( DEFINED QT_CMAKE_SYSTEM_PREFIX_PATH_BACKUP )
set ( path_list ${ CMAKE_SYSTEM_PREFIX_PATH } )
string ( REPLACE ";" "\\;" path_list "${path_list}" )
list ( APPEND flags "-DQT_CONFIG_COMPILE_TEST_CMAKE_SYSTEM_PREFIX_PATH=${path_list}" )
endif ( )
if ( DEFINED QT_CMAKE_SYSTEM_FRAMEWORK_PATH_BACKUP )
set ( path_list ${ CMAKE_SYSTEM_FRAMEWORK_PATH } )
string ( REPLACE ";" "\\;" path_list "${path_list}" )
list ( APPEND flags "-DQT_CONFIG_COMPILE_TEST_CMAKE_SYSTEM_FRAMEWORK_PATH=${path_list}" )
endif ( )
2021-06-03 11:51:48 +00:00
if ( NOT arg_CMAKE_FLAGS )
set ( arg_CMAKE_FLAGS "" )
endif ( )
2021-08-12 13:55:47 +00:00
# CI passes the project dir of the Qt repository as absolute path without drive letter:
# \Users\qt\work\qt\qtbase
# Ensure that arg_PROJECT_PATH is an absolute path with drive letter:
# C:/Users/qt/work/qt/qtbase
# This works around CMake upstream issue #22534.
if ( CMAKE_HOST_WIN32 )
get_filename_component ( arg_PROJECT_PATH "${arg_PROJECT_PATH}" REALPATH )
endif ( )
2019-09-21 14:22:36 +00:00
try_compile ( HAVE_ ${ name } "${CMAKE_BINARY_DIR}/config.tests/${name}" "${arg_PROJECT_PATH}"
2021-06-03 11:51:48 +00:00
" $ { n a m e } " C M A K E _ F L A G S $ { f l a g s } $ { a r g _ C M A K E _ F L A G S } )
2019-09-24 08:49:13 +00:00
if ( ${ HAVE_${name } } )
set ( status_label "Success" )
else ( )
set ( status_label "Failed" )
endif ( )
message ( STATUS "Performing Test ${arg_LABEL} - ${status_label}" )
2019-09-21 14:22:36 +00:00
else ( )
foreach ( library IN ITEMS ${ arg_LIBRARIES } )
if ( NOT TARGET "${library}" )
# If the dependency looks like a cmake target, then make this compile test
# fail instead of cmake abort later via CMAKE_REQUIRED_LIBRARIES.
string ( FIND "${library}" "::" cmake_target_namespace_separator )
if ( NOT cmake_target_namespace_separator EQUAL -1 )
set ( HAVE_ ${ name } FALSE )
break ( )
endif ( )
2019-02-11 12:13:43 +00:00
endif ( )
2019-09-21 14:22:36 +00:00
endforeach ( )
2019-02-11 12:13:43 +00:00
2019-09-21 14:22:36 +00:00
if ( NOT DEFINED HAVE_ ${ name } )
2019-10-17 08:49:44 +00:00
set ( _save_CMAKE_C_STANDARD "${CMAKE_C_STANDARD}" )
set ( _save_CMAKE_CXX_STANDARD "${CMAKE_CXX_STANDARD}" )
2020-02-17 08:54:59 +00:00
set ( _save_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}" )
2021-09-30 13:05:52 +00:00
set ( _save_CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}" )
2019-10-17 08:49:44 +00:00
if ( arg_C_STANDARD )
set ( CMAKE_C_STANDARD "${arg_C_STANDARD}" )
endif ( )
if ( arg_CXX_STANDARD )
set ( CMAKE_CXX_STANDARD "${arg_CXX_STANDARD}" )
endif ( )
2020-02-26 09:39:47 +00:00
set ( CMAKE_REQUIRED_FLAGS ${ arg_COMPILE_OPTIONS } )
2020-02-17 08:54:59 +00:00
# For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus
# define values. According to common/msvc-version.conf the flag is supported starting
# with 1913.
# https://developercommunity.visualstudio.com/content/problem/139261/msvc-incorrectly-defines-cplusplus.html
# No support for the flag in upstream CMake as of 3.17.
# https://gitlab.kitware.com/cmake/cmake/issues/18837
if ( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913 )
2020-02-26 09:39:47 +00:00
list ( APPEND CMAKE_REQUIRED_FLAGS "-Zc:__cplusplus" )
2020-02-17 08:54:59 +00:00
endif ( )
2021-09-30 13:05:52 +00:00
# Let CMake load our custom platform modules.
if ( NOT QT_AVOID_CUSTOM_PLATFORM_MODULES )
list ( APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_MODULE_PATH )
endif ( )
2019-09-21 14:22:36 +00:00
set ( _save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" )
set ( CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}" )
check_cxx_source_compiles ( "${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_ ${ name } )
set ( CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}" )
2019-10-17 08:49:44 +00:00
set ( CMAKE_C_STANDARD "${_save_CMAKE_C_STANDARD}" )
set ( CMAKE_CXX_STANDARD "${_save_CMAKE_CXX_STANDARD}" )
2020-02-17 08:54:59 +00:00
set ( CMAKE_REQUIRED_FLAGS "${_save_CMAKE_REQUIRED_FLAGS}" )
2021-09-30 13:05:52 +00:00
set ( CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "${_save_CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}" )
2019-09-21 14:22:36 +00:00
endif ( )
2019-02-11 12:13:43 +00:00
endif ( )
2019-09-21 14:22:36 +00:00
2018-12-11 15:02:39 +00:00
set ( TEST_ ${ name } "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}" )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-04-08 15:23:57 +00:00
# This function should be used for passing required try compile platform variables to the
# project-based try_compile() call.
# out_var will be a list of -Dfoo=bar strings, suitable to pass to CMAKE_FLAGS.
function ( qt_get_platform_try_compile_vars out_var )
# Use the regular variables that are used for source-based try_compile() calls.
set ( flags "${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}" )
2021-09-17 12:11:47 +00:00
# Pass custom flags.
list ( APPEND flags "CMAKE_C_FLAGS" )
list ( APPEND flags "CMAKE_C_FLAGS_DEBUG" )
list ( APPEND flags "CMAKE_C_FLAGS_RELEASE" )
list ( APPEND flags "CMAKE_C_FLAGS_RELWITHDEBINFO" )
list ( APPEND flags "CMAKE_CXX_FLAGS" )
list ( APPEND flags "CMAKE_CXX_FLAGS_DEBUG" )
list ( APPEND flags "CMAKE_CXX_FLAGS_RELEASE" )
list ( APPEND flags "CMAKE_CXX_FLAGS_RELWITHDEBINFO" )
2021-09-28 08:51:25 +00:00
list ( APPEND flags "CMAKE_OBJCOPY" )
2021-09-17 12:11:47 +00:00
2019-04-08 15:23:57 +00:00
# Pass toolchain files.
if ( CMAKE_TOOLCHAIN_FILE )
list ( APPEND flags "CMAKE_TOOLCHAIN_FILE" )
endif ( )
if ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE )
list ( APPEND flags "VCPKG_CHAINLOAD_TOOLCHAIN_FILE" )
endif ( )
2020-04-02 08:33:04 +00:00
# Pass language standard flags.
list ( APPEND flags "CMAKE_C_STANDARD" )
list ( APPEND flags "CMAKE_CXX_STANDARD" )
2019-04-08 15:23:57 +00:00
# Assemble the list with regular options.
set ( flags_cmd_line "" )
foreach ( flag ${ flags } )
if ( ${ flag } )
list ( APPEND flags_cmd_line "-D${flag}=${${flag}}" )
endif ( )
endforeach ( )
2021-09-30 13:05:52 +00:00
# Let CMake load our custom platform modules.
if ( NOT QT_AVOID_CUSTOM_PLATFORM_MODULES )
list ( APPEND flags_cmd_line "-DCMAKE_MODULE_PATH:STRING=${QT_CMAKE_DIR}/platforms" )
endif ( )
2019-04-08 15:23:57 +00:00
# Pass darwin specific options.
2020-07-20 15:16:04 +00:00
# The architectures need to be passed explicitly to project-based try_compile calls even on
# macOS, so that arm64 compilation works on Apple silicon.
CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple
CMAKE_OSX_ARCHITECTURES values and let the clang front end
deal with lipo-ing the final libraries.
For now, Qt can be configured to build universal macOS libraries by
passing 2 architectures to CMake, either via:
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
or
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
Currently we recommend specifying the intel x86_64 arch as the first
one, to get an intel slice configuration that is comparable to a
non-universal intel build.
Specifying the arm64 slice first could pessimize optimizations and
reduce the feature set for the intel slice due to the limitation
that we run configure tests only once.
The first specified architecture is the one used to do all the
configure tests.
It 'mostly' defines the common feature set of both architecture
slices, with the excepion of some special handling for sse2 and
neon instructions.
In the future we might want to run at least the Qt architecture config
test for all specified architectures, so that we can extract all the
supported sub-arches and instruction sets in a reliable way.
For now, we use the same sse2 hack as for iOS simulator_and_device
builds, otherwise QtGui fails to link due to missing
qt_memfill32_sse2 and other symbols.
The hack is somewhat augmented to ensure that reconfiguration
still succeeds (same issue happened with iOS). Previously the sse2
feature condition was broken due to force setting the feature
to be ON. Now the condition also checks for a special
QT_FORCE_FEATURE_sse2 variable which we set internally.
Note that we shouldn't build for arm64e, because the binaries
get killed when running on AS with the following message:
kernel: exec_mach_imgact: not running binary built against
preview arm64e ABI.
Aslo, by default, we disable the arm64 slice for qt sql plugins,
mostly because the CI provisioned sql libraries that we depend on only
contain x86_64 slices, and trying to build the sql plugins for both
slices will fail with linker errors.
This behavior can be disabled for all targets marked by
qt_internal_force_macos_intel_arch, by setting the
QT_FORCE_MACOS_ALL_ARCHES CMake option to ON.
To disble it per-target one can set
QT_FORCE_MACOS_ALL_ARCHES_${target} to ON.
Task-number: QTBUG-85447
Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-24 15:03:35 +00:00
qt_internal_get_first_osx_arch ( osx_first_arch )
if ( osx_first_arch )
2020-07-20 15:16:04 +00:00
# Do what qmake does, aka when doing a simulator_and_device build, build the
# target architecture test only with the first given architecture, which should be the
# device architecture, aka some variation of "arm" (armv7, arm64).
list ( APPEND flags_cmd_line "-DCMAKE_OSX_ARCHITECTURES:STRING=${osx_first_arch}" )
endif ( )
if ( UIKIT )
# Specify the sysroot, but only if not doing a simulator_and_device build.
2019-04-08 15:23:57 +00:00
# So keep the sysroot empty for simulator_and_device builds.
if ( QT_UIKIT_SDK )
list ( APPEND flags_cmd_line "-DCMAKE_OSX_SYSROOT:STRING=${QT_UIKIT_SDK}" )
endif ( )
endif ( )
2021-10-05 09:09:07 +00:00
if ( QT_NO_USE_FIND_PACKAGE_SYSTEM_ENVIRONMENT_PATH )
list ( APPEND flags_cmd_line "-DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH:BOOL=OFF" )
endif ( )
2019-04-08 15:23:57 +00:00
set ( "${out_var}" "${flags_cmd_line}" PARENT_SCOPE )
endfunction ( )
CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple
CMAKE_OSX_ARCHITECTURES values and let the clang front end
deal with lipo-ing the final libraries.
For now, Qt can be configured to build universal macOS libraries by
passing 2 architectures to CMake, either via:
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
or
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
Currently we recommend specifying the intel x86_64 arch as the first
one, to get an intel slice configuration that is comparable to a
non-universal intel build.
Specifying the arm64 slice first could pessimize optimizations and
reduce the feature set for the intel slice due to the limitation
that we run configure tests only once.
The first specified architecture is the one used to do all the
configure tests.
It 'mostly' defines the common feature set of both architecture
slices, with the excepion of some special handling for sse2 and
neon instructions.
In the future we might want to run at least the Qt architecture config
test for all specified architectures, so that we can extract all the
supported sub-arches and instruction sets in a reliable way.
For now, we use the same sse2 hack as for iOS simulator_and_device
builds, otherwise QtGui fails to link due to missing
qt_memfill32_sse2 and other symbols.
The hack is somewhat augmented to ensure that reconfiguration
still succeeds (same issue happened with iOS). Previously the sse2
feature condition was broken due to force setting the feature
to be ON. Now the condition also checks for a special
QT_FORCE_FEATURE_sse2 variable which we set internally.
Note that we shouldn't build for arm64e, because the binaries
get killed when running on AS with the following message:
kernel: exec_mach_imgact: not running binary built against
preview arm64e ABI.
Aslo, by default, we disable the arm64 slice for qt sql plugins,
mostly because the CI provisioned sql libraries that we depend on only
contain x86_64 slices, and trying to build the sql plugins for both
slices will fail with linker errors.
This behavior can be disabled for all targets marked by
qt_internal_force_macos_intel_arch, by setting the
QT_FORCE_MACOS_ALL_ARCHES CMake option to ON.
To disble it per-target one can set
QT_FORCE_MACOS_ALL_ARCHES_${target} to ON.
Task-number: QTBUG-85447
Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-24 15:03:35 +00:00
# Set out_var to the first value of CMAKE_OSX_ARCHITECTURES.
# Sets an empty string if no architecture is present.
function ( qt_internal_get_first_osx_arch out_var )
set ( value "" )
if ( CMAKE_OSX_ARCHITECTURES )
list ( GET CMAKE_OSX_ARCHITECTURES 0 value )
endif ( )
set ( ${ out_var } "${value}" PARENT_SCOPE )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( qt_config_compile_test_x86simd extension label )
2019-02-10 23:20:34 +00:00
if ( DEFINED TEST_X86SIMD_ ${ extension } )
return ( )
endif ( )
2019-04-08 15:23:57 +00:00
set ( flags "-DSIMD:string=${extension}" )
qt_get_platform_try_compile_vars ( platform_try_compile_vars )
list ( APPEND flags ${ platform_try_compile_vars } )
2019-09-24 08:49:13 +00:00
message ( STATUS "Performing SIMD Test ${label}" )
2019-03-12 20:55:58 +00:00
try_compile ( "TEST_X86SIMD_${extension}"
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c o n f i g . t e s t s / x 8 6 _ s i m d _ $ { e x t e n s i o n } "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c o n f i g . t e s t s / x 8 6 _ s i m d "
x 8 6 _ s i m d
2019-04-08 15:23:57 +00:00
C M A K E _ F L A G S $ { f l a g s } )
2019-09-19 17:12:57 +00:00
if ( ${ TEST_X86SIMD_${extension } } )
set ( status_label "Success" )
else ( )
set ( status_label "Failed" )
endif ( )
message ( STATUS "Performing SIMD Test ${label} - ${status_label}" )
2019-03-12 20:55:58 +00:00
set ( TEST_subarch_ ${ extension } "${TEST_X86SIMD_${extension}}" CACHE INTERNAL "${label}" )
2018-10-24 13:20:27 +00:00
endfunction ( )
2020-06-26 18:45:11 +00:00
function ( qt_config_compile_test_machine_tuple label )
2020-07-03 09:18:52 +00:00
if ( DEFINED TEST_MACHINE_TUPLE OR NOT LINUX OR ANDROID )
2020-06-26 18:45:11 +00:00
return ( )
endif ( )
message ( STATUS "Performing Test ${label}" )
execute_process ( COMMAND "${CMAKE_CXX_COMPILER}" -dumpmachine
O U T P U T _ V A R I A B L E o u t p u t
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
R E S U L T _ V A R I A B L E e x i t _ c o d e )
if ( exit_code EQUAL 0 )
set ( status_label "Success" )
else ( )
set ( status_label "Failed" )
endif ( )
message ( STATUS "Performing Test ${label} - ${status_label}" )
set ( TEST_machine_tuple "${output}" CACHE INTERNAL "${label}" )
endfunction ( )
2020-08-19 14:49:13 +00:00
function ( qt_config_compiler_supports_flag_test name )
if ( DEFINED "TEST_${name}" )
return ( )
endif ( )
cmake_parse_arguments ( arg "" "LABEL;FLAG" "" ${ ARGN } )
check_cxx_compiler_flag ( "${arg_FLAG}" TEST_ ${ name } )
set ( TEST_ ${ name } "${TEST_${name}}" CACHE INTERNAL "${label}" )
endfunction ( )
2020-08-21 10:59:24 +00:00
function ( qt_config_linker_supports_flag_test name )
if ( DEFINED "TEST_${name}" )
return ( )
endif ( )
cmake_parse_arguments ( arg "" "LABEL;FLAG" "" ${ ARGN } )
set ( flags "-Wl,${arg_FLAG}" )
# Select the right linker.
if ( GCC OR CLANG )
2021-07-12 10:43:27 +00:00
if ( QT_FEATURE_use_gold_linker )
2020-08-21 10:59:24 +00:00
list ( PREPEND flags "-fuse-ld=gold" )
2021-07-12 10:43:27 +00:00
elseif ( QT_FEATURE_use_bfd_linker )
2020-08-21 10:59:24 +00:00
list ( PREPEND flags "-fuse-ld=bfd" )
2021-07-12 10:43:27 +00:00
elseif ( QT_FEATURE_use_lld_linker )
2020-08-21 10:59:24 +00:00
list ( PREPEND flags "-fuse-ld=lld" )
endif ( )
endif ( )
set ( CMAKE_REQUIRED_LINK_OPTIONS ${ flags } )
check_cxx_source_compiles ( "int main() { return 0; }" TEST_ ${ name } )
set ( TEST_ ${ name } "${TEST_${name}}" CACHE INTERNAL "${label}" )
endfunction ( )
2019-01-14 10:35:53 +00:00
function ( qt_make_features_available target )
2020-05-31 10:34:05 +00:00
if ( NOT "${target}" MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*$" )
message ( FATAL_ERROR "${target} does not match ${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*. INVALID NAME." )
2019-01-14 10:35:53 +00:00
endif ( )
if ( NOT TARGET ${ target } )
message ( FATAL_ERROR "${target} not found." )
endif ( )
2019-01-10 09:50:38 +00:00
2019-01-14 10:35:53 +00:00
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" )
2019-01-14 10:01:06 +00:00
continue ( )
endif ( )
2019-01-14 10:35:53 +00:00
foreach ( feature IN ITEMS ${ features } )
2019-02-11 09:55:07 +00:00
if ( DEFINED "QT_FEATURE_${feature}" AND NOT "${QT_FEATURE_${feature}}" STREQUAL "${value}" )
2021-02-09 13:25:40 +00:00
message ( FATAL_ERROR "Feature ${feature} is already defined to be \" ${ QT_FEATURE_${feature } }\ " and should now be set to \" ${ value } \" when importing features from ${ target } . " )
2018-10-24 13:20:27 +00:00
endif ( )
2019-02-10 21:34:42 +00:00
set ( QT_FEATURE_ ${ feature } "${value}" CACHE INTERNAL "Qt feature: ${feature} (from target ${target})" )
2018-10-24 13:20:27 +00:00
endforeach ( )
2019-01-14 10:35:53 +00:00
set ( value OFF )
2018-10-24 13:20:27 +00:00
endforeach ( )
endforeach ( )
endfunction ( )