Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Checks:
- -llvm-prefer-static-over-anonymous-namespace
- -llvm-use-ranges
- -llvmlibc-*
# FIXME: https://github.com/llvm/llvm-project/issues/246857
# FIXME: https://github.com/llvm/llvm-project/issues/63939
- -misc-include-cleaner
- -modernize-use-trailing-return-type
- -performance-enum-size
- -portability-avoid-pragma-once
Expand Down
58 changes: 38 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.build.type }}
runs-on: ubuntu-26.04
strategy:
fail-fast: false
matrix:
build:
- {
Expand All @@ -34,18 +35,22 @@ jobs:
config:
- {
name: 'Linux GCC',
cc: gcc-15,
cxx: g++-15,
gcov: gcov-15,
profiles: '-pr:h conan/gcc15'
profiles: '-pr:a conan/gcc16',
cc: $(brew --prefix gcc@16)/bin/gcc-16,
cxx: $(brew --prefix gcc@16)/bin/g++-16,
gcov: $(brew --prefix gcc@16)/bin/gcov-16
}
- {
name: 'Linux Clang',
cc: clang-22,
cxx: clang++-22,
gcov: llvm-cov-22 gcov,
profiles: '-pr:h conan/clang22 -pr:h conan/libc++'
profiles: '-pr:a conan/clang23 -pr:a conan/libc++',
cc: $(brew --prefix llvm@23)/bin/clang,
cxx: $(brew --prefix llvm@23)/bin/clang++,
gcov: $(brew --prefix llvm@23)/bin/llvm-cov gcov
}
exclude:
# FIXME: https://github.com/llvm/llvm-project/issues/121709
- build: { type: RelWithDebInfo, preset: conan-relwithdebinfo }
config: { name: 'Linux Clang', profiles: '-pr:a conan/clang23 -pr:a conan/libc++', cc: $(brew --prefix llvm@23)/bin/clang, cxx: $(brew --prefix llvm@23)/bin/clang++, gcov: $(brew --prefix llvm@23)/bin/llvm-cov gcov }
steps:
- name: Checkout repository
uses: actions/checkout@v7
Expand All @@ -62,12 +67,18 @@ jobs:

- name: Install dependencies
run: |
sudo apt install libc++-22-dev libc++abi-22-dev
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-22 100
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install cppcheck
brew install cppcheck gcc@16 llvm@23
uv sync
uv run conan profile detect
mkdir -p ~/.config/clang
echo "-L$HOMEBREW_PREFIX/opt/llvm/lib" > ~/.config/clang/clang++.cfg
echo "-stdlib=libc++" >> ~/.config/clang/clang++.cfg
echo "-unwindlib=libunwind" >> ~/.config/clang/clang++.cfg
echo "-rtlib=compiler-rt" >> ~/.config/clang/clang++.cfg
echo "-L$HOMEBREW_PREFIX/opt/llvm/lib" > ~/.config/clang/clang.cfg
echo "-unwindlib=libunwind" >> ~/.config/clang/clang.cfg
echo "-rtlib=compiler-rt" >> ~/.config/clang/clang.cfg

- name: Cache Conan packages
uses: actions/cache@v6
Expand All @@ -84,12 +95,14 @@ jobs:
uv run conan install .
-b missing -pr:a default ${{ matrix.config.profiles }}
-c:a tools.cmake.cmaketoolchain:generator=Ninja
-c:h tools.build:compiler_executables="{\"c\": \"${{ matrix.config.cc }}\", \"cpp\": \"${{ matrix.config.cxx }}\"}"
-c:a tools.build:compiler_executables="{\"c\": \"${{ matrix.config.cc }}\", \"cpp\": \"${{ matrix.config.cxx }}\"}"
-s:h build_type=${{ matrix.build.type }}

- name: Configure
run: >
if [[ ${{ contains(matrix.config.cc, 'clang') }} == true ]]; then BUILD_RPATH="-D CMAKE_BUILD_RPATH=$(brew --prefix llvm@23)/lib"; fi;
uv run cmake --preset ${{ matrix.build.preset }}
$BUILD_RPATH
-D ENABLE_COVERAGE:BOOL=${{ matrix.build.type == 'Debug' }}
-D ENABLE_ASAN:BOOL=${{ matrix.build.type == 'Debug' }}
-D ENABLE_UBSAN:BOOL=${{ matrix.build.type == 'Debug' }}
Expand All @@ -107,14 +120,13 @@ jobs:

- name: Collect test coverage
if: matrix.build.type == 'Debug'
env:
GCOV: ${{ matrix.config.gcov }}
run: uv run gcovr
run: GCOV="${{ matrix.config.gcov }}" uv run gcovr

build_macos:
name: ${{ matrix.config.name }} ${{ matrix.build.type }}
runs-on: xcode-27
strategy:
fail-fast: false
matrix:
build:
- {
Expand All @@ -131,7 +143,7 @@ jobs:
cc: $(brew --prefix llvm@23)/bin/clang,
cxx: $(brew --prefix llvm@23)/bin/clang++,
gcov: $(brew --prefix llvm@23)/bin/llvm-cov gcov,
profiles: '-pr:h conan/clang23 -pr:h conan/libc++'
profiles: '-pr:a conan/clang23 -pr:a conan/libc++'
}
steps:
- name: Checkout repository
Expand Down Expand Up @@ -167,12 +179,13 @@ jobs:
uv run conan install .
-b missing -pr:a default ${{ matrix.config.profiles }}
-c:a tools.cmake.cmaketoolchain:generator=Ninja
-c:h tools.build:compiler_executables="{\"c\": \"${{ matrix.config.cc }}\", \"cpp\": \"${{ matrix.config.cxx }}\"}"
-c:a tools.build:compiler_executables="{\"c\": \"${{ matrix.config.cc }}\", \"cpp\": \"${{ matrix.config.cxx }}\"}"
-s:h build_type=${{ matrix.build.type }}

- name: Configure
run: >
uv run cmake --preset ${{ matrix.build.preset }}
-D CMAKE_CXX_STDLIB_MODULES_JSON=$(brew --prefix llvm@23)/lib/c++/libc++.modules.json
-D ENABLE_COVERAGE:BOOL=${{ matrix.build.type == 'Debug' }}
-D ENABLE_ASAN:BOOL=${{ matrix.build.type == 'Debug' }}
-D ENABLE_UBSAN:BOOL=${{ matrix.build.type == 'Debug' }}
Expand All @@ -194,6 +207,7 @@ jobs:
name: ${{ matrix.config.name }} ${{ matrix.build.type }}
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
build:
- {
Expand All @@ -209,14 +223,18 @@ jobs:
name: 'Windows MSVC',
cc: cl,
cxx: cl,
profiles: '-pr:h conan/msvc195-md'
profiles: '-pr:a conan/msvc195-md'
}
- {
name: 'Windows Clang',
cc: clang,
cxx: clang++,
profiles: '-pr:a conan/clang23'
}
exclude:
# FIXME: https://github.com/microsoft/STL/pull/5982 is not yet shipped
# with visual studio on github actions runner
- config: { name: 'Windows Clang', cc: clang, cxx: clang++, profiles: '-pr:a conan/clang23' }
steps:
- name: Checkout repository
uses: actions/checkout@v7
Expand Down Expand Up @@ -252,8 +270,8 @@ jobs:
uv run conan install .
-b missing -pr:a default ${{ matrix.config.profiles }}
-c:a tools.cmake.cmaketoolchain:generator=Ninja
-c:h tools.env.virtualenv:powershell=pwsh
-c:h tools.build:compiler_executables="{'c': '${{ matrix.config.cc }}', 'cpp': '${{ matrix.config.cxx }}'}"
-c:a tools.env.virtualenv:powershell=pwsh
-c:a tools.build:compiler_executables="{'c': '${{ matrix.config.cc }}', 'cpp': '${{ matrix.config.cxx }}'}"
-s:h build_type=${{ matrix.build.type }}

- name: Configure
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ repos:
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.13.7
rev: 0.13.12
hooks:
- id: uv-lock
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 4.4 FATAL_ERROR)
cmake_minimum_required(VERSION 4.5 FATAL_ERROR)

