diff --git a/.github/workflows/cmake/action.yml b/.github/workflows/cmake/action.yml index 0ac09bfa4..b8794da26 100644 --- a/.github/workflows/cmake/action.yml +++ b/.github/workflows/cmake/action.yml @@ -1,56 +1,25 @@ name: Composite CMake inputs: - cmake_generator: - required: false - type: string - default: 'Unix Makefiles' - cmake_build_type: + cmake_preset: required: true type: string - default: '' - cmake_cxx_compiler: - required: false - type: string - gsl_cxx_standard: - required: true - type: number extra_cmake_args: required: false type: string default: '' - build_cmd: - required: true - type: string - default: 'make' - test_cmd: - required: false - type: string - default: 'make test' - shell: - required: false - type: string - default: 'bash' - runs: using: composite steps: - - name: Create build directory - run: mkdir build - shell: ${{ inputs.shell }} - - name: Configure CMake - 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 }} + run: cmake --preset ${{ inputs.cmake_preset }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }} + shell: bash - - name: Build - working-directory: build - run: ${{ inputs.build_cmd }} - shell: ${{ inputs.shell }} + - name: Build (with preset) + run: cmake --build --preset ${{ inputs.cmake_preset }} + shell: bash - - name: Test - working-directory: build - run: ${{ inputs.test_cmd }} - shell: ${{ inputs.shell }} + - name: Test (with preset) + run: ctest --preset ${{ inputs.cmake_preset }} --output-on-failure --no-compress-output + shell: pwsh diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index 7ab2c7eaf..e576ce48e 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 diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index c410c66ba..31a2a49c0 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -15,8 +15,8 @@ jobs: run: sudo apt-get update && sudo apt-get install -y clang cmake make - name: Configure CMake (C++14) - run: cmake -B build-cxx14 . -DGSL_CXX_STANDARD=14 -DGSL_TEST=ON -G "Unix Makefiles" + run: cmake --preset clang-14-debug - name: Configure CMake (C++20) - run: cmake -B build-cxx20 . -DGSL_CXX_STANDARD=20 -DGSL_TEST=ON -G "Unix Makefiles" + run: cmake --preset clang-20-debug diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..eed32e240 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,463 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}", + "installDir": "${sourceDir}/install/${presetName}", + "cacheVariables": { + "GSL_CXX_STANDARD": "14", + "GSL_TEST": "ON" + } + }, + { + "name": "msvc-base", + "inherits": "base", + "hidden": true, + "generator": "Visual Studio 17 2022", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "toolset": "host=x64", + "architecture": "x64", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "cl" + } + }, + { + "name": "gcc-base", + "inherits": "base", + "hidden": true, + "generator": "Unix Makefiles", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "g++", + "CMAKE_C_COMPILER": "gcc" + } + }, + { + "name": "clang-base", + "inherits": "base", + "hidden": true, + "generator": "Unix Makefiles", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_C_COMPILER": "clang" + } + }, + { + "name": "msvc-14-debug", + "displayName": "MSVC C++14 Debug", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "14" + } + }, + { + "name": "msvc-14-release", + "displayName": "MSVC C++14 Release", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "14" + } + }, + { + "name": "msvc-17-debug", + "displayName": "MSVC C++17 Debug", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "17" + } + }, + { + "name": "msvc-17-release", + "displayName": "MSVC C++17 Release", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "17" + } + }, + { + "name": "msvc-20-debug", + "displayName": "MSVC C++20 Debug", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "20" + } + }, + { + "name": "msvc-20-release", + "displayName": "MSVC C++20 Release", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "20" + } + }, + { + "name": "msvc-23-debug", + "displayName": "MSVC C++23 Debug", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "23" + } + }, + { + "name": "msvc-23-release", + "displayName": "MSVC C++23 Release", + "inherits": "msvc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "23" + } + }, + { + "name": "gcc-14-debug", + "displayName": "GCC C++14 Debug", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "14" + } + }, + { + "name": "gcc-14-release", + "displayName": "GCC C++14 Release", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "14" + } + }, + { + "name": "gcc-17-debug", + "displayName": "GCC C++17 Debug", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "17" + } + }, + { + "name": "gcc-17-release", + "displayName": "GCC C++17 Release", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "17" + } + }, + { + "name": "gcc-20-debug", + "displayName": "GCC C++20 Debug", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "20" + } + }, + { + "name": "gcc-20-release", + "displayName": "GCC C++20 Release", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "20" + } + }, + { + "name": "gcc-23-debug", + "displayName": "GCC C++23 Debug", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "23" + } + }, + { + "name": "gcc-23-release", + "displayName": "GCC C++23 Release", + "inherits": "gcc-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "23" + } + }, + { + "name": "clang-14-debug", + "displayName": "Clang C++14 Debug", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "14" + } + }, + { + "name": "clang-14-release", + "displayName": "Clang C++14 Release", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "14" + } + }, + { + "name": "clang-17-debug", + "displayName": "Clang C++17 Debug", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "17" + } + }, + { + "name": "clang-17-release", + "displayName": "Clang C++17 Release", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "17" + } + }, + { + "name": "clang-20-debug", + "displayName": "Clang C++20 Debug", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "20" + } + }, + { + "name": "clang-20-release", + "displayName": "Clang C++20 Release", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "20" + } + }, + { + "name": "clang-23-debug", + "displayName": "Clang C++23 Debug", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "GSL_CXX_STANDARD": "23" + } + }, + { + "name": "clang-23-release", + "displayName": "Clang C++23 Release", + "inherits": "clang-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "GSL_CXX_STANDARD": "23" + } + } + ], + "buildPresets": [ + { + "name": "msvc-14-debug", + "configurePreset": "msvc-14-debug" + }, + { + "name": "msvc-14-release", + "configurePreset": "msvc-14-release" + }, + { + "name": "msvc-17-debug", + "configurePreset": "msvc-17-debug" + }, + { + "name": "msvc-17-release", + "configurePreset": "msvc-17-release" + }, + { + "name": "msvc-20-debug", + "configurePreset": "msvc-20-debug" + }, + { + "name": "msvc-20-release", + "configurePreset": "msvc-20-release" + }, + { + "name": "msvc-23-debug", + "configurePreset": "msvc-23-debug" + }, + { + "name": "msvc-23-release", + "configurePreset": "msvc-23-release" + }, + { + "name": "gcc-14-debug", + "configurePreset": "gcc-14-debug" + }, + { + "name": "gcc-14-release", + "configurePreset": "gcc-14-release" + }, + { + "name": "gcc-17-debug", + "configurePreset": "gcc-17-debug" + }, + { + "name": "gcc-17-release", + "configurePreset": "gcc-17-release" + }, + { + "name": "gcc-20-debug", + "configurePreset": "gcc-20-debug" + }, + { + "name": "gcc-20-release", + "configurePreset": "gcc-20-release" + }, + { + "name": "gcc-23-debug", + "configurePreset": "gcc-23-debug" + }, + { + "name": "gcc-23-release", + "configurePreset": "gcc-23-release" + }, + { + "name": "clang-14-debug", + "configurePreset": "clang-14-debug" + }, + { + "name": "clang-14-release", + "configurePreset": "clang-14-release" + }, + { + "name": "clang-17-debug", + "configurePreset": "clang-17-debug" + }, + { + "name": "clang-17-release", + "configurePreset": "clang-17-release" + }, + { + "name": "clang-20-debug", + "configurePreset": "clang-20-debug" + }, + { + "name": "clang-20-release", + "configurePreset": "clang-20-release" + }, + { + "name": "clang-23-debug", + "configurePreset": "clang-23-debug" + }, + { + "name": "clang-23-release", + "configurePreset": "clang-23-release" + } + ], + "testPresets": [ + { + "name": "msvc-14-debug", + "configurePreset": "msvc-14-debug" + }, + { + "name": "msvc-14-release", + "configurePreset": "msvc-14-release" + }, + { + "name": "msvc-17-debug", + "configurePreset": "msvc-17-debug" + }, + { + "name": "msvc-17-release", + "configurePreset": "msvc-17-release" + }, + { + "name": "msvc-20-debug", + "configurePreset": "msvc-20-debug" + }, + { + "name": "msvc-20-release", + "configurePreset": "msvc-20-release" + }, + { + "name": "msvc-23-debug", + "configurePreset": "msvc-23-debug" + }, + { + "name": "msvc-23-release", + "configurePreset": "msvc-23-release" + }, + { + "name": "gcc-14-debug", + "configurePreset": "gcc-14-debug" + }, + { + "name": "gcc-14-release", + "configurePreset": "gcc-14-release" + }, + { + "name": "gcc-17-debug", + "configurePreset": "gcc-17-debug" + }, + { + "name": "gcc-17-release", + "configurePreset": "gcc-17-release" + }, + { + "name": "gcc-20-debug", + "configurePreset": "gcc-20-debug" + }, + { + "name": "gcc-20-release", + "configurePreset": "gcc-20-release" + }, + { + "name": "gcc-23-debug", + "configurePreset": "gcc-23-debug" + }, + { + "name": "gcc-23-release", + "configurePreset": "gcc-23-release" + }, + { + "name": "clang-14-debug", + "configurePreset": "clang-14-debug" + }, + { + "name": "clang-14-release", + "configurePreset": "clang-14-release" + }, + { + "name": "clang-17-debug", + "configurePreset": "clang-17-debug" + }, + { + "name": "clang-17-release", + "configurePreset": "clang-17-release" + }, + { + "name": "clang-20-debug", + "configurePreset": "clang-20-debug" + }, + { + "name": "clang-20-release", + "configurePreset": "clang-20-release" + }, + { + "name": "clang-23-debug", + "configurePreset": "clang-23-debug" + }, + { + "name": "clang-23-release", + "configurePreset": "clang-23-release" + } + ] +} \ No newline at end of file diff --git a/CMakeSettings.json b/CMakeSettings.json deleted file mode 100644 index 2e1ad24c5..000000000 --- a/CMakeSettings.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ - "msvc_x64_x64" - ], - "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", - "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", - "cmakeCommandArgs": "-DGSL_CXX_STANDARD=17", - "buildCommandArgs": "-v", - "ctestCommandArgs": "", - "codeAnalysisRuleset": "CppCoreCheckRules.ruleset" - } - ] -} \ No newline at end of file