support/cmake: Explicitly set CMAKE_SYSTEM
authorFrank Vanbever <frank.vanbever@essensium.com>
Sun, 17 Mar 2019 16:48:17 +0000 (17:48 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Sat, 3 Aug 2019 17:17:32 +0000 (19:17 +0200)
Some packages test for CMAKE_SYSTEM explicitly[1]

CMAKE_SYSTEM is comprised of CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_VERSION.
It defaults to CMAKE_SYSTEM_NAME if CMAKE_SYSTEM_VERSION is not set[2]

At the point CMAKE_SYSTEM_NAME is set to "Linux" CMAKE_SYSTEM is already
constructed. Setting it explicitly ensures that it is the correct value.

This is because we do set CMAKE_SYSTEM_NAME twice, in fact:

  - first in toolchainfile.cmake, so that we tell cmake to use the
    "Buildroot" platform,

  - second, in the Buildroot.cmake platform definition itself, so that
    we eventually behave like the Linux platform.

We also set CMAKE_SYSTEM_VERSION to 1, and so the real CMAKE_SYSTEM
value should be set to Linux-1 if we were to follow the documentation to
the letter.

However, for Linux, the version does not matter, and in some situations
may even be harmful (that was reported in one of the commits that
introduce Buildroot.cmake and toolchainfile.cmake).

[1] Fluidsynth https://github.com/FluidSynth/fluidsynth/blob/0cd44d00e1ec9a905d51163efde7b70ff8ae0ba3/CMakeLists.txt#L80
[2] https://cmake.org/cmake/help/git-master/variable/CMAKE_SYSTEM.html#variable:CMAKE_SYSTEM

Signed-off-by: Frank Vanbever <frank.vanbever@mind.be>
Acked-by: Yann E. MORIN <yann.morin.1998@free.fr>
[Peter: update commit message with description from Yann]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
support/misc/Buildroot.cmake

index 9f5f565255cec2306501ed57d8541cddc2864447..761b6d7ae25ad5cafe595656af98e30ec0866668 100644 (file)
@@ -1,5 +1,6 @@
 # Impersonate a Linux system. Afterall, that's what we are...
 set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM ${CMAKE_SYSTEM_NAME})
 include(Platform/Linux)
 
 # Override problematic settings, to avoid RPATH against host lib directories.