Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ccache to github actions #12

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ jobs:
with:
submodules: true

- name: Cache for ccache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ${{ matrix.os }}-build-ccache-${{ hashFiles('**/git-modules.txt') }}
restore-keys: |
${{ matrix.os }}-build-ccache-

- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-graph-dev
sudo apt-get install -y libboost-graph-dev ccache

- name: CMake
run: |
Expand Down Expand Up @@ -99,6 +107,7 @@ jobs:
run: |
pushd build
make -j$(nproc)
make ccache-stats
popd

- name: Test
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache"))
find_program(ccache_EXECUTABLE ccache)
if(ccache_EXECUTABLE)
set(CMAKE_C_COMPILER_LAUNCHER ${ccache_EXECUTABLE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_EXECUTABLE})
add_custom_target(ccache-stats
COMMAND ${ccache_EXECUTABLE} --show-stats
)
else()
add_custom_target(ccache-stats
COMMAND echo "ccache not found."
)
endif(ccache_EXECUTABLE)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall")

if (APPLE)
Expand Down