llvm.org GIT mirror llvm / 9736ffc
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357899 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 6 months ago
3 changed file(s) with 23 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
420420 option(LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF)
421421 option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON)
422422 endif()
423 option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
424 option(LLVM_ENABLE_CXX1Z "Compile with C++1z enabled." OFF)
425423 option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
426424 option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF)
427425 option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
428426 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
427
428 set(LLVM_CXX_STD_default "c++11")
429 # Preserve behaviour of legacy cache variables
430 if (LLVM_ENABLE_CXX1Y)
431 set(LLVM_CXX_STD_default "c++1y")
432 elseif (LLVM_ENABLE_CXX1Z)
433 set(LLVM_CXX_STD_default "c++1z")
434 endif()
435 set(LLVM_CXX_STD ${LLVM_CXX_STD_default}
436 CACHE STRING "C++ standard to use for compilation.")
429437
430438 option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF)
431439
436436 append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS)
437437 add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
438438 add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
439 if (LLVM_ENABLE_CXX1Y)
440 check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
441 append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
442 elseif(LLVM_ENABLE_CXX1Z)
443 check_cxx_compiler_flag("-std=c++1z" CXX_SUPPORTS_CXX1Z)
444 append_if(CXX_SUPPORTS_CXX1Z "-std=c++1z" CMAKE_CXX_FLAGS)
439 check_cxx_compiler_flag("-std=${LLVM_CXX_STD}" CXX_SUPPORTS_CXX_STD)
440 if (CXX_SUPPORTS_CXX_STD)
441 if (CYGWIN OR MINGW)
442 # MinGW and Cygwin are a bit stricter and lack things like
443 # 'strdup', 'stricmp', etc in c++11 mode.
444 string(REPLACE "c++" "gnu++" "${LLVM_CXX_STD}" gnu_LLVM_CXX_STD)
445 append("-std=${gnu_LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
446 else()
447 append("-std=${LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
448 endif()
445449 else()
446 check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
447 if (CXX_SUPPORTS_CXX11)
448 if (CYGWIN OR MINGW)
449 # MinGW and Cygwin are a bit stricter and lack things like
450 # 'strdup', 'stricmp', etc in c++11 mode.
451 append("-std=gnu++11" CMAKE_CXX_FLAGS)
452 else()
453 append("-std=c++11" CMAKE_CXX_FLAGS)
454 endif()
455 else()
456 message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
457 endif()
450 message(FATAL_ERROR "The host compiler does not support '-std=${LLVM_CXX_STD}'.")
458451 endif()
459452 if (LLVM_ENABLE_MODULES)
460453 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
265265 **LLVM_ENABLE_THREADS**:BOOL
266266 Build with threads support, if available. Defaults to ON.
267267
268 **LLVM_ENABLE_CXX1Y**:BOOL
269 Build in C++1y mode, if available. Defaults to OFF.
268 **LLVM_CXX_STD**:STRING
269 Build with the specified C++ standard. Defaults to "c++11".
270270
271271 **LLVM_ENABLE_ASSERTIONS**:BOOL
272272 Enables code assertions. Defaults to ON if and only if ``CMAKE_BUILD_TYPE``