[libcxx-commits] [libcxx] 5ce2c6d - build: avoid custom handling for C++ standard

Saleem Abdulrasol via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 2 12:08:19 PDT 2019


Author: Saleem Abdulrasol
Date: 2019-11-02T15:07:54-04:00
New Revision: 5ce2c6d2db88019e0b8bc00c77e4155b4eaa15d7

URL: https://github.com/llvm/llvm-project/commit/5ce2c6d2db88019e0b8bc00c77e4155b4eaa15d7
DIFF: https://github.com/llvm/llvm-project/commit/5ce2c6d2db88019e0b8bc00c77e4155b4eaa15d7.diff

LOG: build: avoid custom handling for C++ standard

Use the builtin CMake support for specifying the proper flags for the targets to
build at a certain C++ standard.  This avoids unnecessary checks in CMake,
speeding up the configure phase as well as simplifies the logic overall.

Added: 
    

Modified: 
    libcxx/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index e57ed030a8d0..cdb3b085cb07 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -518,21 +518,18 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
 
 # Required flags ==============================================================
 function(cxx_add_basic_build_flags target)
-  if (LIBCXX_HAS_MUSL_LIBC OR LIBCXX_TARGETING_CLANG_CL)
-    # musl's pthread implementations uses volatile types in their structs which is
-    # not a constexpr in C++11 but is in C++14, so we use C++14 with musl.
-    set(LIBCXX_STANDARD_VER c++14 CACHE STRING "internal option to change build dialect")
+  if(LIBCXX_HAS_MUSL_LIBC OR LIBCXX_TARGETING_CLANG_CL)
+    # musl's pthread implementations uses volatile types in their structs which
+    # is not a constexpr in C++11 but is in C++14, so we use C++14 with musl.
+    set_target_properties(${target} PROPERTIES
+      CXX_STANDARD 14
+      CXX_STANDARD_REQUIRED YES
+      CXX_EXTENSIONS NO)
   else()
-    set(LIBCXX_STANDARD_VER c++11 CACHE STRING "internal option to change build dialect")
-  endif()
-  target_add_compile_flags_if_supported(${target} PRIVATE -std=${LIBCXX_STANDARD_VER})
-  target_add_compile_flags_if_supported(${target} PRIVATE "/std:${LIBCXX_STANDARD_VER}")
-  mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME)
-  mangle_name("LIBCXX_SUPPORTS_STD_COLON_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME_MSVC)
-  if(NOT ${SUPPORTS_DIALECT_NAME} AND NOT ${SUPPORTS_DIALECT_NAME_MSVC})
-    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()
+    set_target_properties(${target} PROPERTIES
+      CXX_STANDARD 11
+      CXX_STANDARD_REQUIRED YES
+      CXX_EXTENSIONS NO)
   endif()
 
   # On all systems the system c++ standard library headers need to be excluded.


        


More information about the libcxx-commits mailing list