[llvm] r357899 - [CMake] Replace LLVM_ENABLE_CXX1Y and friends with LLVM_CXX_STD
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 03:19:17 PDT 2019
Author: bogner
Date: Mon Apr 8 03:19:17 2019
New Revision: 357899
URL: http://llvm.org/viewvc/llvm-project?rev=357899&view=rev
Log:
[CMake] Replace LLVM_ENABLE_CXX1Y and friends with LLVM_CXX_STD
Simplify building with particular C++ standards by replacing the
specific "enable standard X" flags with a flag that allows specifying
the standard you want directly.
We preserve compatibility with the existing flags so that anyone with
those flags in existing caches won't break mysteriously.
Differential Revision: https://reviews.llvm.org/D60399
Modified:
llvm/trunk/CMakeLists.txt
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
llvm/trunk/docs/CMake.rst
Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=357899&r1=357898&r2=357899&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Mon Apr 8 03:19:17 2019
@@ -421,13 +421,21 @@ else()
option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF)
option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON)
endif()
-option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
-option(LLVM_ENABLE_CXX1Z "Compile with C++1z enabled." OFF)
option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF)
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
+set(LLVM_CXX_STD_default "c++11")
+# Preserve behaviour of legacy cache variables
+if (LLVM_ENABLE_CXX1Y)
+ set(LLVM_CXX_STD_default "c++1y")
+elseif (LLVM_ENABLE_CXX1Z)
+ set(LLVM_CXX_STD_default "c++1z")
+endif()
+set(LLVM_CXX_STD ${LLVM_CXX_STD_default}
+ CACHE STRING "C++ standard to use for compilation.")
+
option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF)
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=357899&r1=357898&r2=357899&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Mon Apr 8 03:19:17 2019
@@ -437,25 +437,18 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE
append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS)
add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
- if (LLVM_ENABLE_CXX1Y)
- check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
- append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
- elseif(LLVM_ENABLE_CXX1Z)
- check_cxx_compiler_flag("-std=c++1z" CXX_SUPPORTS_CXX1Z)
- append_if(CXX_SUPPORTS_CXX1Z "-std=c++1z" CMAKE_CXX_FLAGS)
- else()
- check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
- if (CXX_SUPPORTS_CXX11)
- if (CYGWIN OR MINGW)
- # MinGW and Cygwin are a bit stricter and lack things like
- # 'strdup', 'stricmp', etc in c++11 mode.
- append("-std=gnu++11" CMAKE_CXX_FLAGS)
- else()
- append("-std=c++11" CMAKE_CXX_FLAGS)
- endif()
+ check_cxx_compiler_flag("-std=${LLVM_CXX_STD}" CXX_SUPPORTS_CXX_STD)
+ if (CXX_SUPPORTS_CXX_STD)
+ if (CYGWIN OR MINGW)
+ # MinGW and Cygwin are a bit stricter and lack things like
+ # 'strdup', 'stricmp', etc in c++11 mode.
+ string(REPLACE "c++" "gnu++" "${LLVM_CXX_STD}" gnu_LLVM_CXX_STD)
+ append("-std=${gnu_LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
else()
- message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
+ append("-std=${LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
endif()
+ else()
+ message(FATAL_ERROR "The host compiler does not support '-std=${LLVM_CXX_STD}'.")
endif()
if (LLVM_ENABLE_MODULES)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
Modified: llvm/trunk/docs/CMake.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.rst?rev=357899&r1=357898&r2=357899&view=diff
==============================================================================
--- llvm/trunk/docs/CMake.rst (original)
+++ llvm/trunk/docs/CMake.rst Mon Apr 8 03:19:17 2019
@@ -266,8 +266,8 @@ LLVM-specific variables
**LLVM_ENABLE_THREADS**:BOOL
Build with threads support, if available. Defaults to ON.
-**LLVM_ENABLE_CXX1Y**:BOOL
- Build in C++1y mode, if available. Defaults to OFF.
+**LLVM_CXX_STD**:STRING
+ Build with the specified C++ standard. Defaults to "c++11".
**LLVM_ENABLE_ASSERTIONS**:BOOL
Enables code assertions. Defaults to ON if and only if ``CMAKE_BUILD_TYPE``
More information about the llvm-commits
mailing list