diff --git a/.github/workflows/github-cxx-qt-tests.yml b/.github/workflows/github-cxx-qt-tests.yml index 5c423056c..b3a8ec410 100644 --- a/.github/workflows/github-cxx-qt-tests.yml +++ b/.github/workflows/github-cxx-qt-tests.yml @@ -287,6 +287,7 @@ jobs: cargo_dir: ~/.cargo rustc_wrapper: sccache build_type: Release + cargo_target: x86_64-unknown-linux-gnu - name: Ubuntu 24.04 (gcc) Qt6 os: ubuntu-24.04 qt_version: 6 @@ -308,6 +309,7 @@ jobs: libgl1-mesa-dev libvulkan-dev libxkbcommon-dev + cargo_target: x86_64-unknown-linux-gnu - name: macOS 13 (clang) Qt5 os: macos-13 @@ -331,6 +333,7 @@ jobs: cxx: clang++ rustc_wrapper: sccache build_type: Release + cargo_target: x86_64-apple-darwin - name: macOS 14 (clang) Qt6 os: macos-14 qt_version: 6 @@ -353,6 +356,7 @@ jobs: cxx: clang++ rustc_wrapper: sccache build_type: Release + cargo_target: aarch64-apple-darwin - name: Windows 2022 (MSVC) Qt5 os: windows-2022 @@ -372,6 +376,7 @@ jobs: cxx: cl rustc_wrapper: sccache build_type: Release + cargo_target: x86_64-pc-windows-msvc - name: Windows 2022 (MSVC2019) Qt6 os: windows-2022 qt_version: 6 @@ -390,6 +395,7 @@ jobs: cxx: cl rustc_wrapper: sccache build_type: Release + cargo_target: x86_64-pc-windows-msvc # Use a Debug build to ensure we can build and run tests in Debug mode with MSVC - name: Windows 2022 (MSVC2022) Qt6 Debug os: windows-2022 @@ -409,6 +415,7 @@ jobs: cxx: cl rustc_wrapper: sccache build_type: Debug + cargo_target: x86_64-pc-windows-msvc runs-on: ${{ matrix.os }} name: ${{ matrix.name }} @@ -422,6 +429,8 @@ jobs: SCCACHE_CACHE_SIZE: 600M SCCACHE_LOG: debug SCCACHE_ERROR_LOG: ${{ matrix.sccache_log_path }} + # Ensure that we share the same target sub folder + CARGO_BUILD_TARGET: ${{ matrix.cargo_target }} steps: - name: "Clone Git repository" diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f5846b73..ace195a4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,18 +134,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_TESTING) list(APPEND CARGO_ENV ${RUNTIME_ENV}) endif() -# Same logic as in Corrosion.cmake -if(CMAKE_VS_PLATFORM_NAME) - set(BUILD_DIR "${CMAKE_VS_PLATFORM_NAME}/$") -elseif(CMAKE_CONFIGURATION_TYPES) - set(BUILD_DIR "$") -else() - set(BUILD_DIR .) -endif() - # Set the target dir to the same that Corrosion uses to reuse build artifacts # from the main build. -set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/${BUILD_DIR}/cargo/build") +set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/cargo/build") if(BUILD_TESTING) # Add CMake tests for `cargo test/clippy/fmt/doc`. @@ -157,8 +148,10 @@ if(BUILD_TESTING) set_tests_properties(cargo_tests cargo_clippy PROPERTIES ENVIRONMENT_MODIFICATION "${CARGO_ENV}" ) + # Cargo doc cannot have a target set otherwise it fails + # https://github.com/rust-lang/cargo/issues/10368 set_tests_properties(cargo_doc PROPERTIES - ENVIRONMENT_MODIFICATION "${CARGO_ENV};RUSTDOCFLAGS=set:--deny=warnings" + ENVIRONMENT_MODIFICATION "${CARGO_ENV};RUSTDOCFLAGS=set:--deny=warnings;CARGO_BUILD_TARGET=unset:;" ) # Ensure test inputs and outputs are formatted