CMake: CCache: Always make clang happy

When we are using ccache anyway, always add the flags to make clang
happy. Also, fix copy-paste error regarding what variable to modify for
it.
This commit is contained in:
Neui 2024-06-10 23:41:49 +02:00
parent f91413db8f
commit a1c54063d0
1 changed files with 6 additions and 8 deletions

View File

@ -3,17 +3,15 @@ if(CCACHE_BIN)
# Official ccache recommendation is to set CMAKE_C(XX)_COMPILER_LAUNCHER
if (NOT CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")
list(INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_BIN}")
# ccache uses -I when compiling without preprocessor, which makes clang complain.
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics")
endif()
endif()
if (NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache")
list(INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_BIN}")
endif()
# ccache uses -I when compiling without preprocessor, which makes clang complain.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics")
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
endif()
endif()