mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Divert LCC compiler as a new one, instead of treating it as GNU. Since old times, Elbrus C/C++/Fortran Compiler (LCC) by MCST has been passing checks for GNU compilers, so it has been identified as GNU. Now, with intent of seriously upstreaming its support, it has been added as a separate LCC compiler, and its version displays not a supported GCC version, but LCC version itself (e.g. LCC 1.25.19 instead of GNU 7.3.0). This commit adds its support for detection, and also converts basically every check like 'is this compiler GNU?' to 'is this compiler GNU or LCC?'. The only places where this check is untouched, is where it regards other platforms where LCC is unavailable (primarily non-Linux), and where it REALLY differs from GNU compiler. Note: this transition may break software that are already ported to Elbrus, but hardly relies that LCC will be detected as GNU; still such software is not known.
25 lines
816 B
CMake
25 lines
816 B
CMake
|
|
enable_language (C)
|
|
include(CheckCompilerFlag)
|
|
|
|
set(C 1) # test that this is tolerated
|
|
|
|
check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL)
|
|
if(SHOULD_FAIL)
|
|
message(SEND_ERROR "invalid C compile flag didn't fail.")
|
|
endif()
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
|
|
check_compiler_flag(C "-x c" SHOULD_WORK)
|
|
if(NOT SHOULD_WORK)
|
|
message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-x c' check failed")
|
|
endif()
|
|
endif()
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU") # LCC C compiler silently ignore -frtti instead of failing, so skip it here.
|
|
check_compiler_flag(C "-frtti" SHOULD_FAIL_RTTI)
|
|
if(SHOULD_FAIL_RTTI)
|
|
message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed")
|
|
endif()
|
|
endif()
|