Skip to content

Commit

Permalink
feat: make ccache usable on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Mar 31, 2022
1 parent 7fb3d1e commit 412730f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,8 @@ include(cmake/CPM.cmake)
# excluded from the generated target lists for the various tools.
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/third_party_deps)

# ---- Speedup build using ccache ----
# see https://github.com/TheLartians/Ccache.cmake enables CCACHE support through
# the USE_CCACHE flag possible values are: YES, NO or equivalent
if(USE_CCACHE)
cpmaddpackage("gh:TheLartians/Ccache.cmake@1.2.3")
endif()
# ---- Speedup build using ccache (needs CPM) ----
include(cmake/FasterBuild.cmake)

# ------------------------------------------------------------------------------
# Testing
Expand Down
22 changes: 22 additions & 0 deletions cmake/FasterBuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#

# ------------------------------------------------------------------------------
# Reduce build time by using ccache when available
# ------------------------------------------------------------------------------

find_program(CCACHE_TOOL_PATH ccache)

if(NOT WIN32 AND USE_CCACHE AND CCACHE_TOOL_PATH)
message(STATUS "Using ccache (${CCACHE_TOOL_PATH}) (via wrapper).")
# see https://github.com/TheLartians/Ccache.cmake enables CCACHE support through
# the USE_CCACHE flag possible values are: YES, NO or equivalent
cpmaddpackage("gh:TheLartians/Ccache.cmake@1.2.3")
elseif(WIN32 AND USE_CCACHE AND CCACHE_TOOL_PATH)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
message(STATUS "Using ccache (${CCACHE_TOOL_PATH}).")
endif()

0 comments on commit 412730f

Please sign in to comment.