+ 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)
+ 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()
+ else()
+ message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
+ endif()
+ endif()
+ if (LLVM_ENABLE_MODULES)
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fmodules -fcxx-modules")
+ # Check that we can build code with modules enabled, and that repeatedly
+ # including <cassert> still manages to respect NDEBUG properly.
+ CHECK_CXX_SOURCE_COMPILES("#undef NDEBUG
+ #include <cassert>
+ #define NDEBUG
+ #include <cassert>
+ int main() { assert(this code is not compiled); }"
+ CXX_SUPPORTS_MODULES)
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+ if (CXX_SUPPORTS_MODULES)
+ append_if(CXX_SUPPORTS_MODULES "-fmodules" CMAKE_C_FLAGS)
+ append_if(CXX_SUPPORTS_MODULES "-fmodules -fcxx-modules" CMAKE_CXX_FLAGS)
+ else()
+ message(FATAL_ERROR "LLVM_ENABLE_MODULES is not supported by this compiler")
+ endif()
+ endif(LLVM_ENABLE_MODULES)