1 # Check if the host compiler is new enough. LLVM requires at least GCC 4.8,
2 # MSVC 2015 (Update 3), or Clang 3.1.
4 include(CheckCXXSourceCompiles)
6 if(NOT DEFINED LLVM_COMPILER_CHECKED)
7 set(LLVM_COMPILER_CHECKED ON)
9 if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
10 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
11 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
12 message(FATAL_ERROR "Host GCC version must be at least 4.8!")
14 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
15 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
16 message(FATAL_ERROR "Host Clang version must be at least 3.1!")
19 if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
20 if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 19.0)
21 message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=19.0")
24 elseif(NOT LLVM_ENABLE_LIBCXX)
25 # Otherwise, test that we aren't using too old of a version of libstdc++
26 # with the Clang compiler. This is tricky as there is no real way to
27 # check the version of libstdc++ directly. Instead we test for a known
28 # bug in libstdc++4.6 that is fixed in libstdc++4.7.
29 set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
30 set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
31 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
32 check_cxx_source_compiles("
34 std::atomic<float> x(0.0f);
35 int main() { return (float)x; }"
36 LLVM_NO_OLD_LIBSTDCXX)
37 if(NOT LLVM_NO_OLD_LIBSTDCXX)
38 message(FATAL_ERROR "Host Clang must be able to find libstdc++4.8 or newer!")
40 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
41 set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
43 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
44 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
45 message(FATAL_ERROR "Host Visual Studio must be at least 2015")
46 elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00.24213.1)
47 message(WARNING "Host Visual Studio should at least be 2015 Update 3 (MSVC 19.00.24213.1)"
48 " due to miscompiles from earlier versions")