diff --git a/.github/workflows/ci-cmake.yml b/.github/workflows/ci-cmake.yml new file mode 100644 index 0000000..c075919 --- /dev/null +++ b/.github/workflows/ci-cmake.yml @@ -0,0 +1,49 @@ +name: CMake + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build-and-test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + library: [shared, static] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - uses: ilammy/msvc-dev-cmd@v1 + if: runner.os == 'Windows' + + # CMAKE_Fortran_COMPILER=NOTFOUND stops Eigen's blas/ subdirectory from + # probing for a Fortran compiler (its check_language call skips the probe + # when the cache variable is already defined), which otherwise fails on + # Windows runners where MinGW gfortran is on the PATH alongside the MSVC + # toolchain. + - name: Configure + run: > + cmake -S . -B build + ${{ runner.os == 'Windows' && '-G Ninja' || '' }} + -DOAR_BUILD_EXAMPLES=ON + -DOAR_BUILD_SHARED_LIBRARY=${{ matrix.library == 'shared' && 'ON' || 'OFF' }} + -DCMAKE_Fortran_COMPILER=NOTFOUND + + - name: Build + run: cmake --build build --parallel + + - name: Run smoke tests + shell: bash + run: | + export PATH="$PWD/build:$PATH" + ./build/tests/examples/test_audio_element_types + ./build/tests/examples/test_channel_based_rendering + ./build/tests/examples/test_scene_based_rendering + ./build/tests/examples/test_object_based_rendering + + - name: Run obr unit tests + run: ctest --test-dir build/src/renderer/obr/obr_capi/obr -L obr --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index fe432aa..677ba5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 3.28) set(PROJECT_N oar) project(${PROJECT_N} VERSION 1.0.0) +# Export all symbols when building oar as a DLL so an import library is +# generated for the examples to link against. +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED True) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index 2fdd5e5..99ab931 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -28,6 +28,8 @@ set_property(TARGET test_audio_element_types PROPERTY C_STANDARD 99) set_property(TARGET test_channel_based_rendering PROPERTY C_STANDARD 99) set_property(TARGET test_scene_based_rendering PROPERTY C_STANDARD 99) set_property(TARGET test_object_based_rendering PROPERTY C_STANDARD 99) -target_link_libraries(test_channel_based_rendering PRIVATE m) -target_link_libraries(test_scene_based_rendering PRIVATE m) -target_link_libraries(test_object_based_rendering PRIVATE m) +if(NOT MSVC) + target_link_libraries(test_channel_based_rendering PRIVATE m) + target_link_libraries(test_scene_based_rendering PRIVATE m) + target_link_libraries(test_object_based_rendering PRIVATE m) +endif()