CMake: Fix build with MSVC 2019 and Qt 6.2

Qt 6.2 requires __cplusplus preprocessor set to at least 201703L

According to https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
one needs to add the compiler flag /Zc:__cplusplus

CMake doesn't set the flag, there is an issue opened at
https://gitlab.kitware.com/cmake/cmake/-/issues/18837

This flag is passed to any target that links to Qt6::Core, unless
the flags are not manually copied for some reason.

Task-number: QTCREATORBUG-25730
Change-Id: I271e85fe857b5d4ac8980f77c723e5704a8eb743
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2021-05-20 17:43:17 +02:00
parent ad16790140
commit 9449bfbf04
2 changed files with 8 additions and 5 deletions
+2
View File
@@ -295,10 +295,12 @@ function(add_qtc_depends target_name)
endif()
foreach(obj_lib IN LISTS object_lib_depends)
target_compile_options(${target_name} PRIVATE $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_OPTIONS>)
target_compile_definitions(${target_name} PRIVATE $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(${target_name} PRIVATE $<TARGET_PROPERTY:${obj_lib},INTERFACE_INCLUDE_DIRECTORIES>)
endforeach()
foreach(obj_lib IN LISTS object_public_depends)
target_compile_options(${target_name} PUBLIC $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_OPTIONS>)
target_compile_definitions(${target_name} PUBLIC $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(${target_name} PUBLIC $<TARGET_PROPERTY:${obj_lib},INTERFACE_INCLUDE_DIRECTORIES>)
endforeach()