Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
76 changes: 63 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,61 @@ jobs:

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

- name: Configure CMake
run: cmake --preset=test
if: ${{ !matrix.cc }}

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

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

- name: Build and Install
run: |
cmake --preset=default
cmake --build --preset=default
cmake --install build/default --prefix ${{ runner.temp }}/install
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
if: ${{ matrix.cc }}

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

- 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
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
cmake_minimum_required(VERSION 3.20)

# Project declaration - cpp_library_setup will use this name and detect version from git tags
project(stlab-enum-ops)
project(enum-ops)

# Setup cpp-library infrastructure
if(PROJECT_IS_TOP_LEVEL)
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm CACHE PATH "CPM cache")
if(PROJECT_IS_TOP_LEVEL AND NOT CPM_SOURCE_CACHE AND NOT DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_SOURCE_CACHE "${CMAKE_SOURCE_DIR}/.cache/cpm" CACHE PATH "CPM source cache")
message(STATUS "Setting cpm cache dir to: ${CPM_SOURCE_CACHE}")
endif()
include(cmake/CPM.cmake)

Expand All @@ -16,7 +17,9 @@ include(cmake/CPM.cmake)
# NAME cpp-library
# URL "${CMAKE_SOURCE_DIR}/../cpp-library"
# )
CPMAddPackage("gh:stlab/[email protected]")
CPMAddPackage("gh:stlab/cpp-library#4f09b3b7f0abcc4ef1b39060ce03784920ce32e5")
# 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