Enhance CMake compiler check on Linux (#102)

* Enhance CMake compiler check

This commit adds a check for compilers that don't meet the project's
minimum requirements. It will catch Clang versions that are too low as
well as any non-Clang compilers.

* Change SEND_ERROR to FATAL_ERROR
This commit is contained in:
Cory Bloor
2018-08-15 19:05:02 -06:00
committed by Romain Guy
parent 6d9668ccf6
commit 2dc0d278ac

View File

@@ -61,11 +61,22 @@ set(TOOLS ${CMAKE_SOURCE_DIR}/tools)
# ==================================================================================================
# Compiler check
# ==================================================================================================
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(FATAL_ERROR
"The GCC compiler is not supported, please use clang for both C and C++. "
"Please refer to README.md for more information.")
return()
set(MIN_CLANG_VERSION "5.0")
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
message(FATAL_ERROR "Detected C compiler Clang ${CMAKE_C_COMPILER_VERSION} < ${MIN_CLANG_VERSION}")
endif()
else()
message(FATAL_ERROR "Detected C compiler ${CMAKE_C_COMPILER_ID} is unsupported")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MIN_CLANG_VERSION)
message(FATAL_ERROR "Detected CXX compiler Clang ${CMAKE_CXX_COMPILER_VERSION} < ${MIN_CLANG_VERSION}")
endif()
else()
message(FATAL_ERROR "Detected CXX compiler ${CMAKE_CXX_COMPILER_ID} is unsupported")
endif()
# Detect use of the clang-cl.exe frontend, which does not support all of clangs normal options