From 5804473578b87f8a674eb230ee059851f6a7aaaa Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 11 Mar 2020 14:44:12 +0100 Subject: [PATCH] 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 Reviewed-by: Alexandru Croitor --- cmake/QtBaseGlobalTargets.cmake | 4 ++++ cmake/QtBuild.cmake | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index 32f0fa8c5f3..6e047f59caf 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -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) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index af8cc6c4827..2f5215c1bf8 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -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.