llvm.org GIT mirror llvm / a796afd
[AIX] For XL, pick GCC-compatible std & default warning options Summary: LLVM now requires C++14. For IBM XL compilers with C++14 support, this can be done with the GCC-style options. The relevant block in the CMake file is split up into smaller parts as part of this patch to allow the common cases to be shared. Reviewers: jfb, jasonliu, daltenty, xingxue Reviewed By: jfb, xingxue Subscribers: mstorsjo, mgorny, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66256 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369058 91177308-0d34-0410-b5e6-96231b3b80d8 Hubert Tong 2 months ago
1 changed file(s) with 32 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
431431 endif()
432432 endif()
433433
434 elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
435 append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
436 append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS)
437 add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
438 add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
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++" gnu_LLVM_CXX_STD "${LLVM_CXX_STD}")
445 append("-std=${gnu_LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
434 else( MSVC )
435 # Warnings-as-errors handling for GCC-compatible compilers:
436 if ( LLVM_COMPILER_IS_GCC_COMPATIBLE )
437 append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
438 append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS)
439 endif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
440
441 # Specific default warnings-as-errors for compilers accepting GCC-compatible warning flags:
442 if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
443 add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME)
444 add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW)
445 endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
446
447 # C++ language standard selection for compilers accepting the GCC-style option:
448 if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
449 check_cxx_compiler_flag("-std=${LLVM_CXX_STD}" CXX_SUPPORTS_CXX_STD)
450 if (CXX_SUPPORTS_CXX_STD)
451 if (CYGWIN OR MINGW)
452 # MinGW and Cygwin are a bit stricter and lack things like
453 # 'strdup', 'stricmp', etc in c++11 mode.
454 string(REPLACE "c++" "gnu++" gnu_LLVM_CXX_STD "${LLVM_CXX_STD}")
455 append("-std=${gnu_LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
456 else()
457 append("-std=${LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
458 endif()
446459 else()
447 append("-std=${LLVM_CXX_STD}" CMAKE_CXX_FLAGS)
448 endif()
449 else()
450 message(FATAL_ERROR "The host compiler does not support '-std=${LLVM_CXX_STD}'.")
451 endif()
452 if (LLVM_ENABLE_MODULES)
460 message(FATAL_ERROR "The host compiler does not support '-std=${LLVM_CXX_STD}'.")
461 endif()
462 endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
463
464 # Modules enablement for GCC-compatible compilers:
465 if ( LLVM_COMPILER_IS_GCC_COMPATIBLE AND LLVM_ENABLE_MODULES )
453466 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
454467 set(module_flags "-fmodules -fmodules-cache-path=${PROJECT_BINARY_DIR}/module.cache")
455468 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
480493 else()
481494 message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler")
482495 endif()
483 endif(LLVM_ENABLE_MODULES)
496 endif( LLVM_COMPILER_IS_GCC_COMPATIBLE AND LLVM_ENABLE_MODULES )
484497 endif( MSVC )
485498
486499 if (MSVC)