Skip to content

Conversation

@jrose-signal
Copy link

Setting CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR is often enough for CMake to handle cross-compilation even without a toolchain file, but it gets in the way of generators that handle cross-compilation on their own (in Visual Studio's case, using the -T "toolset" option).

Narrow fix for the issue I brought up in #158 (comment). Possible fix for #171 as well, if it does turn out to be the same thing.

src/lib.rs Outdated
Comment on lines 460 to 464
&& !(msvc
&& self
.generator
.as_deref()
.map_or(true, |g| g.to_string_lossy().starts_with("Visual Studio")))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely weirdly complicated for an inline condition, and depends on the default generator choice for MSVC being Visual Studio (implemented below, unchanged). Suggestions welcome on how to reorganize this.

@jrose-signal
Copy link
Author

(Test failures are also happening on upstream.)

@tgross35 tgross35 added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2024
Setting CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR is often enough for
CMake to handle cross-compilation even without a toolchain file, but it
gets in the way of generators that handle cross-compilation on their own
(in Visual Studio's case, using the -T "toolset" option).
@jrose-signal jrose-signal force-pushed the visual-studio-cross-compilation branch from 88ba56f to 897845f Compare December 11, 2025 23:56
Copy link
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the face of it this does look reasonable to me. We shouldn't have competing sources of truth for cross-compiling.

However, I'm not yet familiar enough with how this crate is used in practice to be confident this won't be breaking for someone out there. Could someone be relying on CMAKE_SYSTEM_NAME or CMAKE_SYSTEM_PROCESSOR being set even for Visual Studio builds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants