Skip to content

Commit

Permalink
Merge pull request #478 from ValeevGroup/evaleev/fix/use-ccache-corre…
Browse files Browse the repository at this point in the history
…ctly

use `ccache` correctly
  • Loading branch information
evaleev authored Sep 25, 2024
2 parents 2d9fd7f + 4523aa6 commit 8da57e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,10 @@ jobs:
sudo ln -s /usr/lib/x86_64-linux-gnu/libscalapack-openmpi.so /usr/lib/x86_64-linux-gnu/libscalapack.so
echo "MPIEXEC=/usr/bin/mpiexec" >> $GITHUB_ENV
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Setup ccache cache files
uses: actions/[email protected]
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
path: ${{github.workspace}}/build/.ccache
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
key: ccache-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.task_backend }}

- name: "Configure build: ${{ env.BUILD_CONFIG }}"
shell: bash
Expand Down
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
##########################
add_custom_target(External-tiledarray)

# ccache is an optional dep but must be found first so that the rest of dependencies can use it
find_program(CCACHE ccache)
if(CCACHE)
mark_as_advanced(CCACHE)
message (STATUS "Found ccache: ${CCACHE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}" CACHE STRING "Compiler launcher to use for compiling C++")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}" CACHE STRING "Compiler launcher to use for compiling C")
set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE}" CACHE STRING "Compiler launcher to use for compiling CUDA")
endif(CCACHE)

# required deps:
# 1. derive runtime (CUDA/HIP/...) first since others may depend on it
if(ENABLE_CUDA)
Expand Down Expand Up @@ -336,15 +346,7 @@ if(ENABLE_SCALAPACK)
include(external/scalapackpp.cmake)
endif()

# optional deps:
# 1. ccache
find_program(CCACHE ccache)
if(CCACHE)
mark_as_advanced(CCACHE)
message (STATUS "Found ccache: ${CCACHE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}" CACHE STRING "Compiler launcher to use for compiling C++")
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}" CACHE STRING "Compiler launcher to use for compiling C")
endif(CCACHE)
# other optional deps:
# 2. TTG
# N.B. make sure TA configures MADNESS correctly
#if (TA_TTG)
Expand Down
7 changes: 7 additions & 0 deletions external/librett.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ else()
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
endif(CMAKE_TOOLCHAIN_FILE)

foreach(lang C CXX CUDA)
if (DEFINED CMAKE_${lang}_COMPILER_LAUNCHER)
list(APPEND LIBRETT_CMAKE_ARGS
"-DCMAKE_${lang}_COMPILER_LAUNCHER=${CMAKE_${lang}_COMPILER_LAUNCHER}")
endif()
endforeach()

if (BUILD_SHARED_LIBS)
set(LIBRETT_DEFAULT_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
else(BUILD_SHARED_LIBS)
Expand Down
7 changes: 7 additions & 0 deletions external/umpire.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ else()
)
endif(CMAKE_TOOLCHAIN_FILE)

foreach(lang C CXX CUDA)
if (DEFINED CMAKE_${lang}_COMPILER_LAUNCHER)
list(APPEND UMPIRE_CMAKE_ARGS
"-DCMAKE_${lang}_COMPILER_LAUNCHER=${CMAKE_${lang}_COMPILER_LAUNCHER}")
endif()
endforeach()

if (BUILD_SHARED_LIBS)
set(UMPIRE_DEFAULT_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
else(BUILD_SHARED_LIBS)
Expand Down

0 comments on commit 8da57e2

Please sign in to comment.