Setting CMAKE_SYSTEM_NAME causes CMAKE_CROSSCOMPILING to be true even if host OS and target OS are equal
I tried to use the new install(RUNTIME_DEPENDENCIES) command in version 3.21, but got the following error message:
install TARGETS RUNTIME_DEPENDENCIES is not supported when cross-compiling.
I was surprised, since I am on windows and not cross compiling at all.
The reason for this is that I had "cacheVariables": { "CMAKE_SYSTEM_NAME": "Windows" }
in my CMakePresets.json file, and this caused CMAKE_CROSSCOMPILING to be set to true in the generated CMakeSystem.cmake file. Removing CMAKE_SYSTEM_NAME from the presets file fixes this, and when looking at the generated CMakeSystem.cmake file I see set(CMAKE_SYSTEM_NAME "Windows")
, exactly as before.
Specifying CMAKE_SYSTEM_PROCESSOR behaves as expected: It does not set CMAKE_CROSSCOMPILING to true if it is equal to the host processor. The same is true for CMAKE_SYSTEM_VERSION, but in that case one could actually argue that compiling for a specific windows SDK is some sort of cross-compiling.
I think it would be good if CMAKE_SYSTEM_NAME would be aligned to CMAKE_SYSTEM_PROCESSOR, i.e. not setting CMAKE_CROSSCOMPILING to true if it was explicitly set to the same value that would be chosen automatically.