project(
cpp-project-template
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ source .venv/bin/activate
conan install -pr:a default \
-pr:a conan/<profile matching the compiler in use> \
-c:a tools.cmake.cmaketoolchain:generator=<CMake generator> \
-c:h tools.build:compiler_executables='{"c": "<CC>", "cpp": "<CXX>"}' \
-c:a tools.build:compiler_executables='{"c": "<CC>", "cpp": "<CXX>"}' \
-c:h tools.build:skip_test=<True|False> \
-s:h build_type=<Debug|RelWithDebInfo|Release|MinSizeRel> -b missing .

Expand Down Expand Up @@ -100,8 +100,8 @@ GCOV=<"gcov" for GCC, "llvm-cov gcov" for Clang> gcovr
conan install -pr:a default \
-pr:a conan/<profile matching the compiler in use> \
-c:a tools.cmake.cmaketoolchain:generator=<CMake generator> \
-c:h tools.env.virtualenv:powershell=pwsh \
-c:h tools.build:compiler_executables='{"c": "<CC>", "cpp": "<CXX>"}' \
-c:a tools.env.virtualenv:powershell=pwsh \
-c:a tools.build:compiler_executables='{"c": "<CC>", "cpp": "<CXX>"}' \
-c:h tools.build:skip_test=<True|False> \
-s:h build_type=<Debug|RelWithDebInfo|Release|MinSizeRel> -b missing .

Expand Down
9 changes: 9 additions & 0 deletions cmake/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ option(ENABLE_HARDENINGS "Enable hardenings" OFF)

# Useful CMake defaults
cmake_diagnostic(SET CMD_DEPRECATED FATAL_ERROR)
cmake_diagnostic(SET CMD_STRICT FATAL_ERROR)
cmake_diagnostic(SET CMD_UNINITIALIZED FATAL_ERROR)
cmake_diagnostic(SET CMD_UNUSED_CLI FATAL_ERROR)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
Expand All @@ -39,6 +42,12 @@ set(CMAKE_VS_JUST_MY_CODE_DEBUGGING ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST)
set(CMAKE_CTEST_ARGUMENTS --progress --output-on-failure --parallel)
set(CMAKE_INSTALL_SBOM_FORMATS spdx)
if(LINUX)
set(CMAKE_INSTALL_RPATH \$ORIGIN/../lib)
elseif(APPLE)
set(CMAKE_INSTALL_RPATH @loader_path/../lib)
endif()

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down
5 changes: 0 additions & 5 deletions conan/clang22

This file was deleted.

5 changes: 0 additions & 5 deletions conan/gcc15

This file was deleted.

7 changes: 2 additions & 5 deletions lib/math/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
project(math)

add_library(${PROJECT_NAME} INTERFACE)
target_sources(
${PROJECT_NAME}
INTERFACE FILE_SET HEADERS BASE_DIRS include FILES include/math/math.hpp
)
add_library(${PROJECT_NAME} STATIC)
target_sources(${PROJECT_NAME} PUBLIC FILE_SET CXX_MODULES FILES math.cpp)
8 changes: 5 additions & 3 deletions lib/math/include/math/math.hpp → lib/math/math.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once
#include <cstdint>
export module my.math;
import std;

namespace math {
// cppcheck does not understand modules yet
// cppcheck-suppress syntaxError
export namespace math {
#ifdef RECURSIVE_FIB
inline
#endif
Expand Down
18 changes: 17 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ install(
TARGETS ${PROJECT_NAME}
RUNTIME_DEPENDENCY_SET ${PROJECT_NAME}_runtime_dependencies
)
install(RUNTIME_DEPENDENCY_SET ${PROJECT_NAME}_runtime_dependencies)
install(
RUNTIME_DEPENDENCY_SET ${PROJECT_NAME}_runtime_dependencies
PRE_EXCLUDE_REGEXES
[[libc\.so\..*]]
[[libm\.so\..*]]
[[libpthread\.so\..*]]
[[ld-linux.*\.so\..*]]
[[libdl\.so\..*]]
[[librt\.so\..*]]
[[api-ms-.*]]
[[ext-ms-.*]]
[[.*azureattest.*]]
[[pdmutil.*]]
[[hvsifiletrust.*]]
[[wpaxholder.*]]
POST_EXCLUDE_REGEXES [[.*system32.*\.dll]] [[.*syswow64.*\.dll]]
)
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <array>
#include <fmt/base.h>
#include <functional>
#include <math/math.hpp>
#include <numeric>

import my.math;
import std;

int main(int, char**) {
constexpr std::array indices{3, 4, 5, 7};
Expand Down
2 changes: 1 addition & 1 deletion test/math/math-test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

#include <math/math.hpp>
import my.math;

// NOLINTNEXTLINE
TEST(Math, FibonacciWorks) {
Expand Down
Loading
Loading