blob: 1c046ade7e155b76c2a64fe3dd2bfd5a9e924524 [file] [log] [blame]
Teresa Johnsonf7f02fa2016-10-18 17:17:37 +00001# Check if the host compiler is new enough. LLVM requires at least GCC 4.8,
Reid Kleckner9fac19f2016-03-02 16:42:56 +00002# MSVC 2013, or Clang 3.1.
3
Saleem Abdulrasool2d5e95c2016-03-08 18:56:00 +00004include(CheckCXXSourceCompiles)
5
Reid Kleckner9fac19f2016-03-02 16:42:56 +00006if(NOT DEFINED LLVM_COMPILER_CHECKED)
7 set(LLVM_COMPILER_CHECKED ON)
8
9 if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
10 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Aaron Ballmanc78f5d42016-11-14 13:33:51 +000011 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
12 message(FATAL_ERROR "Host GCC version must be at least 4.8!")
Reid Kleckner9fac19f2016-03-02 16:42:56 +000013 endif()
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!")
17 endif()
18
19 if (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
20 if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 18.0)
21 message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=18.0")
22 endif()
23 set(CLANG_CL 1)
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 "-std=c++0x")
32 check_cxx_source_compiles("
33#include <atomic>
34std::atomic<float> x(0.0f);
35int main() { return (float)x; }"
36 LLVM_NO_OLD_LIBSTDCXX)
37 if(NOT LLVM_NO_OLD_LIBSTDCXX)
Aaron Ballmanc78f5d42016-11-14 13:33:51 +000038 message(FATAL_ERROR "Host Clang must be able to find libstdc++4.8 or newer!")
Reid Kleckner9fac19f2016-03-02 16:42:56 +000039 endif()
40 set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
41 set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
42 endif()
43 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
44 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0)
45 message(FATAL_ERROR "Host Visual Studio must be at least 2013")
46 elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.31101)
47 message(WARNING "Host Visual Studio should at least be 2013 Update 4 (MSVC 18.0.31101)"
48 " due to miscompiles from earlier versions")
49 endif()
50 endif()
51 endif()
52endif()