diff --git a/.github/workflows/cmake/action.yml b/.github/workflows/cmake/action.yml index 0ac09bf..4ad09ea 100644 --- a/.github/workflows/cmake/action.yml +++ b/.github/workflows/cmake/action.yml @@ -1,25 +1,29 @@ name: Composite CMake inputs: + cmake_preset: + required: false + type: string + description: 'CMake preset name to use (if provided, other cmake_* inputs are ignored)' cmake_generator: required: false type: string default: 'Unix Makefiles' cmake_build_type: - required: true + required: false type: string default: '' cmake_cxx_compiler: required: false type: string gsl_cxx_standard: - required: true + required: false type: number extra_cmake_args: required: false type: string default: '' build_cmd: - required: true + required: false type: string default: 'make' test_cmd: @@ -35,21 +39,40 @@ inputs: runs: using: composite steps: - - name: Create build directory + - name: Configure CMake (with preset) + if: ${{ inputs.cmake_preset != '' }} + run: cmake --preset ${{ inputs.cmake_preset }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }} + shell: ${{ inputs.shell }} + + - name: Create build directory (without preset) + if: ${{ inputs.cmake_preset == '' }} run: mkdir build shell: ${{ inputs.shell }} - - name: Configure CMake + - name: Configure CMake (without preset) + if: ${{ inputs.cmake_preset == '' }} working-directory: build run: cmake -G "${{ inputs.cmake_generator }}" -DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} -DCMAKE_CXX_COMPILER=${{ inputs.cmake_cxx_compiler }} -DGSL_CXX_STANDARD=${{ inputs.gsl_cxx_standard }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }} .. shell: ${{ inputs.shell }} - - name: Build + - name: Build (with preset) + if: ${{ inputs.cmake_preset != '' }} + run: cmake --build --preset ${{ inputs.cmake_preset }} + shell: ${{ inputs.shell }} + + - name: Build (without preset) + if: ${{ inputs.cmake_preset == '' }} working-directory: build run: ${{ inputs.build_cmd }} shell: ${{ inputs.shell }} - - name: Test + - name: Test (with preset) + if: ${{ inputs.cmake_preset != '' }} + run: ctest --preset ${{ inputs.cmake_preset }} --output-on-failure --no-compress-output + shell: ${{ inputs.shell }} + + - name: Test (without preset) + if: ${{ inputs.cmake_preset == '' }} working-directory: build run: ${{ inputs.test_cmd }} shell: ${{ inputs.shell }} diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index 7ab2c7e..e576ce4 100644 --- a/.github/workflows/compilers.yml +++ b/.github/workflows/compilers.yml @@ -35,9 +35,7 @@ jobs: - name: Run CMake (configure, build, test) uses: ./.github/workflows/cmake with: - cmake_build_type: ${{ matrix.build_type }} - cmake_cxx_compiler: g++-${{ matrix.gcc_version }} - gsl_cxx_standard: ${{ matrix.cxx_version }} + cmake_preset: gcc-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }} clang: strategy: @@ -58,9 +56,7 @@ jobs: - name: Run CMake (configure, build, test) uses: ./.github/workflows/cmake with: - cmake_build_type: ${{ matrix.build_type }} - cmake_cxx_compiler: clang++-${{ matrix.clang_version }} - gsl_cxx_standard: ${{ matrix.cxx_version }} + cmake_preset: clang-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }} xcode: strategy: @@ -78,9 +74,7 @@ jobs: - name: Run CMake (configure, build, test) uses: ./.github/workflows/cmake with: - cmake_build_type: ${{ matrix.build_type }} - cmake_cxx_compiler: clang++ - gsl_cxx_standard: ${{ matrix.cxx_version }} + cmake_preset: clang-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }} extra_cmake_args: '-DCMAKE_CXX_FLAGS="-isysroot \"$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk\""' VisualStudio: @@ -99,11 +93,7 @@ jobs: - name: Run CMake (configure, build, test) uses: ./.github/workflows/cmake with: - cmake_generator: ${{ matrix.generator }} - cmake_build_type: ${{ matrix.build_type }} - gsl_cxx_standard: ${{ matrix.cxx_version }} + cmake_preset: msvc-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }} extra_cmake_args: ${{ matrix.extra_args }} - build_cmd: msbuild GSL.sln - test_cmd: ctest . --output-on-failure --no-compress-output shell: pwsh