From 1ca3c453160bef16d1296367fa65d72c1d18da5d Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 1 Jan 2017 20:20:40 +0000 Subject: [PATCH] build: further improve flags handling for cl This allows us to build with cl (or rather clang-cl) by using the correct spelling for `-include` (`/FI` for cl). clang-cl and cl default to C++11/C++14 as they support it rather than permitting an explicit language standard. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290802 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 658221efa..823bfb5cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -354,8 +354,10 @@ if (LIBCXX_HAS_MUSL_LIBC) endif() add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER}) mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME) -if (NOT MSVC AND NOT ${SUPPORTS_DIALECT_NAME}) - message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}") +if(NOT ${SUPPORTS_DIALECT_NAME}) + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}") + endif() endif() # On all systems the system c++ standard library headers need to be excluded. @@ -515,13 +517,17 @@ if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) endif() if (LIBCXX_NEEDS_SITE_CONFIG) - configure_file( - include/__config_site.in - ${LIBCXX_BINARY_DIR}/__config_site - @ONLY) + configure_file("include/__config_site.in" + "${LIBCXX_BINARY_DIR}/__config_site" + @ONLY) + # Provide the config definitions by included the generated __config_site # file at compile time. - add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + add_compile_flags("/FI\"${LIBCXX_BINARY_DIR}/__config_site\"") + else() + add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") + endif() endif() #===============================================================================