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