| Teresa Johnson | f7f02fa | 2016-10-18 17:17:37 +0000 | [diff] [blame] | 1 | # Check if the host compiler is new enough. LLVM requires at least GCC 4.8, | 
| Reid Kleckner | e793966 | 2016-12-15 19:08:02 +0000 | [diff] [blame] | 2 | # MSVC 2015 (Update 3), or Clang 3.1. | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 3 |  | 
| Saleem Abdulrasool | 2d5e95c | 2016-03-08 18:56:00 +0000 | [diff] [blame] | 4 | include(CheckCXXSourceCompiles) | 
|  | 5 |  | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 6 | if(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 Ballman | c78f5d4 | 2016-11-14 13:33:51 +0000 | [diff] [blame] | 11 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) | 
|  | 12 | message(FATAL_ERROR "Host GCC version must be at least 4.8!") | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 13 | 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") | 
| Reid Kleckner | e793966 | 2016-12-15 19:08:02 +0000 | [diff] [blame] | 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") | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 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}) | 
| Don Hinton | 3a5a48b | 2017-12-25 01:23:09 +0000 | [diff] [blame] | 31 | set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x") | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 32 | check_cxx_source_compiles(" | 
|  | 33 | #include <atomic> | 
|  | 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) | 
| Aaron Ballman | c78f5d4 | 2016-11-14 13:33:51 +0000 | [diff] [blame] | 38 | message(FATAL_ERROR "Host Clang must be able to find libstdc++4.8 or newer!") | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 39 | 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") | 
| Reid Kleckner | e793966 | 2016-12-15 19:08:02 +0000 | [diff] [blame] | 44 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0) | 
|  | 45 | message(FATAL_ERROR "Host Visual Studio must be at least 2015") | 
| Zachary Turner | 491fe5b | 2017-01-03 23:12:36 +0000 | [diff] [blame] | 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)" | 
| Reid Kleckner | 9fac19f | 2016-03-02 16:42:56 +0000 | [diff] [blame] | 48 | "  due to miscompiles from earlier versions") | 
|  | 49 | endif() | 
|  | 50 | endif() | 
|  | 51 | endif() | 
|  | 52 | endif() |