ci: GitHub actions updated with CMake presets usage

This commit is contained in:
Mateusz Pusz
2022-08-02 08:30:14 +02:00
parent 9b1c9f16f1
commit 1c5061338f
2 changed files with 49 additions and 42 deletions

View File

@@ -113,6 +113,10 @@ jobs:
CMAKE_GENERATOR: Ninja CMAKE_GENERATOR: Ninja
steps: steps:
- name: Downcase 'build_type'
run: |
build_type=${{ matrix.build_type }}
echo "build_type=${build_type,,}" >> ${GITHUB_ENV}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Cache Conan data - name: Cache Conan data
uses: actions/cache@v2 uses: actions/cache@v2
@@ -177,12 +181,11 @@ jobs:
run: | run: |
conan config init conan config init
conan remote add upload https://mpusz.jfrog.io/artifactory/api/conan/conan-oss conan remote add upload https://mpusz.jfrog.io/artifactory/api/conan/conan-oss
conan profile update settings.build_type=${{ matrix.build_type }} default
conan profile update settings.compiler.cppstd=20 default conan profile update settings.compiler.cppstd=20 default
if [[ "${{ matrix.config.compiler.type }}" == "GCC" || "${{ matrix.config.compiler.type }}" == "CLANG" ]]; then if [[ "${{ matrix.config.compiler.type }}" == "GCC" || "${{ matrix.config.compiler.type }}" == "CLANG" ]]; then
conan profile update settings.compiler.libcxx=${{ matrix.config.lib }} default conan profile update settings.compiler.libcxx=${{ matrix.config.lib }} default
fi fi
conan profile update conf.tools.cmake.cmaketoolchain:generator=Ninja default conan profile update conf.tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" default
conan profile show default conan profile show default
# - name: Add support for clang-13 to Conan's settings.yml # - name: Add support for clang-13 to Conan's settings.yml
# # TODO Remove when Conan will support clang-13 # # TODO Remove when Conan will support clang-13
@@ -193,65 +196,70 @@ jobs:
- name: Install Conan dependencies - name: Install Conan dependencies
shell: bash shell: bash
run: | run: |
mkdir -p build/${{ matrix.build_type }} && cd build/${{ matrix.build_type }} conan install . -s build_type=${{ matrix.build_type }} -b outdated -u
conan install ../.. -b outdated -u mv CMakeUserPresets.json src
- name: Configure mp-units CMake - name: Configure mp-units CMake
if: matrix.config.compiler.type == 'VISUAL' if: matrix.config.compiler.type == 'VISUAL'
shell: cmd shell: cmd
working-directory: build/${{ matrix.build_type }} working-directory: src
run: | run: |
cmake --version cmake --version
call conanvcvars.bat ..\build\generators\conanbuild.bat
cmake ../../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} cmake --preset default -DCMAKE_INSTALL_PREFIX=../out
- name: Configure mp-units CMake - name: Configure mp-units CMake
if: matrix.config.compiler.type != 'VISUAL' if: matrix.config.compiler.type != 'VISUAL'
shell: bash shell: bash
working-directory: build/${{ matrix.build_type }} working-directory: src
run: | run: |
cmake --version cmake --version
cmake ../../src -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} cmake --preset default -DCMAKE_INSTALL_PREFIX=../out
- name: Install mp-units - name: Install mp-units
shell: bash shell: bash
working-directory: build/${{ matrix.build_type }} working-directory: src
run: | run: |
cmake --install . --prefix test_package cmake --build --preset ${build_type} --target install
- name: Install dependencies for test_package - name: Provide dependencies for test_package
shell: bash shell: bash
working-directory: test_package
run: | run: |
mkdir -p test_package/build/${{ matrix.build_type }} && cd test_package/build/${{ matrix.build_type }} cp ../src/CMakeUserPresets.json .
conan install ../../..
- name: Build test_package CMake (local build) - name: Build test_package CMake (local build)
if: matrix.config.compiler.type == 'VISUAL' if: matrix.config.compiler.type == 'VISUAL'
shell: cmd shell: cmd
working-directory: test_package/build/${{ matrix.build_type }} working-directory: test_package
run: | run: |
call conanvcvars.bat ..\build\generators\conanbuild.bat
cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} cmake --preset default -Dmp-units_DIR=../build -Bbuild/local
cmake --build . cmake --build build/local --config ${{ matrix.build_type }}
- name: Build test_package CMake (local build) - name: Build test_package CMake (local build)
if: matrix.config.compiler.type != 'VISUAL' if: matrix.config.compiler.type != 'VISUAL'
shell: bash shell: bash
working-directory: test_package/build/${{ matrix.build_type }} working-directory: test_package
run: | run: |
cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -Dmp-units_DIR=${{ github.workspace }}/build/${{ matrix.build_type }} cmake --preset default -Dmp-units_DIR=../build -Bbuild/local
cmake --build . cmake --build build/local --config ${{ matrix.build_type }}
- name: Build test_package CMake (installation) - name: Run test_package (local build)
if: matrix.config.compiler.type == 'VISUAL'
shell: cmd
working-directory: test_package/build/${{ matrix.build_type }}
run: |
call conanvcvars.bat
cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package
cmake --build .
- name: Build test_package CMake (installation)
if: matrix.config.compiler.type != 'VISUAL'
shell: bash shell: bash
working-directory: test_package/build/${{ matrix.build_type }} working-directory: test_package/build/local/${{ matrix.build_type }}
run: | run: |
cmake ../.. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=../../../build/${{ matrix.build_type }}/test_package ./test_package
cmake --build . - name: Build test_package CMake (installation)
- name: Run test_package if: matrix.config.compiler.type == 'VISUAL'
shell: bash shell: cmd
working-directory: test_package/build/${{ matrix.build_type }} working-directory: test_package/build/${{ matrix.build_type }}
run: |
..\build\generators\conanbuild.bat
cmake --preset default -DCMAKE_INSTALL_PREFIX=../out -Bbuild/install
cmake --build build/install --config ${{ matrix.build_type }}
- name: Build test_package CMake (installation)
if: matrix.config.compiler.type != 'VISUAL'
shell: bash
working-directory: test_package/build/${{ matrix.build_type }}
run: |
cmake --preset default -DCMAKE_INSTALL_PREFIX=../out -Bbuild/install
cmake --build build/install --config ${{ matrix.build_type }}
- name: Run test_package (installation)
shell: bash
working-directory: test_package/build/install/${{ matrix.build_type }}
run: | run: |
./test_package ./test_package

View File

@@ -78,16 +78,15 @@ jobs:
conan remote add -i 0 upload https://mpusz.jfrog.io/artifactory/api/conan/conan-oss conan remote add -i 0 upload https://mpusz.jfrog.io/artifactory/api/conan/conan-oss
- name: Install Conan dependencies - name: Install Conan dependencies
run: | run: |
mkdir build && cd build conan install . -s compiler.cppstd=20 -s compiler.libcxx=libstdc++11 -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config" -e mp-units:CONAN_RUN_TESTS=True -b outdated -u
conan install .. -s compiler.cppstd=20 -s compiler.libcxx=libstdc++11 -e mp-units:CONAN_RUN_TESTS=True -b outdated -u
- name: Configure CMake - name: Configure CMake
working-directory: build working-directory: build
run: | run: |
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --preset default
- name: Generate documentation - name: Generate documentation
working-directory: build working-directory: build
run: | run: |
cmake --build . --target documentation --config Release cmake --build --preset Release --target documentation
- name: Deploy documentation - name: Deploy documentation
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3