Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ninja Multi-Config Cross-Config support #492

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.23.5
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
4 changes: 2 additions & 2 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function(_corrosion_set_imported_location_deferred target_name base_property out
elseif(output_directory)
set(curr_out_dir "${output_directory}")
else()
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
endif()
string(REPLACE "\$<CONFIG>" "${config_type}" curr_out_dir "${curr_out_dir}")
message(DEBUG "Setting ${base_property}_${config_type_upper} for target ${target_name}"
Expand Down Expand Up @@ -235,7 +235,7 @@ function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_names ca
# Fallback to the default directory. We do not append the configuration directory here
# and instead let CMake do this, since otherwise the resolving of dynamic library
# imported paths may fail.
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
endif()
set(multiconfig_out_dir_genex "${multiconfig_out_dir_genex}$<$<CONFIG:${config_type}>:${curr_out_dir}>")
endforeach()
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
Loading