cmake/linux: Move color diagnostics setting to preset for ubuntu-ci

This also removes color diagnostics setting for cmake < 3.24.
This commit is contained in:
Norihiro Kamae 2024-08-26 16:25:09 +09:00 • committed by Ryan Foster
commit 14aaaa325b
2 changed files with 3 additions and 8 deletions

View file

@ -82,7 +82,8 @@
"inherits": ["ubuntu"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_COMPILE_WARNING_AS_ERROR": true
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
"CMAKE_COLOR_DIAGNOSTICS": true
}
},
{

View file

@ -51,17 +51,11 @@ add_compile_options(
"$<$<COMPILE_LANG_AND_ID:CXX,Clang>:${_obs_clang_cxx_options}>"
)
# Add support for color diagnostics and CMake switch for warnings as errors to CMake < 3.24
# CMake switch for warnings as errors to CMake < 3.24
if(CMAKE_VERSION VERSION_LESS 3.24.0)
add_compile_options(
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-fcolor-diagnostics>
)
if(CMAKE_COMPILE_WARNING_AS_ERROR)
add_compile_options(-Werror)
endif()
else()
set(CMAKE_COLOR_DIAGNOSTICS ON)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)