Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export cmake config package #23

Open
wants to merge 28 commits into
base: verify_headers
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
83c9a98
Add verify to build presets
steve-downey Nov 10, 2024
c429662
Export cmake config package
ClausKlein Nov 20, 2024
73fde6b
Add find-package-test
ClausKlein Nov 20, 2024
e530c3f
Restructure cmake preset
ClausKlein Dec 6, 2024
aa94639
Trigger find-packge-test
ClausKlein Dec 6, 2024
72f4370
Test to find installed package on CI too
ClausKlein Dec 6, 2024
b29852d
Add missing Debug build type for CI
ClausKlein Dec 6, 2024
b70856b
Setup that test depends on all
ClausKlein Dec 6, 2024
405286d
Use cmake workflow preset on CI
ClausKlein Dec 7, 2024
37b2991
Use right toolchain for preset name
ClausKlein Dec 7, 2024
c0f2538
It seems clang-17 builds only with -std=c++20 ?
ClausKlein Dec 7, 2024
183e933
Add support for Coveralls to CI
ednolan Dec 9, 2024
5765b9d
Merge pull request #87 from bemanproject/enolan_coveralls
ednolan Dec 9, 2024
be88ef6
Merge branch 'main' into feature/export-config-package
ClausKlein Dec 10, 2024
fb64c34
Fix merge problems
ClausKlein Dec 10, 2024
ed7235f
remove unuseed .cmakg-format
wusatosi Dec 10, 2024
7e886f9
add back shell-check
wusatosi Dec 10, 2024
a27baaf
add back codespell
wusatosi Dec 10, 2024
9412778
Revert "add back shell-check"
wusatosi Dec 10, 2024
326c060
remove shell check
wusatosi Dec 10, 2024
19a5e5f
update pre-commit dependency
wusatosi Dec 10, 2024
553f284
Fix typo in CMakePresets.json
camio Dec 11, 2024
de6cfd6
fix git blame ignore
wusatosi Dec 11, 2024
f6ffaea
Merge pull request #90 from wusatosi/blame-fix
steve-downey Dec 11, 2024
db756d0
Merge pull request #88 from wusatosi/cleanup
wusatosi Dec 12, 2024
9e0c8f7
Merge pull request #89 from bemanproject/camio-patch-1
neatudarius Dec 12, 2024
0302fc1
Merge branch 'main' into feature/export-config-package
ClausKlein Dec 12, 2024
0505f9c
Validate and format json files too
ClausKlein Dec 12, 2024
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
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
Language: Json
IndentWidth: 2
---
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
Expand Down
85 changes: 0 additions & 85 deletions .cmake-format.json

This file was deleted.

