Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
72 changes: 59 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ on:

jobs:
test:
name: Test (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
compiler: [gcc, clang, msvc]
exclude:
- os: ubuntu-latest
compiler: msvc
- os: macos-latest
compiler: msvc
- os: macos-latest
compiler: gcc
- os: windows-latest
compiler: gcc
- os: windows-latest
compiler: clang
include:
- name: Ubuntu GCC
os: ubuntu-latest
cc: gcc
cxx: g++
- name: Ubuntu Clang
os: ubuntu-latest
cc: clang
cxx: clang++
- name: macOS
os: macos-latest
- name: Windows
os: windows-latest

runs-on: ${{ matrix.os }}

Expand All @@ -36,13 +38,57 @@ jobs:

- name: Configure CMake
run: cmake --preset=test
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}

- name: Build
run: cmake --build --preset=test

- name: Test
run: ctest --preset=test

install-test:
name: Test Installation (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v5

- name: Build and Install
run: |
cmake --preset=default
cmake --build --preset=default
cmake --install build/default --prefix ${{ runner.temp }}/install

- name: Test find_package
shell: bash
run: |
# Create a minimal test to verify the installation works with find_package
mkdir -p ${{ runner.temp }}/test-find-package
cd ${{ runner.temp }}/test-find-package

# Create test CMakeLists.txt
cat > CMakeLists.txt << EOF
cmake_minimum_required(VERSION 3.20)
project(test-find-package CXX)

find_package(stlab-enum-ops REQUIRED)

message(STATUS "Successfully found stlab-enum-ops")
EOF

# Convert paths to forward slashes for CMake (works on all platforms)
INSTALL_PREFIX=$(echo "${{ runner.temp }}/install" | sed 's|\\|/|g')

# Test find_package with CMAKE_PREFIX_PATH
cmake -B build -S . -DCMAKE_PREFIX_PATH="${INSTALL_PREFIX}"

clang-tidy:
runs-on: ubuntu-latest

Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"_comment": "Auto-generated from cpp-library (https://github.com/stlab/cpp-library) - Do not edit this file directly",
"recommendations": [
"matepek.vscode-catch2-test-adapter",
"llvm-vs-code-extensions.vscode-clangd",
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ include(cmake/CPM.cmake)
# NAME cpp-library
# URL "${CMAKE_SOURCE_DIR}/../cpp-library"
# )
CPMAddPackage("gh:stlab/[email protected]")
CPMAddPackage("gh:stlab/cpp-library#77c30bc9d7b0c35359a1f0ef951e63e60e24edf7")
# CPMAddPackage("gh:stlab/[email protected]")

include(${cpp-library_SOURCE_DIR}/cpp-library.cmake)

# Let cpp-library handle the project declaration and version detection
Expand Down
17 changes: 16 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,29 @@
"CMAKE_CXX_EXTENSIONS": "OFF",
"CPP_LIBRARY_FORCE_INIT": "ON"
}
},
{
"name": "install",
"displayName": "Local Install Test",
"description": "Configuration for testing installation locally (installs to build/install/prefix)",
"binaryDir": "${sourceDir}/build/install",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TESTING": "OFF",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_CXX_EXTENSIONS": "OFF",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install/prefix"
}
}
],
"buildPresets": [
{ "name": "default", "displayName": "Default Build", "configurePreset": "default" },
{ "name": "test", "displayName": "Build Tests", "configurePreset": "test" },
{ "name": "docs", "displayName": "Build Docs", "configurePreset": "docs", "targets": "docs" },
{ "name": "clang-tidy", "displayName": "Build with Clang-Tidy", "configurePreset": "clang-tidy" },
{ "name": "init", "displayName": "Initialize Templates", "configurePreset": "init" }
{ "name": "init", "displayName": "Initialize Templates", "configurePreset": "init" },
{ "name": "install", "displayName": "Build for Local Install", "configurePreset": "install" }
],
"testPresets": [
{ "name": "test", "displayName": "Run All Tests", "configurePreset": "test", "output": { "outputOnFailure": true } },
Expand Down