mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 22:58:37 -05:00
Clang: For MSVC ABI do not use modes older than C++14
Since commitd44c0db0b2(clang: setup correct configuration in gnu mode, 2019-02-20, v3.15.0-rc1~41^2~5) we support the GNU-like Clang that targets the MSVC ABI. However, Clang cannot compile with the MSVC standard library unless it runs in a mode aware of C++14 (since MSVC itself does not even have a lower mode). When `CMAKE_CXX_STANDARD` is set to 98 or 11, use C++14 anyway. Since Clang's default mode is aware of C++14, another option is to not add any flags for 98 or 11. However, if a future Clang version ever defaults to a higher C++ standard, setting the standard to 98 or 11 should at least not use a mode higher than 14. Also revert test updates from commit4819ff9647(Tests: fix failures with gnu mode clang on windows, 2019-03-21, v3.15.0-rc1~41^2~3) that were meant to work around the standard selection problem. Fixes: #19496
This commit is contained in:
@@ -58,6 +58,13 @@ if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
|
||||
unset(_clang_version_std17)
|
||||
|
||||
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
# The MSVC standard library requires C++14, and MSVC itself has no
|
||||
# notion of operating in a mode not aware of at least that standard.
|
||||
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++14")
|
||||
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++14")
|
||||
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++14")
|
||||
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++14")
|
||||
|
||||
# This clang++ is missing some features because of MSVC compatibility.
|
||||
unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
|
||||
unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
|
||||
|
||||
Reference in New Issue
Block a user