2 changes: 1 addition & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
907e040
907e0406400ad008db3f724e8d255239471155b0
43 changes: 38 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
fail-fast: false
matrix:
config:
- {name: "Ubuntu Clang 20", os: ubuntu-24.04, toolchain: "clang-20", clang_version: 20, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu Clang 20", os: ubuntu-24.04, toolchain: "clang-20", clang_version: 20, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Debug;Asan\" "}
# Note: clang-19 + Asan setup causes errors on some platforms. Temporary skip some checks via .asan_options.
- {name: "Ubuntu Clang 19", os: ubuntu-24.04, toolchain: "clang-19", clang_version: 19, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" ", asan_options: "new_delete_type_mismatch=0"}
- {name: "Ubuntu Clang 18", os: ubuntu-24.04, toolchain: "clang-18", clang_version: 18, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu Clang 17", os: ubuntu-24.04, toolchain: "clang-17", clang_version: 17, installed_clang_version: 17, cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu GCC 14", os: ubuntu-24.04, toolchain: "gcc-14", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu GCC 13", os: ubuntu-24.04, toolchain: "gcc-13", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu GCC 12", os: ubuntu-24.04, toolchain: "gcc-12", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu GCC 14", os: ubuntu-24.04, toolchain: "gcc-14", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan;Gcov\" ", coverage: true}
- {name: "Ubuntu GCC 13", os: ubuntu-24.04, toolchain: "gcc-13", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
- {name: "Ubuntu GCC 12", os: ubuntu-24.04, toolchain: "gcc-12", cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" "}
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -64,6 +64,7 @@ jobs:
[[ ${CLANG_VERSION} = 17 ]] && sudo apt-get install libc++-dev libc++1 libc++abi-dev libc++abi1
find /usr/lib/x86_64-linux-gnu/ -name libc++.so* || true
clang++-${CLANG_VERSION} --version
type clang++-${CLANG_VERSION}
- name: Install GCC
if: startsWith(matrix.config.name, 'Ubuntu GCC')
run: |
Expand All @@ -77,13 +78,19 @@ jobs:
sudo apt-get install g++-${GCC_VERSION} gcc-${GCC_VERSION}
find /usr/lib/x86_64-linux-gnu/ -name libstdc++.so*
g++-${GCC_VERSION} --version
type g++-${GCC_VERSION}
- name: Install Gcovr
if: matrix.config.coverage
run: |
set -x
sudo apt-get install gcovr
- name: CMake Configure
run: |
set -x
echo ${{ matrix.config.cmake_args }}
echo ${{ matrix.config.toolchain }}
rm -rf .build
cmake ${{ matrix.config.cmake_args }} -DCMAKE_INSTALL_PREFIX=.install -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
cmake ${{ matrix.config.cmake_args }} -DCMAKE_INSTALL_PREFIX=.install -DCMAKE_PREFIX_PATH=.install -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
- name: CMake ASAN Build
run: |
set -x
Expand All @@ -107,3 +114,29 @@ jobs:
run: |
set -x
cmake --install .build --config RelWithDebInfo --component beman_optional26_development --verbose
- name: CMake Gcov Build
if: matrix.config.coverage
run: |
set -x
cmake --build .build --config Gcov --target all_verify_interface_header_sets -- -k 0
cmake --build .build --config Gcov --target all -- -k 0
- name: CMake Gcov Test
if: matrix.config.coverage
run: |
set -x
ctest --build-config Gcov --output-on-failure --test-dir .build
- name: Generate Coverage
if: matrix.config.coverage
run: |
set -x
cmake --build .build --config Gcov --target process_coverage -- -k 0
- name: Coveralls
if: matrix.config.coverage
uses: coverallsapp/github-action@main
with:
file: ${{runner.workspace}}/optional26/.build/coverage.json
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: CMake Debug Workflow
run: |
set -x
cmake --workflow --preset ${{ matrix.config.toolchain }}
19 changes: 16 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
exclude: ^\.clang-format$
- id: check-added-large-files

# Clang-format for C++
Expand All @@ -16,19 +18,30 @@ repos:
rev: v18.1.8
hooks:
- id: clang-format
types_or: [c++, c]
types_or: [c++, c, json]

# CMake linting and formatting
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.15.1
rev: 0.17.0
hooks:
- id: gersemi
name: CMake linting

# Markdown linting
# Config file: .markdownlint.yaml
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.43.0
hooks:
- id: markdownlint
exclude: ^papers/

# Config file: .codespell_ignore
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ['-I', '.codespell_ignore', '--uri-ignore-words-list']
exclude: |
(?x)^(
papers/.*
)$
4 changes: 0 additions & 4 deletions .shellcheckrc

This file was deleted.

44 changes: 28 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 3.27)
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE)

project(beman_optional26 VERSION 0.0.0 LANGUAGES CXX)
cmake_minimum_required(VERSION 3.29...3.31)

project(beman_optional26 VERSION 0.0.1 LANGUAGES CXX)

# Includes
include(CTest)
include(FetchContent)
include(CPack)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
set(TARGET_PACKAGE_NAME ${PROJECT_NAME})
set(TARGETS_EXPORT_NAME ${TARGET_PACKAGE_NAME}-targets)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_PACKAGE_NAME})

option(
OPTIONAL26_ENABLE_TESTING
Expand All @@ -20,6 +25,8 @@ option(

# Build the tests if enabled via the option OPTIONAL26_ENABLE_TESTING
if(OPTIONAL26_ENABLE_TESTING)
include(FetchContent)

# Fetch GoogleTest
FetchContent_Declare(
googletest
Expand All @@ -29,12 +36,15 @@ if(OPTIONAL26_ENABLE_TESTING)
e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0
)
FetchContent_MakeAvailable(googletest)

enable_testing()
endif()

set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)

# Create the library target and named header set for beman_optional26
add_library(beman_optional26 INTERFACE)
add_library(Beman::Optional26::beman_optional26 ALIAS beman_optional26)
target_sources(
beman_optional26
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS include
Expand All @@ -59,23 +69,24 @@ add_subdirectory(include/beman/optional26)

add_subdirectory(examples)

include(CMakePackageConfigHelpers)
# install
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

# This will be used to replace @PACKAGE_cmakeModulesDir@
set(cmakeModulesDir cmake/beman)
configure_package_config_file(
cmake/Config.cmake.in
BemanOptional26Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
PATH_VARS cmakeModulesDir
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-config.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/BemanOptional26Config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
COMPONENT beman_optional26_development
FILES
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-config-version.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)

# Coverage
Expand All @@ -87,4 +98,5 @@ add_custom_target(
COMMENT "Running gcovr to process coverage results"
COMMAND mkdir -p coverage
COMMAND gcovr --config gcovr.cfg .
DEPENDS test
)
Loading