CMake: Propagate minimum required C++ standard to consumers of Qt

Aka the version of C++ that needs to be supported when compiling
applications that use Qt headers (C++17 at the moment).

Change-Id: I64dec297e8329f31b1d9864f216a95782049ed06
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexandru Croitor 2020-03-11 14:44:12 +01:00
parent d2419b0d8c
commit 5804473578
2 changed files with 11 additions and 0 deletions

View File

@ -200,6 +200,10 @@ target_include_directories(GlobalConfigPrivate INTERFACE
)
add_library(Qt::GlobalConfigPrivate ALIAS GlobalConfigPrivate)
# Propagate minimum C++ 17 via Platform to Qt consumers (apps), after the global features
# are computed.
qt_set_language_standards_interface_compile_features(Platform)
# defines PlatformCommonInternal PlatformModuleInternal PlatformPluginInternal PlatformToolInternal
include(QtInternalTargets)

View File

@ -4075,6 +4075,13 @@ function(qt_set_language_standards)
endif()
endfunction()
function(qt_set_language_standards_interface_compile_features target)
# Regardless of which C++ standard is used to build Qt itself, require C++17 when building
# Qt applications using CMake (because the Qt header files use C++17 features).
set(cpp_feature "cxx_std_17")
target_compile_features("${target}" INTERFACE ${cpp_feature})
endfunction()
function(qt_enable_msvc_cplusplus_define target visibility)
# For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus.
# Check qt_config_compile_test for more info.