llvm.org GIT mirror llvm / 564787f
[cmake] Instead of testing char16_t for MSVC compat, directly ask cl.exe its version Credit to Aaron Ballman for thinking of this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264886 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
1 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
347347 append("/Zc:rvalueCast" CMAKE_CXX_FLAGS)
348348
349349 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
350 # In VS 2015, char16_t became a builtin type. Clang still defaults to VS
351 # 2013 compatibility, where it cannot be a builtin type. If we're using an
352 # STL newer than 2015, this compilation will fail. Rasing the MSVC
353 # compatibility version of the compiler will provide char16/32.
354 check_cxx_source_compiles("#include \nchar16_t v1;\n" STL_PROVIDES_CHAR16_T)
355 if (NOT STL_PROVIDES_CHAR16_T)
356 append("-fms-compatibility-version=19" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
357 endif()
350 # Find and run MSVC (not clang-cl) and get its version. This will tell
351 # clang-cl what version of MSVC to pretend to be so that the STL works.
352 execute_process(COMMAND "$ENV{VSINSTALLDIR}/VC/bin/cl.exe"
353 OUTPUT_QUIET
354 ERROR_VARIABLE MSVC_COMPAT_VERSION
355 )
356 string(REGEX REPLACE "^.*Compiler Version ([0-9.]+) for .*$" "\\1"
357 MSVC_COMPAT_VERSION "${MSVC_COMPAT_VERSION}")
358 append("-fms-compatibility-version=${MSVC_COMPAT_VERSION}"
359 CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
358360 endif()
359361
360362 if (NOT LLVM_ENABLE_TIMESTAMPS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")