Skip to content

Commit

Permalink
Add Ninja Multi-Config Cross-Config test
Browse files Browse the repository at this point in the history
Add a test with CMAKE_CROSS_CONFIGS set
  • Loading branch information
jschwe committed Mar 6, 2024
1 parent b01a6d3 commit 0828966
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,28 @@ jobs:
working-directory: build
run: ctest --output-on-failure --build-config Debug -j 3

ninja_multi_config_cross_config:
name: Test Ninja Multi-Config Cross-Configs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install CMake
uses: corrosion-rs/install-cmake@v2
with:
cmake: 3.22.6
ninja: 1.10.0
# Install cbindgen before Rust to use recent default Rust version.
- name: Install cbindgen
run: cargo install cbindgen
- name: Install Rust
id: install_rust
uses: dtolnay/rust-toolchain@stable
- name: Configure
run: cmake -S. -Bbuild -G "Ninja Multi-Config" -DCMAKE_CROSS_CONFIGS="Debug;Release" -DCMAKE_DEFAULT_CONFIGS="Debug;Release"
- name: Run Tests
working-directory: build
run: ctest --output-on-failure -j 3 --build-config Debug


test_cxxbridge:
name: Test cxxbridge integration
Expand Down
6 changes: 6 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ function(corrosion_tests_add_test test_name bin_names)
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND configure_cmake_args TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}")
endif()
if(CMAKE_CROSS_CONFIGS)
list(APPEND configure_cmake_args CMAKE_CROSS_CONFIGS "${CMAKE_CROSS_CONFIGS}")
endif()
if(CMAKE_DEFAULT_CONFIGS)
list(APPEND configure_cmake_args CMAKE_DEFAULT_CONFIGS "${CMAKE_DEFAULT_CONFIGS}")
endif()

add_test(NAME "${test_name}_build"
COMMAND
Expand Down
8 changes: 8 additions & 0 deletions test/ConfigureAndBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ set(oneValueArgs
CARGO_PROFILE
OSX_ARCHITECTURES
TOOLCHAIN_FILE
CMAKE_CROSS_CONFIGS
CMAKE_DEFAULT_CONFIGS
)
set(multiValueArgs "PASS_THROUGH_ARGS")
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}"
Expand Down Expand Up @@ -59,6 +61,12 @@ endif()
if(TEST_TOOLCHAIN_FILE)
list(APPEND configure_args "-DCMAKE_TOOLCHAIN_FILE=${TEST_TOOLCHAIN_FILE}")
endif()
if(TEST_CMAKE_CROSS_CONFIGS)
list(APPEND configure_args "-DCMAKE_CROSS_CONFIGS=${TEST_CMAKE_CROSS_CONFIGS}")
endif()
if(TEST_CMAKE_DEFAULT_CONFIGS)
list(APPEND configure_args "-DCMAKE_DEFAULT_CONFIGS=${TEST_CMAKE_DEFAULT_CONFIGS}")
endif()
if(TEST_CARGO_PROFILE)
list(APPEND configure_args "-DCARGO_PROFILE=${TEST_CARGO_PROFILE}")
endif()
Expand Down

0 comments on commit 0828966

Please sign in to comment.