diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d08a155..4a000ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -36,6 +38,14 @@ 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 @@ -43,6 +53,46 @@ jobs: - 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 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 63a4875..6ffa416 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -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", diff --git a/CMakeLists.txt b/CMakeLists.txt index ed0069c..7c8ef19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -16,7 +17,9 @@ include(cmake/CPM.cmake) # NAME cpp-library # URL "${CMAKE_SOURCE_DIR}/../cpp-library" # ) -CPMAddPackage("gh:stlab/cpp-library@4.0.5") +CPMAddPackage("gh:stlab/cpp-library#4f09b3b7f0abcc4ef1b39060ce03784920ce32e5") +# CPMAddPackage("gh:stlab/cpp-library@4.0.5") + include(${cpp-library_SOURCE_DIR}/cpp-library.cmake) # Let cpp-library handle the project declaration and version detection diff --git a/CMakePresets.json b/CMakePresets.json index 1e805dd..c61386b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -68,6 +68,20 @@ "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": [ @@ -75,7 +89,8 @@ { "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 } },