Skip to content

Commit 2724d9e

Browse files
committed
build: remove LLVM_CXX_STD extension point
This extension point is not needed. Provide the equivalent option through `CMAKE_CXX_STANDARD` which mirrors the previous extension point. Rely on CMake to provide the check for the compiler instead.
1 parent 074af2d commit 2724d9e

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

llvm/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ project(LLVM
5050
VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}
5151
LANGUAGES C CXX ASM)
5252

53+
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
54+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
55+
set(CMAKE_CXX_EXTENSIONS NO)
56+
5357
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
5458
message(STATUS "No build type selected, default to Debug")
5559
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)" FORCE)

llvm/cmake/modules/HandleLLVMOptions.cmake

-28
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ else()
1818
set(LINKER_IS_LLD_LINK FALSE)
1919
endif()
2020

21-
set(LLVM_CXX_STD_default "c++14")
22-
# Preserve behaviour of legacy cache variables
23-
if (LLVM_ENABLE_CXX1Z)
24-
set(LLVM_CXX_STD_default "c++1z")
25-
endif()
26-
if (LLVM_CXX_STD STREQUAL "c++11")
27-
set(LLVM_CXX_STD_force FORCE)
28-
endif()
29-
set(LLVM_CXX_STD ${LLVM_CXX_STD_default}
30-
CACHE STRING "C++ standard to use for compilation." ${LLVM_CXX_STD_force})
31-
3221
set(LLVM_ENABLE_LTO OFF CACHE STRING "Build LLVM with LTO. May be specified as Thin or Full to use a particular kind of LTO")
3322
string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
3423

@@ -445,23 +434,6 @@ if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
445434
add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
446435
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
447436

448-
# C++ language standard selection for compilers accepting the GCC-style option:
449-
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
450-
check_cxx_compiler_flag("-std=${LLVM_CXX_STD}" CXX_SUPPORTS_CXX_STD)
451-
if (CXX_SUPPORTS_CXX_STD)
452-
if (CYGWIN OR MINGW)
453-
# MinGW and Cygwin are a bit stricter and lack things like
454-
# 'strdup', 'stricmp', etc in c++11 mode.
455-
string(REPLACE "c++" "gnu++" gnu_LLVM_CXX_STD "${LLVM_CXX_STD}")
456-
append("-std=${gnu_LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
457-
else()
458-
append("-std=${LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
459-
endif()
460-
else()
461-
message(FATAL_ERROR "The host compiler does not support '-std=${LLVM_CXX_STD}'.")
462-
endif()
463-
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
464-
465437
# Modules enablement for GCC-compatible compilers:
466438
if ( LLVM_COMPILER_IS_GCC_COMPATIBLE AND LLVM_ENABLE_MODULES )
467439
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})

llvm/docs/CMake.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ CMake manual, or execute ``cmake --help-variable VARIABLE_NAME``.
204204
**CMAKE_CXX_FLAGS**:STRING
205205
Extra flags to use when compiling C++ source files.
206206

207+
Rarely-used CMake variables
208+
---------------------------
209+
210+
Here are some of the CMake variables that are rarely used, along with a brief
211+
explanation and LLVM-specific notes. For full documentation, consult the CMake
212+
manual, or execute ``cmake --help-variable VARIABLE_NAME``.
213+
214+
**CMAKE_CXX_STANDARD**:STRING
215+
Sets the C++ standard to conform to when building LLVM. Possible values are
216+
14, 17, 20. LLVM Requires C++ 14 or higher. This defaults to 14.
217+
207218
.. _LLVM-specific variables:
208219

209220
LLVM-specific variables
@@ -274,9 +285,6 @@ LLVM-specific variables
274285
Enable unwind tables in the binary. Disabling unwind tables can reduce the
275286
size of the libraries. Defaults to ON.
276287

277-
**LLVM_CXX_STD**:STRING
278-
Build with the specified C++ standard. Defaults to "c++11".
279-
280288
**LLVM_ENABLE_ASSERTIONS**:BOOL
281289
Enables code assertions. Defaults to ON if and only if ``CMAKE_BUILD_TYPE``
282290
is *Debug*.

0 commit comments

Comments
 (0)