Skip to content

Conversation

apocelipes
Copy link

When cross-compiling for Windows systems, CMake will report an error because the CMAKE_SYSTEM_VERSION variable has not been set:

image

Checking whether this variable has been set resolves the error. A warning message is specifically output for this situation.

@thbeu
Copy link
Contributor

thbeu commented Sep 8, 2025

Duplicate of #2204.

@apocelipes
Copy link
Author

Duplicate of #2204.

This is not vcpkg. And seems like this error happens with many tools. So I think it should be fixed.

@apocelipes
Copy link
Author

Duplicate of #2204.

See the document:
image

So check whether the variable is set and print a warning message is the right way for handling cross-compilation.

@thbeu
Copy link
Contributor

thbeu commented Sep 8, 2025

Yes, it should be fixed in the lib.

@yhirose
Copy link
Owner

yhirose commented Sep 8, 2025

@sum01 @jimmy-park could you please review this pull request? Thanks!

CMakeLists.txt Outdated
message(SEND_ERROR "Windows ${CMAKE_SYSTEM_VERSION} or lower is not supported. Please use Windows 10 or later.")
endif()
else()
message(WARNING "The target is Windows but CMAKE_SYSTEM_VERSION is not set, the default system version is set to Windows 10 or later.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it actually setting a default system version anywhere? I don't remember it being in the Cmake at least.

Copy link
Author

Choose a reason for hiding this comment

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

CMake >= 3.24 on Windows ignores this variable and always finds the latest version of the SDK, so no need to set it.

For version < 3.24, we can use set(CMAKE_SYSTEM_VERSION "10.0.19041.0"). Users can also pass values from command lines to it.

I added it. @sum01 PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants