Skip to content
Open
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
1 change: 0 additions & 1 deletion .git_archival.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=?[0-9.]*)$
ref-names: $Format:%D$
11 changes: 0 additions & 11 deletions .github/dependabot.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"packageRules": [
{
"groupName": "CI and devDependencies",
"matchManagers": ["github-actions", "pre-commit"]
}
],
"separateMajorMinor": false,
"extends": [
"config:recommended",
":dependencyDashboard",
"schedule:weekly",
":enablePreCommit",
":semanticCommitTypeAll(chore)"
]
}
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: CI
run-name: >
CI (${{ github.event_name }})
${{ github.event_name == 'pull_request' && format('PR#{0}', github.event.number) || '' }}

on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
branches: [ main ]
schedule:
- cron: 0 0 * * 3

permissions:
contents: read
Expand All @@ -21,12 +26,9 @@ jobs:
tests:
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml
permissions:
contents: read
checks: write
pull-requests: write

docs:
name: 📘 docs
needs: [ pre-commit ]
uses: ./.github/workflows/step_docs.yaml

Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: release
run-name: Release
name: 🚀 Release
run-name: Release ${{ github.ref_name }}

on:
push:
Expand All @@ -13,22 +13,15 @@ on:
required: true

jobs:
# TODO: tests and docs are not aligned when called from workflow_dispatch :/
pre-commit:
uses: ./.github/workflows/step_pre-commit.yaml
tests:
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml
permissions:
contents: read
checks: write
pull-requests: write
docs:
needs: [ pre-commit ]
uses: ./.github/workflows/step_docs.yaml

release:
needs: [ tests, docs ]
needs: [ tests ]
name: Create release
runs-on: ubuntu-latest
permissions:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/step_docs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
name: docs
run-name: Run documentation tests

on:
workflow_call:

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/step_pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
name: pre-commit
run-name: Run pre-commits

on:
workflow_call:

Expand Down
23 changes: 5 additions & 18 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
name: test
run-name: Run tests

on:
workflow_call:

Expand All @@ -16,28 +13,20 @@ jobs:
strategy:
fail-fast: false
matrix:
cmake: ["3.20", "latest", "latestrc"]
cmake: [ "3.25", "latest", "latestrc" ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Note: Proper solution is: https://github.com/actions/runner/issues/2033#issuecomment-1598547465
- name: Temporary fix for git permissions
run: |
git config --global --add safe.directory "*"
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions Bot"
- name: Setup tmt
uses: LecrisUT/tmt-actions/setup-tmt@v1
- uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ matrix.cmake }}
- name: Build and test native CMake
run: |
# Not running presets because of minimum CMake version being tested
cmake -B ./build
ctest --test-dir ./build --output-on-failure
echo "CMakeExtraUtils_ROOT=$(pwd)/build" >> $GITHUB_ENV
cmake --workflow --preset default --fresh
echo "CMakeExtraUtils_ROOT=$(pwd)/cmake-build-release" >> $GITHUB_ENV
# TODO: This will be migrated to standalone actions
- name: Run tmt tests
uses: LecrisUT/tmt-actions/run-tmt@v1
Expand All @@ -47,10 +36,6 @@ jobs:
report:
name: Report JUnit
needs: [ tests ]
permissions:
contents: read
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Download test results
Expand All @@ -62,4 +47,6 @@ jobs:
large_files: true
report_individual_runs: true
report_suite_logs: any
comment_mode: off
check_run: false
if: always()
133 changes: 54 additions & 79 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Minimum version follows the current Ubuntu LTS and RHEL version
cmake_minimum_required(VERSION 3.20)
if (POLICY CMP0140)
# Enable using return(PROPAGATE)
# TODO: Remove when cmake 3.25 is commonly distributed
cmake_policy(SET CMP0140 NEW)
endif ()
cmake_minimum_required(VERSION 3.25...3.30)

#[==============================================================================================[
# Basic project definition #
Expand All @@ -16,26 +11,15 @@ list(APPEND CMAKE_MESSAGE_CONTEXT CMakeExtraUtils)
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(DynamicVersion)
dynamic_version(PROJECT_PREFIX CMakeExtraUtils_
FALLBACK_VERSION 0.0.0
FALLBACK_VERSION 0.0.0
)

project(CMakeExtraUtils
VERSION ${PROJECT_VERSION}
DESCRIPTION "Extra utilities for cmake"
HOMEPAGE_URL https://github.com/LecrisUT/CmakeExtraUtils
LANGUAGES NONE
VERSION ${PROJECT_VERSION}
DESCRIPTION "Extra utilities for cmake"
HOMEPAGE_URL https://github.com/LecrisUT/CmakeExtraUtils
LANGUAGES NONE
)
# Back-porting to PROJECT_IS_TOP_LEVEL to older cmake
# TODO: Remove when requiring cmake >= 3.21
if (NOT DEFINED CMakeExtraUtils_IS_TOP_LEVEL)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(PROJECT_IS_TOP_LEVEL ON)
set(CMakeExtraUtils_IS_TOP_LEVEL ON)
else ()
set(PROJECT_IS_TOP_LEVEL OFF)
set(CMakeExtraUtils_IS_TOP_LEVEL_IS_TOP_LEVEL OFF)
endif ()
endif ()


#[==============================================================================================[
Expand All @@ -50,10 +34,10 @@ option(CMAKEEXTRAUTILS_INSTALL "CMakeExtraUtils: Install project files" ${PROJEC
]==============================================================================================]

if (CMAKEEXTRAUTILS_INSTALL)
include(CMakePackageConfigHelpers)
if (UNIX)
include(GNUInstallDirs)
endif ()
include(CMakePackageConfigHelpers)
if (UNIX)
include(GNUInstallDirs)
endif ()
endif ()

#[==============================================================================================[
Expand All @@ -69,19 +53,19 @@ endif ()
# Copy the module files to build directory
# This is needed to make the scripts importable by ${builddir}/CMakeExtraUtilsConfig.cmake
foreach (module IN ITEMS
DynamicVersion
PackageComps
DynamicVersion
PackageComps
)
configure_file(
${PROJECT_SOURCE_DIR}/cmake/${module}.cmake
${CMAKE_CURRENT_BINARY_DIR}/${module}.cmake
COPYONLY
)
configure_file(
${PROJECT_SOURCE_DIR}/cmake/${module}.cmake
${CMAKE_CURRENT_BINARY_DIR}/${module}.cmake
COPYONLY
)
endforeach ()

if (CMAKEEXTRAUTILS_TESTS)
enable_testing()
add_subdirectory(test)
enable_testing()
add_subdirectory(test)
endif ()

#[==============================================================================================[
Expand All @@ -90,52 +74,43 @@ endif ()

# Install package files
if (CMAKEEXTRAUTILS_INSTALL)
# Will show developer warning, but can't supress it :(
# Package files
write_basic_package_version_file(
CMakeExtraUtilsConfigVersion.cmake
VERSION ${PROJECT_VERSION}
# TODO: Currently unstable api, change when v1.0 is released
COMPATIBILITY SameMinorVersion
ARCH_INDEPENDENT
)
configure_package_config_file(
cmake/CMakeExtraUtilsConfig.cmake.in
CMakeExtraUtilsConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/CMakeExtraUtilsConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/CMakeExtraUtilsConfig.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
)
# Bundled cmake files
install(FILES
cmake/DynamicVersion.cmake
cmake/PackageComps.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
)
# Will show developer warning, but can't supress it :(
# Package files
write_basic_package_version_file(
CMakeExtraUtilsConfigVersion.cmake
VERSION ${PROJECT_VERSION}
# TODO: Currently unstable api, change when v1.0 is released
COMPATIBILITY SameMinorVersion
ARCH_INDEPENDENT
)
configure_package_config_file(
cmake/CMakeExtraUtilsConfig.cmake.in
CMakeExtraUtilsConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/CMakeExtraUtilsConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/CMakeExtraUtilsConfig.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
)
# Bundled cmake files
install(FILES
cmake/DynamicVersion.cmake
cmake/PackageComps.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/CMakeExtraUtils
)
endif ()

# Make project available for FetchContent
if (NOT PROJECT_IS_TOP_LEVEL)
# Propagate variables for FetchContent
# All variables have to be consistent with CMakeExtraUtilsConfig.cmake
if (CMAKE_VERSION VERSION_LESS 3.25)
# TODO: Remove when cmake 3.25 is commonly distributed
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} PARENT_SCOPE)
set(CMakeExtraUtils_VERSION ${CMakeExtraUtils_VERSION} PARENT_SCOPE)
set(CMakeExtraUtils_VERSION_MAJOR ${CMakeExtraUtils_VERSION_MAJOR} PARENT_SCOPE)
set(CMakeExtraUtils_VERSION_MINOR ${CMakeExtraUtils_VERSION_MINOR} PARENT_SCOPE)
set(CMakeExtraUtils_VERSION_PATCH ${CMakeExtraUtils_VERSION_PATCH} PARENT_SCOPE)
set(CMakeExtraUtils_VERSION_TWEAK ${CMakeExtraUtils_VERSION_TWEAK} PARENT_SCOPE)
endif ()
return(PROPAGATE
CMAKE_MODULE_PATH
CMakeExtraUtils_VERSION
CMakeExtraUtils_VERSION_MAJOR
CMakeExtraUtils_VERSION_MINOR
CMakeExtraUtils_VERSION_PATCH
CMakeExtraUtils_VERSION_TWEAK
)
# Propagate variables for FetchContent
# All variables have to be consistent with CMakeExtraUtilsConfig.cmake
return(PROPAGATE
CMAKE_MODULE_PATH
CMakeExtraUtils_VERSION
CMakeExtraUtils_VERSION_MAJOR
CMakeExtraUtils_VERSION_MINOR
CMakeExtraUtils_VERSION_PATCH
CMakeExtraUtils_VERSION_TWEAK
)
endif ()
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# CMakeExtraUtils

[![CI Status][ci-badge]][ci-link]
[![Documentation Status][rtd-badge]][rtd-link]

![License Status][license-badge]
![CMake Status][cmake-badge]

<!-- SPHINX-START -->

Extra utilities for cmake:

- [`DynamicVersion`](cmake/DynamicVersion.md)
- [`PackageComps`](cmake/PackageComps.md)
- [`DynamicVersion`]
- [`PackageComps`]

## Installation

Expand Down Expand Up @@ -39,6 +47,8 @@ project(MyProject
VERSION ${PROJECT_VERSION})
```

<!-- SPHINX-END -->

## TODO for v1.0

- [x] Automation:
Expand All @@ -47,3 +57,12 @@ project(MyProject
- [ ] Test coverage:
- [x] `DynamicVersion`
- [ ] `PackageComps`

[ci-badge]: https://github.com/LecrisUT/CmakeExtraUtils/actions/workflows/ci.yaml/badge.svg?branch=main&event=push
[ci-link]: https://github.com/LecrisUT/CmakeExtraUtils/actions/workflows/ci.yaml?query=branch%3Amain+event%3Apush
[cmake-badge]: https://img.shields.io/badge/CMake-3.25-blue?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iTGF5ZXIgMiIgdmlld0JveD0iMCAwIDU0NS41IDU0NS45Ij48cGF0aCBkPSJNNTQ2IDUzNCAyODIgOWwzOSA0MzQgMjI1IDkxeiIgZGF0YS1uYW1lPSJyZWQgcmlnaHQiIHN0eWxlPSJmaWxsOiNmMzI3MzU7c3Ryb2tlLXdpZHRoOjAiLz48cGF0aCBkPSJNNTI1IDU0NiAxNzAgNDAzIDEgNTQ2aDUyNHoiIGRhdGEtbmFtZT0iZ3JlZW4gYm90dG9tIiBzdHlsZT0ic3Ryb2tlLXdpZHRoOjA7ZmlsbDojM2VhZTJiIi8+PHBhdGggZD0iTTI2MyAwIDAgNTIybDI4OC0yNDRMMjYzIDB6IiBkYXRhLW5hbWU9ImJsdWUgbGVmdCIgc3R5bGU9ImZpbGw6IzAwNjhjNztzdHJva2Utd2lkdGg6MCIvPjxwYXRoIGQ9Im0yOTEgMjk5LTEwNSA4OSAxMTcgNDgtMTItMTM3eiIgZGF0YS1uYW1lPSJncmF5IGNlbnRlciIgc3R5bGU9ImZpbGw6I2RjZTNlYztzdHJva2Utd2lkdGg6MCIvPjwvc3ZnPg==
[license-badge]: https://img.shields.io/github/license/LecrisUT/CmakeExtraUtils
[rtd-badge]: https://img.shields.io/readthedocs/cmakeextrautils
[rtd-link]: https://cmakeextrautils.readthedocs.io/en/latest/?badge=latest
[`dynamicversion`]: cmake/DynamicVersion.md
[`packagecomps`]: cmake/PackageComps.md
Loading