Skip to content

Commit

Permalink
build in known build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pasbi committed Sep 30, 2024
1 parent b06ebad commit 5176fa5
Showing 1 changed file with 34 additions and 45 deletions.
79 changes: 34 additions & 45 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,28 @@ jobs:
compiler: clang
- os: ubuntu-latest
compiler: msvc
include:
- compiler: gcc
generator: Ninja
cppstd: gnu20
libcxx: libstdc++
compiler_version: 11
- compiler: clang
generator: Ninja
cppstd: gnu20
libcxx: libc++
compiler_version: 14
- compiler: msvc
generator: Visual Studio 17 2022
cppstd: 20
compiler_runtime: dynamic
compiler_version: 194

steps:
- uses: actions/checkout@v4

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- if: ${{ matrix.compiler == 'clang' }}
run: sudo apt-get update; sudo apt-get install clang

- name: Install Conan
id: conan
Expand All @@ -57,64 +69,41 @@ jobs:
restore-keys: conan-cache-${{ runner.os }}-

- uses: DamianReeves/write-file-action@master
if: ${{ matrix.compiler == 'clang' }}
with:
path: ${{ env.CONAN_HOME }}/profiles/default
contents: |
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=gnu20
compiler.libcxx=libc++
compiler.version=14
os=Linux
[conf]
tools.system.package_manager:mode=install
tools.system.package_manager:sudo=True
build_type=${{ matrix.build_type }}
compiler=${{ matrix.compiler }}
compiler.cppstd=${{ matrix.cppstd }}
compiler.libcxx=${{ matrix.libcxx }}
compiler.version=${{ matrix.compiler_version }}
compiler.runtime=${{ matrix.compiler_runtime }}
os=${{ runner.os }}
write-mode: overwrite

- uses: DamianReeves/write-file-action@master
if: ${{ matrix.compiler == 'gcc' }}
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
path: ${{ env.CONAN_HOME }}/profiles/default
contents: |
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu20
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
[conf]
tools.system.package_manager:mode=install
tools.system.package_manager:sudo=True
write-mode: overwrite
write-mode: append

- uses: DamianReeves/write-file-action@master
if: ${{ matrix.compiler == 'msvc' }}
with:
path: ${{ env.CONAN_HOME }}/profiles/default
contents: |
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=20
compiler.runtime=dynamic
compiler.version=194
os=Windows
write-mode: overwrite

- name: PrintProfile
run: cat ${{ env.CONAN_HOME }}/profiles/default

- name: Install Dependencies
run: conan install . --build=missing --output-folder=build

- name: Build
run: conan create . --build=missing
run: >
cmake -G ${{ matrix.generator }} -S . -B build -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build build --config ${{ matrix.build_type }} --parallel
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
run: ctest --build-config ${{ matrix.build_type }} --test-dir build

0 comments on commit 5176fa5

Please sign in to comment.