-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12842 from Neui/fix-cmake-ccache
CMake: Fix CCache support when already using _LAUNCHER
- Loading branch information
Showing
1 changed file
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
find_program(CCACHE_BIN NAMES ccache sccache) | ||
if(CCACHE_BIN) | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${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}") | ||
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_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics") | ||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics") | ||
endif() | ||
endif() |