diff --git a/.github/workflows/build-linux-arm64.yml b/.github/workflows/build-linux-arm64.yml index e38c6fbe..89005d1d 100644 --- a/.github/workflows/build-linux-arm64.yml +++ b/.github/workflows/build-linux-arm64.yml @@ -27,7 +27,10 @@ jobs: - name: Cache SDK Folder uses: actions/cache@v4 with: - path: ${{ github.workspace }}/build/sdk + path: | + ${{ github.workspace }}/build/.ccache + ${{ github.workspace }}/build/sdk + ${{ github.workspace }}/build/bin key: ${{ runner.os }}-${{ runner.arch }}-sdk - uses: actions/setup-python@v5 diff --git a/.github/workflows/build-linux-intel.yml b/.github/workflows/build-linux-intel.yml index 465e6c5e..1d530dc6 100644 --- a/.github/workflows/build-linux-intel.yml +++ b/.github/workflows/build-linux-intel.yml @@ -27,7 +27,10 @@ jobs: - name: Cache SDK Folder uses: actions/cache@v4 with: - path: ${{ github.workspace }}/build/sdk + path: | + ${{ github.workspace }}/build/.ccache + ${{ github.workspace }}/build/sdk + ${{ github.workspace }}/build/bin key: ${{ runner.os }}-${{ runner.arch }}-sdk - uses: actions/setup-python@v5 diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index f5de4d66..1b469ef3 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -26,7 +26,10 @@ jobs: - name: Cache SDK Folder uses: actions/cache@v4 with: - path: ${{ github.workspace }}/build/sdk + path: | + ${{ github.workspace }}/build/.ccache + ${{ github.workspace }}/build/sdk + ${{ github.workspace }}/build/bin key: ${{ runner.os }}-${{ runner.arch }}-sdk - uses: actions/setup-python@v5 diff --git a/.github/workflows/build-macos-intel.yml b/.github/workflows/build-macos-intel.yml index be0b02ff..a18f5803 100644 --- a/.github/workflows/build-macos-intel.yml +++ b/.github/workflows/build-macos-intel.yml @@ -24,7 +24,10 @@ jobs: - name: Cache SDK Folder uses: actions/cache@v4 with: - path: ${{ github.workspace }}/build/sdk + path: | + ${{ github.workspace }}/build/.ccache + ${{ github.workspace }}/build/sdk + ${{ github.workspace }}/build/bin key: ${{ runner.os }}-${{ runner.arch }}-sdk - uses: actions/setup-python@v5 diff --git a/.github/workflows/build-windows-intel.yml b/.github/workflows/build-windows-intel.yml index 369b746f..8b085681 100644 --- a/.github/workflows/build-windows-intel.yml +++ b/.github/workflows/build-windows-intel.yml @@ -24,7 +24,10 @@ jobs: - name: Cache SDK Folder uses: actions/cache@v4 with: - path: ${{ github.workspace }}/build/sdk + path: | + ${{ github.workspace }}/build/.ccache + ${{ github.workspace }}/build/sdk + ${{ github.workspace }}/build/bin key: ${{ runner.os }}-${{ runner.arch }}-sdk - uses: actions/setup-python@v5 diff --git a/CMakeLists.txt b/CMakeLists.txt index ecaf33c5..abc1cd54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ PROJECT(Lethean) set(VERSION "1.0" CACHE STRING "Build version") - message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}") message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}") message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}") @@ -15,6 +14,12 @@ message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}") list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(DocBuilder) +option (USE_CCACHE "Use ccache if a usable instance is found" ON) +if (USE_CCACHE) + include(FindCcache) +else() + message(STATUS "ccache deselected") +endif() if(POLICY CMP0043) cmake_policy(SET CMP0043 NEW) diff --git a/cmake/CleanBuild.cmake b/cmake/CleanBuild.cmake index b0b2473b..2c6616b1 100644 --- a/cmake/CleanBuild.cmake +++ b/cmake/CleanBuild.cmake @@ -21,6 +21,7 @@ function(selective_clean_build_dir) # List of top-level items in the build directory to keep. set(golden_items + "${CMAKE_SOURCE_DIR}/build/.ccache" "${CMAKE_SOURCE_DIR}/build/bin" "${CMAKE_SOURCE_DIR}/build/docs" "${CMAKE_SOURCE_DIR}/build/sdk" diff --git a/cmake/FindCcache.cmake b/cmake/FindCcache.cmake new file mode 100644 index 00000000..47a23cfa --- /dev/null +++ b/cmake/FindCcache.cmake @@ -0,0 +1,26 @@ +find_program(CCACHE_FOUND ccache) +if (CCACHE_FOUND) + # Try to compile a test program with ccache, in order to verify if it really works. (needed on exotic setups) + set(TEST_PROJECT "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp") + file(WRITE "${TEST_PROJECT}/CMakeLists.txt" [=[ +cmake_minimum_required(VERSION 3.10) +project(test) +option (CCACHE "") +file(WRITE "${CMAKE_SOURCE_DIR}/test.cpp" "int main() { return 0; }") +set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache") +set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache") +add_executable(main test.cpp) +]=]) + try_compile(RET "${TEST_PROJECT}/build" "${TEST_PROJECT}" "test" CMAKE_FLAGS -DCCACHE="${CCACHE_FOUND}") + unset(TEST_PROJECT) + if (${RET}) + # Success + message(STATUS "Found usable ccache: ${CCACHE_FOUND}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND} cache_dir=${CMAKE_SOURCE_DIR}/build/.ccache") + else() + message(STATUS "Found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}") + endif() +else() + message(STATUS "ccache NOT found! Please install it for faster rebuilds.") +endif() \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index efed9a7b..e8ae447c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -18,6 +18,8 @@ class BlockchainConan(ConanFile): "testnet": False } + tool_requires = "ccache/4.11" + requires = [ "zlib/1.3.1", "boost/1.85.0",