diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-17 09:54:59 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2020-02-18 14:44:57 +0100 |
commit | eaa29378b9009e36f643004e2df5265cc63409f6 (patch) | |
tree | f3ae00b3202c3b1d188db3067f242809ad915743 /cmake/QtBuild.cmake | |
parent | 00eeed234f7c4cfc357b17424e0dcd714ff65e70 (diff) |
CMake: Fix c++ standard config tests with MSVC
Need to pass additional -Zc:__cplusplus flag when using
MSVC, so that the __cplusplus define has correct values.
Additionally make the option be propagated to consumers of Qt
via the public Platform target, which QtCore links against.
Change-Id: Ie1283c25334b93f993529beb7fb32bdb001627f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 4456ea99f1..81573381c4 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -4016,6 +4016,14 @@ function(qt_set_language_standards) endif() 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. + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913) + target_compile_options("${target}" ${visibility} "-Zc:__cplusplus") + endif() +endfunction() + # Compatibility macros that should be removed once all their usages are removed. function(extend_target) qt_extend_target(${ARGV}) |