This repository was archived by the owner on Mar 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -348,14 +348,16 @@ if( MSVC )
348
348
append ("/Zc:rvalueCast" CMAKE_CXX_FLAGS )
349
349
350
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>\n char16_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 ()
351
+ # Find and run MSVC (not clang-cl) and get its version. This will tell
352
+ # clang-cl what version of MSVC to pretend to be so that the STL works.
353
+ execute_process (COMMAND "$ENV{VSINSTALLDIR} /VC/bin/cl.exe"
354
+ OUTPUT_QUIET
355
+ ERROR_VARIABLE MSVC_COMPAT_VERSION
356
+ )
357
+ string (REGEX REPLACE "^.*Compiler Version ([0-9.]+) for .*$" "\\ 1"
358
+ MSVC_COMPAT_VERSION "${MSVC_COMPAT_VERSION} " )
359
+ append ("-fms-compatibility-version=${MSVC_COMPAT_VERSION} "
360
+ CMAKE_C_FLAGS CMAKE_CXX_FLAGS )
359
361
endif ()
360
362
361
363
if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
You can’t perform that action at this time.
0 commit comments