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