From 412730f86679d7ccd350cadf5649b7a489376cae Mon Sep 17 00:00:00 2001 From: Abdessattar Sassi <457645+abdes@users.noreply.github.com> Date: Thu, 31 Mar 2022 13:17:53 +0400 Subject: [PATCH 1/3] feat: make ccache usable on all platforms --- CMakeLists.txt | 8 ++------ cmake/FasterBuild.cmake | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 cmake/FasterBuild.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b33c9a9..d74508e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cmake/FasterBuild.cmake b/cmake/FasterBuild.cmake new file mode 100644 index 0000000..a0f2536 --- /dev/null +++ b/cmake/FasterBuild.cmake @@ -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() From b34fb1bec76b32b9e1a755197976e17e93b9465c Mon Sep 17 00:00:00 2001 From: Abdessattar Sassi <457645+abdes@users.noreply.github.com> Date: Thu, 31 Mar 2022 16:48:51 +0400 Subject: [PATCH 2/3] chore: put CPM cache in user's home dir --- CMakePresets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 38a67d6..73320e2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,10 +15,10 @@ "installDir": "${sourceDir}/out/install/${presetName}", "environment": { "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "CPM_SOURCE_CACHE": "$env{HOME}/.cache/CPM", "caexcludepath": "${sourceDir}/third_party;${sourceDir}/out" }, "cacheVariables": { + "CPM_SOURCE_CACHE": "~/.cache/CPM", "USE_CCACHE": "ON", "ASAP_BUILD_TESTS": "ON", "ASAP_BUILD_EXAMPLES": "ON" @@ -432,4 +432,4 @@ "configurePreset": "dev-gcc" } ] -} \ No newline at end of file +} From 227de026878beb9dd9679d0cad12cf25bce16c4a Mon Sep 17 00:00:00 2001 From: Abdessattar Sassi <457645+abdes@users.noreply.github.com> Date: Sun, 3 Apr 2022 22:59:25 +0400 Subject: [PATCH 3/3] fix: use only white-listed properties for interface library --- cmake/AsapTargets.cmake | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cmake/AsapTargets.cmake b/cmake/AsapTargets.cmake index ed8040c..92ce110 100644 --- a/cmake/AsapTargets.cmake +++ b/cmake/AsapTargets.cmake @@ -80,8 +80,11 @@ endfunction() function(_module_pkgconfig_files) set(MODULE_PKGCONFIG_FILE ${MODULE_TARGET_NAME}.pc) - get_target_property(TARGET_DEBUG_POSTFIX ${MODULE_TARGET_NAME} DEBUG_POSTFIX) - set(MODULE_LINK_LIBS "-l${MODULE_TARGET_NAME}${TARGET_DEBUG_POSTFIX}") + if(NOT ${type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(TARGET_DEBUG_POSTFIX ${MODULE_TARGET_NAME} + DEBUG_POSTFIX) + set(MODULE_LINK_LIBS "-l${MODULE_TARGET_NAME}${TARGET_DEBUG_POSTFIX}") + endif() configure_file(config.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_PKGCONFIG_FILE} @ONLY) if(${META_PROJECT_ID}_INSTALL) @@ -112,16 +115,16 @@ function(asap_add_library target) asap_set_compile_definitions(${target}) # Generate export headers for the library asap_generate_export_headers(${target} ${META_MODULE_NAME}) - endif() - set_target_properties( - ${target} - PROPERTIES FOLDER "Libraries" - VERSION ${META_MODULE_VERSION} - SOVERSION ${META_MODULE_VERSION_MAJOR} - DEBUG_POSTFIX "d" - CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN YES) + set_target_properties( + ${target} + PROPERTIES FOLDER "Libraries" + VERSION ${META_MODULE_VERSION} + SOVERSION ${META_MODULE_VERSION_MAJOR} + DEBUG_POSTFIX "d" + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN YES) + endif() endfunction() function(asap_add_executable target)