diff --git a/.github/scripts/setup-sccache.sh b/.github/scripts/setup-sccache.sh new file mode 100755 index 0000000000..008e1b648e --- /dev/null +++ b/.github/scripts/setup-sccache.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +export SCCACHE_VERSION="${SCCACHE_VERSION:=0.9.0}" + +export sccache_arch="x86_64" +if [ "$RUNNER_ARCH" = "X86" ]; then + export sccache_arch="i686" +elif [ "$RUNNER_ARCH" = "X64" ]; then + export sccache_arch="x86_64" +elif [ "$RUNNER_ARCH" = "ARM" ]; then + export sccache_arch="armv7" +elif [ "$RUNNER_ARCH" = "ARM64" ]; then + export sccache_arch="aarch64" +fi + +install_sccache() { + export sccache_archive="sccache-v$SCCACHE_VERSION-$sccache_arch-$sccache_os" + export sccache_url="https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VERSION/$sccache_archive.tar.gz" + + echo "Downloading $sccache_url..." + if ! wget -q "$sccache_url"; then + echo "Can't download $sccache_url.">2 + exit 1 + fi + echo "Extracting $sccache_archive.tar.gz..." + if ! tar -xzf "$sccache_archive.tar.gz" >/dev/null; then + echo "Can't extract $sccache_archive.tar.gz">2 + exit 1 + fi + chmod +x "$sccache_archive/sccache" + sudo cp "$sccache_archive/sccache" "/usr/local/bin/sccache" + rm -rf "$sccache_archive.tar.gz" + rm -rf "$sccache_archive" +} + +export sccache_os="unknown-linux-musl" +if [ "$RUNNER_OS" = "Linux" ]; then + export sccache_os="unknown-linux-musl" + if [ "$RUNNER_ARCH" = "ARM" ]; then + export sccache_os="unknown-linux-musleabi" + fi + if ! install_sccache; then + echo "Unable to install sccache!" >2 + exit 1 + fi +elif [ "$RUNNER_OS" = "macOS" ]; then + export sccache_os="apple-darwin" + if ! install_sccache; then + echo "Unable to install sccache!" >2 + exit 1 + fi +elif [ "$RUNNER_OS" = "Windows" ]; then + export sccache_os="pc-windows-msvc" + if ! install_sccache; then + echo "Unable to install sccache!" >2 + exit 1 + fi +fi + +echo "sccache installed." + +# Configure +mkdir $HOME/.sccache +echo "SCCACHE_DIR=$HOME/.sccache" >> $GITHUB_ENV +if [ "$RUNNER_DEBUG" = "1" ]; then + echo "Running with debug output; cached binary artifacts will be ignored to produce a cleaner build" + echo "SCCACHE_RECACHE=true" >> $GITHUB_ENV +fi + +echo "sccache configured." diff --git a/.github/workflows/build-and-test-linux.yaml b/.github/workflows/build-and-test-linux.yaml index 383a911ab0..8c58e149b5 100644 --- a/.github/workflows/build-and-test-linux.yaml +++ b/.github/workflows/build-and-test-linux.yaml @@ -17,6 +17,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + SCCACHE_VERSION: "0.9.0" + jobs: build: strategy: @@ -85,6 +88,16 @@ jobs: g++ - name: Checkout uses: actions/checkout@v4 + - name: Install sccache + run: .github/scripts/setup-sccache.sh + - name: Load cached compilation artifacts + id: compiler-cache + uses: actions/cache@v4 + with: + path: "${{ env.SCCACHE_DIR }}" + key: sccache-${{ matrix.os }}-${{ matrix.x11 }}-${{ matrix.wayland }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + sccache-${{ matrix.os }}-${{ matrix.x11 }}-${{ matrix.wayland }}-${{ matrix.compiler }}-${{ github.ref }} - name: Configure with CMake run: | set -x # show the commands we're running @@ -100,9 +113,10 @@ jobs: RSVG_ENABLED=ON [[ "${{ matrix.os }}" == "ubuntu-20.04"* ]] && RSVG_ENABLED=OFF - mkdir build - cd build - cmake .. -G Ninja \ + # Reset sccache statistics + sccache --zero-stats + + cmake . -B build -G Ninja \ -DBUILD_AUDACIOUS=ON \ -DBUILD_HTTP=ON \ -DBUILD_ICAL=ON \ @@ -119,7 +133,6 @@ jobs: -DBUILD_PULSEAUDIO=ON \ -DBUILD_CURL=ON \ -DBUILD_RSS=ON \ - -DBUILD_TESTS=ON \ -DBUILD_WLAN=ON \ -DBUILD_WAYLAND=${{ matrix.wayland }}\ -DBUILD_X11=${{ matrix.x11 }} \ @@ -129,6 +142,8 @@ jobs: -DMAINTAINER_MODE=ON - name: Compile run: cmake --build build + - name: Show sccache stats + run: sccache --show-stats - name: Test working-directory: build run: ctest --output-on-failure diff --git a/.github/workflows/build-and-test-macos.yaml b/.github/workflows/build-and-test-macos.yaml index 29c1739bc3..d89de7b6ac 100644 --- a/.github/workflows/build-and-test-macos.yaml +++ b/.github/workflows/build-and-test-macos.yaml @@ -16,6 +16,10 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true + +env: + SCCACHE_VERSION: "0.9.0" + jobs: build: env: @@ -50,18 +54,30 @@ jobs: || true # Ignore errors - name: Checkout uses: actions/checkout@v4 - - run: mkdir build + - name: Configure sccache + run: .github/scripts/setup-sccache.sh + - name: Load cached compilation artifacts + id: compiler-cache + uses: actions/cache@v4 + with: + path: "${{ env.SCCACHE_DIR }}" + key: sccache-${{ matrix.os }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + sccache-${{ matrix.os }}-${{ github.ref }} - name: Configure with CMake - working-directory: build run: | - cmake .. -G Ninja \ + # Reset sccache statistics + sccache --zero-stats + + cmake . -B build -G Ninja \ -DMAINTAINER_MODE=ON \ -DBUILD_WAYLAND=OFF \ -DBUILD_RSS=ON \ - -DBUILD_CURL=ON \ - -DBUILD_TESTS=ON + -DBUILD_CURL=ON - name: Compile run: cmake --build build + - name: Show sccache stats + run: sccache --show-stats - name: Test working-directory: build run: ctest --output-on-failure diff --git a/.github/workflows/publish-appimage.yml b/.github/workflows/publish-appimage.yml index 92d4360c5d..8fdceb68c7 100644 --- a/.github/workflows/publish-appimage.yml +++ b/.github/workflows/publish-appimage.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + SCCACHE_VERSION: "0.9.0" + jobs: build: runs-on: ${{ matrix.os }} @@ -106,10 +109,26 @@ jobs: libc++abi-${CLANG_VERSION}-dev echo "CC=clang-${CLANG_VERSION}" | tee -a $GITHUB_ENV echo "CXX=clang++-${CLANG_VERSION}" | tee -a $GITHUB_ENV + + - name: Install sccache + if: startsWith(github.ref, 'refs/tags/') != true + run: .github/scripts/setup-sccache.sh + - name: Load cached compilation artifacts + if: startsWith(github.ref, 'refs/tags/') != true + id: compiler-cache + uses: actions/cache@v4 + with: + path: "${{ env.SCCACHE_DIR }}" + key: sccache-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + sccache-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref }} - name: Build AppImage run: ./appimage/build.sh env: RELEASE: "${{ startsWith(github.ref, 'refs/tags/') && 'ON' || 'OFF' }}" + - name: Show sccache stats + if: startsWith(github.ref, 'refs/tags/') != true + run: sccache --show-stats - run: ./conky-x86_64.AppImage --version # print version - name: Set CONKY_VERSION run: echo "CONKY_VERSION=$(./conky-x86_64.AppImage --short-version)" | tee -a $GITHUB_ENV diff --git a/3rdparty/Vc/CMakeLists.txt b/3rdparty/Vc/CMakeLists.txt index 568179e450..8d343150ee 100644 --- a/3rdparty/Vc/CMakeLists.txt +++ b/3rdparty/Vc/CMakeLists.txt @@ -37,15 +37,6 @@ else() message(WARNING "No optimized implementation of the Vc types available for ${CMAKE_SYSTEM_PROCESSOR}") endif() -option(USE_CCACHE "If enabled, ccache will be used (if it exists on the system) to speed up recompiles." OFF) -if(USE_CCACHE) - find_program(CCACHE_COMMAND ccache) - if(CCACHE_COMMAND) - mark_as_advanced(CCACHE_COMMAND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_COMMAND}") - endif() -endif() - if(NOT Vc_COMPILER_IS_MSVC) AddCompilerFlag("-std=c++14" CXX_RESULT _ok CXX_FLAGS CMAKE_CXX_FLAGS) if(NOT _ok) diff --git a/3rdparty/Vc/cmake/OptimizeForArchitecture.cmake b/3rdparty/Vc/cmake/OptimizeForArchitecture.cmake index e169944f1a..459f396187 100644 --- a/3rdparty/Vc/cmake/OptimizeForArchitecture.cmake +++ b/3rdparty/Vc/cmake/OptimizeForArchitecture.cmake @@ -70,7 +70,10 @@ macro(AutodetectHostArchitecture) string(REGEX REPLACE ".*model[ \t]*:[ \t]+([a-zA-Z0-9_-]+).*" "\\1" _cpu_model "${_cpuinfo}") string(REGEX REPLACE ".*flags[ \t]*:[ \t]+([^\n]+).*" "\\1" _cpu_flags "${_cpuinfo}") elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - exec_program("/usr/sbin/sysctl -n machdep.cpu.vendor machdep.cpu.model machdep.cpu.family machdep.cpu.features" OUTPUT_VARIABLE _sysctl_output_string) + execute_process(COMMAND "/usr/sbin/sysctl" -n machdep.cpu.vendor machdep.cpu.model machdep.cpu.family machdep.cpu.features + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _sysctl_output_string) + mark_as_advanced(_sysctl_output_string) string(REPLACE "\n" ";" _sysctl_output ${_sysctl_output_string}) list(GET _sysctl_output 0 _vendor_id) list(GET _sysctl_output 1 _cpu_model) diff --git a/3rdparty/Vc/cmake/VcMacros.cmake b/3rdparty/Vc/cmake/VcMacros.cmake index c857678c49..1a329b0366 100644 --- a/3rdparty/Vc/cmake/VcMacros.cmake +++ b/3rdparty/Vc/cmake/VcMacros.cmake @@ -41,7 +41,9 @@ include("${_currentDir}/OptimizeForArchitecture.cmake") macro(vc_determine_compiler) if(NOT DEFINED Vc_COMPILER_IS_INTEL) - execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE _cxx_compiler_version ERROR_VARIABLE _cxx_compiler_version) + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" + OUTPUT_VARIABLE _cxx_compiler_version + ERROR_VARIABLE _cxx_compiler_version) set(Vc_COMPILER_IS_INTEL false) set(Vc_COMPILER_IS_OPEN64 false) set(Vc_COMPILER_IS_CLANG false) @@ -50,7 +52,8 @@ macro(vc_determine_compiler) if(CMAKE_CXX_COMPILER MATCHES "/(icpc|icc)$") set(Vc_COMPILER_IS_INTEL true) - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE Vc_ICC_VERSION) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion + OUTPUT_VARIABLE Vc_ICC_VERSION) message(STATUS "Detected Compiler: Intel ${Vc_ICC_VERSION}") # break build with too old clang as early as possible. @@ -62,7 +65,8 @@ macro(vc_determine_compiler) message(STATUS "Detected Compiler: Open64") elseif(CMAKE_CXX_COMPILER MATCHES "clang\\+\\+$" OR "${_cxx_compiler_version}" MATCHES "clang") set(Vc_COMPILER_IS_CLANG true) - exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE Vc_CLANG_VERSION) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version + OUTPUT_VARIABLE Vc_CLANG_VERSION) string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" Vc_CLANG_VERSION "${Vc_CLANG_VERSION}") message(STATUS "Detected Compiler: Clang ${Vc_CLANG_VERSION}") @@ -75,13 +79,15 @@ macro(vc_determine_compiler) message(STATUS "Detected Compiler: MSVC ${MSVC_VERSION}") elseif(CMAKE_COMPILER_IS_GNUCXX) set(Vc_COMPILER_IS_GCC true) - exec_program(${CMAKE_CXX_COMPILER} ARGS -dumpversion OUTPUT_VARIABLE Vc_GCC_VERSION) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} ARGS -dumpversion + OUTPUT_VARIABLE Vc_GCC_VERSION) message(STATUS "Detected Compiler: GCC ${Vc_GCC_VERSION}") # some distributions patch their GCC to return nothing or only major and minor version on -dumpversion. # In that case we must extract the version number from --version. if(NOT Vc_GCC_VERSION OR Vc_GCC_VERSION MATCHES "^[0-9]\\.[0-9]+$") - exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE Vc_GCC_VERSION) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} ARGS --version + OUTPUT_VARIABLE Vc_GCC_VERSION) string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" Vc_GCC_VERSION "${Vc_GCC_VERSION}") message(STATUS "GCC Version from --version: ${Vc_GCC_VERSION}") endif() @@ -93,21 +99,29 @@ macro(vc_determine_compiler) if(Vc_lsb_release) if(NOT Vc_distributor_id) - execute_process(COMMAND ${Vc_lsb_release} -is OUTPUT_VARIABLE Vc_distributor_id OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${Vc_lsb_release} -is + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE Vc_distributor_id) string(TOUPPER "${Vc_distributor_id}" Vc_distributor_id) set(Vc_distributor_id "${Vc_distributor_id}" CACHE STRING "lsb distribution id") - execute_process(COMMAND ${Vc_lsb_release} -rs OUTPUT_VARIABLE Vc_distributor_release OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${Vc_lsb_release} -rs + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE Vc_distributor_release) set(Vc_distributor_release "${Vc_distributor_release}" CACHE STRING "lsb release id") endif() if(Vc_distributor_id STREQUAL "UBUNTU") - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _gcc_version) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _gcc_version) string(REGEX MATCH "\\(.* ${Vc_GCC_VERSION}-([0-9]+).*\\)" _tmp "${_gcc_version}") if(_tmp) set(_patch ${CMAKE_MATCH_1}) string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _tmp "${Vc_distributor_release}") - execute_process(COMMAND printf 0x%x%02x%02x ${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${_patch} OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE _tmp) + execute_process(COMMAND printf 0x%x%02x%02x ${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${_patch} + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _tmp) set(Vc_DEFINITIONS "${Vc_DEFINITIONS} -D__GNUC_UBUNTU_VERSION__=${_tmp}") endif() endif() @@ -151,15 +165,19 @@ macro(vc_add_compiler_flag VAR _flag) endmacro() macro(vc_check_assembler) - exec_program(${CMAKE_CXX_COMPILER} ARGS -print-prog-name=as OUTPUT_VARIABLE _as) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-prog-name=as + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _as) mark_as_advanced(_as) if(NOT _as) message(WARNING "Could not find 'as', the assembler used by GCC. Hoping everything will work out...") else() - exec_program(${_as} ARGS --version OUTPUT_VARIABLE _as_version) + execute_process(COMMAND ${_as} --version + OUTPUT_VARIABLE _as_version) string(REGEX REPLACE "\\([^\\)]*\\)" "" _as_version "${_as_version}") string(REGEX MATCH "[1-9]\\.[0-9]+(\\.[0-9]+)?" _as_version "${_as_version}") + message(STATUS "Detected assembler: ${_as} ${_as_version}") if(_as_version VERSION_LESS "2.18.93") UserWarning("Your binutils is too old (${_as_version}). Some optimizations of Vc will be disabled.") diff --git a/CMakeLists.txt b/CMakeLists.txt index a83b3ff3d4..c68f65334e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,9 @@ include(ConkyPlatformChecks) # CPack module for installation tasks include(ConkyCPackSetup) +# Use compilation cache (if enabled) +include(CCache) + # setup our configuration headers configure_file(${CMAKE_MODULE_PATH}/config.h.in ${CMAKE_BINARY_DIR}/config.h) configure_file(${CMAKE_MODULE_PATH}/build.h.in ${CMAKE_BINARY_DIR}/build.h) @@ -61,7 +64,7 @@ if(BUILD_EXTRAS) add_subdirectory(extras) endif(BUILD_EXTRAS) -if(BUILD_TESTS) +if(BUILD_TESTING) if(CODE_COVERAGE) # Enable coverage checks include(CodeCoverage) @@ -73,7 +76,7 @@ endif() add_subdirectory(src) -if(BUILD_TESTS) +if(BUILD_TESTING) add_subdirectory(tests) enable_testing() endif() diff --git a/cmake/CCache.cmake b/cmake/CCache.cmake new file mode 100644 index 0000000000..1dd5d34301 --- /dev/null +++ b/cmake/CCache.cmake @@ -0,0 +1,22 @@ +if(NOT USE_CCACHE) + return() +endif() + +find_program(CCACHE_COMMAND sccache) +if(CCACHE_COMMAND) + mark_as_advanced(CCACHE_COMMAND) + message(STATUS "Using sccache; disable with '-DUSE_CCACHE=OFF'") +else() + find_program(CCACHE_COMMAND ccache) + if(CCACHE_COMMAND) + mark_as_advanced(CCACHE_COMMAND) + message(STATUS "Using ccache; disable with '-DUSE_CCACHE=OFF'") + else() + message(WARNING "Neither sccache nor ccache found") + return() + endif() +endif() + +set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_COMMAND}") +set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}") +set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_COMMAND}") diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index 5fbf5bc924..404a6ff4dd 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -21,8 +21,18 @@ include(CMakeDependentOption) include(DependentOption) +# This flag is for developers of conky and automated tests in conky repository. +# It should not be enabled by package maintainers as produced binary is -O0. +option(MAINTAINER_MODE "Use defaults for development environment (debug, testing, etc.)" false) +option(BUILD_TESTING "Build test binary" ${MAINTAINER_MODE}) +cmake_dependent_option(RUN_TESTS "Run tests once the build is complete" false + "BUILD_TESTING" false) +# Use gcov (requires LLVM compiler) to generate code coverage +option(CODE_COVERAGE "Enable code coverage report generation" false) + if(NOT CMAKE_BUILD_TYPE) if(MAINTAINER_MODE) + message(WARNING "Default build type: Debug (because MAINTAINER_MODE is set)") set( CMAKE_BUILD_TYPE Debug CACHE @@ -30,6 +40,7 @@ if(NOT CMAKE_BUILD_TYPE) "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) else(MAINTAINER_MODE) + message(STATUS "Default build type: RelWithDebInfo") set( CMAKE_BUILD_TYPE RelWithDebInfo CACHE @@ -44,11 +55,7 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) - -if(MAINTAINER_MODE) - set(CMAKE_COMPILE_WARNING_AS_ERROR true) - set(BUILD_TESTS true) -endif(MAINTAINER_MODE) +set(CMAKE_COMPILE_WARNING_AS_ERROR ${MAINTAINER_MODE}) if(NOT OS_OPENBSD) # Always use libc++ when compiling w/ clang @@ -62,20 +69,32 @@ add_compile_options( $<$:-Wno-unknown-warning-option> $<$:-Wno-unknown-warning>) -option(CHECK_CODE_QUALITY "Check code formatting/quality with clang" false) +# Makes builds fully reproducible for environments (such as NixOS) that prefer +# building the binary from a clean slate. This makes build defaults and process +# avoid optimizations like compiler caching and reusing already built files. +option(REPRODUCIBLE_BUILD "Makes builds fully reproducible" OFF) + +if(REPRODUCIBLE_BUILD) + set(USE_CCACHE_DEFAULT OFF) +else() + set(USE_CCACHE_DEFAULT ON) +endif() +mark_as_advanced(USE_CCACHE_DEFAULT) +# Instead of rebuilding objects from scratch, the compiler will reuse cached +# parts of compilation in order to speed up compilation. +option(USE_CCACHE "Sccache/ccache will be used (if installed) to speed up compilation" ${USE_CCACHE_DEFAULT}) + +option(CHECK_CODE_QUALITY "Check code formatting/quality with clang" ${MAINTAINER_MODE}) option(RELEASE "Build release package" false) mark_as_advanced(RELEASE) -option(MAINTAINER_MODE "Enable maintainer mode" false) -option(CODE_COVERAGE "Enable code coverage report generation" false) - option(BUILD_DOCS "Build documentation" false) option(BUILD_EXTRAS "Build extras (includes syntax files for editors)" false) option(BUILD_I18N "Enable if you want internationalization support" true) -option(BUILD_COLOUR_NAME_MAP "Include mappings of colour name -> RGB (i.e., red -> ff0000)" true) +option(BUILD_COLOUR_NAME_MAP "Include mappings of colour name -> RGB (e.g. red -> ff0000)" true) if(BUILD_I18N) set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 03c8885240..d9e322359b 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -56,6 +56,13 @@ set(conky_libs ${conky_libs} ${CLOCK_GETTIME_LIB}) # standard path to search for includes set(INCLUDE_SEARCH_PATH /usr/include /usr/local/include) +# Detect CI +if(DEFINED ENV{CI}) + # For GitHub actions CI=true is set + set(ENV_IS_CI true) + mark_as_advanced(ENV_IS_CI) +endif() + # Set system vars if(CMAKE_SYSTEM_NAME MATCHES "Linux") set(OS_LINUX true) diff --git a/cmake/UninstallConky.cmake.in b/cmake/UninstallConky.cmake.in index 349bcce41f..4e76d89cef 100644 --- a/cmake/UninstallConky.cmake.in +++ b/cmake/UninstallConky.cmake.in @@ -20,27 +20,22 @@ # if (NOT EXISTS ${CMAKE_BINARY_DIR} / install_manifest.txt) -message( - FATAL_ERROR - "Cannot find install manifest: ${CMAKE_BINARY_DIR}/install_manifest.txt") - endif() + message(FATAL_ERROR "Cannot find install manifest: ${CMAKE_BINARY_DIR}/install_manifest.txt") +endif() + +file(READ "${CMAKE_BINARY_DIR}/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") - file(READ "${CMAKE_BINARY_DIR}/install_manifest.txt" files) string( - REGEX REPLACE - "\n" - ";" files "${files}") foreach (file ${files}) - message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if ( - IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS - "$ENV{DESTDIR}${file}") - exec_program( - ${CMAKE_COMMAND} ARGS - "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval) if (NOT - "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR - "Problem when removing $ENV{DESTDIR}${file}") - endif() else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS - "$ENV{DESTDIR}${file}") - message(STATUS - "File $ENV{DESTDIR}${file} does not exist.") - endif() endforeach() +foreach (file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + execute_process(COMMAND ${CMAKE_COMMAND} "-E" "remove" "\"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval) + if (NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif() + else() + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach() diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake index 755ed67c8a..4a883a5ff8 100644 --- a/cmake/clang-tidy.cmake +++ b/cmake/clang-tidy.cmake @@ -1,7 +1,7 @@ get_target_property(ClangTidy_SRCS_TMP conky SOURCES) get_target_property(conky_SRC_DIR conky SOURCE_DIR) -if(BUILD_TESTS) +if(BUILD_TESTING) get_target_property(ClangTidy_SRCS_TMP_CORE conky_core SOURCES) list(APPEND ClangTidy_SRCS_TMP ${ClangTidy_SRCS_TMP_CORE}) endif() diff --git a/flake.nix b/flake.nix index 0da4eb9a7d..f7ce20d6df 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,7 @@ "-DBUILD_LUA_IMLIB2=ON" "-DBUILD_LUA_RSVG=ON" "-DBUILD_RSS=ON" + "-DREPRODUCIBLE_BUILD=ON" ]; nativeBuildInputs = [ clang_18 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d8b46f133e..486b877d6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -404,7 +404,7 @@ if(BUILD_INTEL_BACKLIGHT) set(optional_sources ${optional_sources} ${intel_backlight}) endif(BUILD_INTEL_BACKLIGHT) -if(BUILD_TESTS) +if(BUILD_TESTING) # Create a library strictly for testing add_library(conky_core ${conky_sources} ${optional_sources}) add_dependencies(conky_core generated_hdr_files) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 76a7a8ad21..05fc413e83 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,6 +23,12 @@ target_link_libraries(test-conky ) catch_discover_tests(test-conky) +if(RUN_TESTS) + add_custom_command(TARGET test-conky + POST_BUILD + COMMAND ctest -C $ --output-on-failure) +endif() + if(CODE_COVERAGE) set(COVERAGE_LCOV_EXCLUDES "*/include/c++/v1/*"