Treat LCC as compiler different from GCC

LCC (eLbrus C/C++ compiler) is an EDG-based compiler that in most cases
is similar in behavior to GNU, but it has different warning options
supported and enabled by default. It seems to have sense to treat LCC
and GNU differently, as CMake supports it from 3.23.

For it to be done, CMake policy CMP0129 should be set to NEW,
and then CMAKE_${LANG}_COMPILER_ID may be checked to be STREQUAL "LCC".

This commit does this, and introduces warning arguments in call
to compiler that are slightly different from GNU to let googletest be
buildable without unexpected warnings.
This commit is contained in:
makise-homura 2024-08-22 21:12:11 +03:00
parent 0953a17a42
commit 5b2ecaa64e
4 changed files with 13 additions and 3 deletions

View File

@ -3,6 +3,7 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0129 NEW)
project(googletest-distribution) project(googletest-distribution)
set(GOOGLETEST_VERSION 1.15.2) set(GOOGLETEST_VERSION 1.15.2)

View File

@ -37,6 +37,7 @@ endif()
# ${gmock_BINARY_DIR}. # ${gmock_BINARY_DIR}.
# Language "C" is required for find_package(Threads). # Language "C" is required for find_package(Threads).
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0129 NEW)
project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C) project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
if (COMMAND set_up_hermetic_build) if (COMMAND set_up_hermetic_build)

View File

@ -47,6 +47,7 @@ endif()
# Project version. # Project version.
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0129 NEW)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C) project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
if (COMMAND set_up_hermetic_build) if (COMMAND set_up_hermetic_build)

View File

@ -102,9 +102,11 @@ macro(config_compiler_and_linker)
if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise") set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise")
endif() endif()
elseif (CMAKE_COMPILER_IS_GNUCXX) elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
set(cxx_base_flags "-Wall -Wshadow -Wundef") CMAKE_CXX_COMPILER_ID STREQUAL "LCC")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) set(cxx_base_flags "-Wall -Wundef")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else") set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
endif() endif()
set(cxx_exception_flags "-fexceptions") set(cxx_exception_flags "-fexceptions")
@ -115,6 +117,11 @@ macro(config_compiler_and_linker)
set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0") set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
set(cxx_strict_flags set(cxx_strict_flags
"-Wextra -Wno-unused-parameter -Wno-missing-field-initializers") "-Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
if (CMAKE_CXX_COMPILER_ID STREQUAL "LCC")
set(cxx_base_flags "${cxx_base_flags} -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function")
else()
set(cxx_base_flags "${cxx_base_flags} -Wshadow")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(cxx_exception_flags "-features=except") set(cxx_exception_flags "-features=except")
# Sun Pro doesn't provide macros to indicate whether exceptions and # Sun Pro doesn't provide macros to indicate whether exceptions and