Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit db91435

Browse files
committed
[cmake] Add -fms-compatibility-version=19 when clang-cl gives errors about char16_t
What we are really trying to do here is to figure out if we are using the 2015 STL. Unfortunately, so far as I know the MSVC STL does not define a version macro that we can check directly. Instead I wrote a check to see if char16_t works. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264881 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f3ba4d1 commit db91435

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmake/modules/HandleLLVMOptions.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,17 @@ if( MSVC )
347347
# "Enforce type conversion rules".
348348
append("/Zc:rvalueCast" CMAKE_CXX_FLAGS)
349349

350+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
351+
# In VS 2015, char16_t became a builtin type. Clang still defaults to VS
352+
# 2013 compatibility, where it cannot be a builtin type. If we're using an
353+
# STL newer than 2015, this compilation will fail. Rasing the MSVC
354+
# compatibility version of the compiler will provide char16/32.
355+
check_cxx_source_compiles("#include <cstdint>\nchar16_t v1;\n" STL_PROVIDES_CHAR16_T)
356+
if (NOT STL_PROVIDES_CHAR16_T)
357+
append("-fms-compatibility-version=19" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
358+
endif()
359+
endif()
360+
350361
if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
351362
# clang-cl and cl by default produce non-deterministic binaries because
352363
# link.exe /incremental requires a timestamp in the .obj file. clang-cl

0 commit comments

Comments
 (0)