Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/pkg-cmake.mk: add Platform/Buildroot-Initialize.cmake
@ 2026-01-17 10:31 Julien Olivain via buildroot
  2026-01-22 17:21 ` Gilles Talis
  2026-02-04  9:13 ` Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain via buildroot @ 2026-01-17 10:31 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain, Gilles Talis

Since commit [1] (core/pkg-cmake: provide our own platform
description), Buildroot is setting its own CMake platform
description. This description applies minor changes on top of
the CMake Linux platform, see [2] and [3]. The CMake system specific
script tries to include an initialization script, if present.
See [4].

Since in commit [1] we set the CMAKE_SYSTEM_NAME to "Buildroot"
(rather than "Linux"), CMake will search for a
"Platform/Buildroot-Initialize.cmake" which does not exist, and
continue normally, since the include is optional.

The "Platform/Linux-Initialize.cmake" file is the one setting the
LINUX [6] and UNIX [7] variables, which are expected to be true on
a linux compatible system. In Buildroot, it is currently not
included, so those variables are unset.

If a CMake package in Buildroot has a construct such as:

    if(LINUX)
        # ...do things...
    else()
        message(FATAL_ERROR "System not supported")
    endif()

It will fail at configuration time.

This situation happened when trying to add the btop++ package
in Buildroot. See [8].

Since the initial intent of commit [1] was to make the Buildroot
CMake system inherit from Linux plus some fixups, this commit simply
adds a Buildroot-Initialize.cmake file that includes the
Linux-Initialize.cmake one from CMake. This will have the effect
to properly define the LINUX and UNIX variables.

[1] https://gitlab.com/buildroot.org/buildroot/-/commit/c69b14fe2f72d8134057b115884c04a2bf27d410
[2] https://gitlab.com/buildroot.org/buildroot/-/blob/2025.11/support/misc/Buildroot.cmake#L1-4
[3] https://cmake.org/cmake/help/v4.2/variable/CMAKE_SYSTEM_NAME.html
[4] https://gitlab.kitware.com/cmake/cmake/-/blob/v4.2.1/Modules/CMakeSystemSpecificInitialize.cmake#L35
[5] https://gitlab.kitware.com/cmake/cmake/-/blob/v4.2.1/Modules/Platform/Linux-Initialize.cmake
[6] https://cmake.org/cmake/help/v4.2/variable/LINUX.html
[7] https://cmake.org/cmake/help/v4.2/variable/UNIX.html
[8] https://github.com/aristocratos/btop/blob/v1.4.6/CMakeLists.txt#L76

Reported-by: Gilles Talis <gilles.talis@gmail.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 package/pkg-cmake.mk                    | 2 ++
 support/misc/Buildroot-Initialize.cmake | 1 +
 2 files changed, 3 insertions(+)
 create mode 100644 support/misc/Buildroot-Initialize.cmake

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index ba287d244a..f572bdebb3 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -287,6 +287,8 @@ define TOOLCHAIN_CMAKE_INSTALL_FILES
 		> $(HOST_DIR)/share/buildroot/toolchainfile.cmake
 	$(Q)$(INSTALL) -D -m 0644 support/misc/Buildroot.cmake \
 		$(HOST_DIR)/share/buildroot/Platform/Buildroot.cmake
+	$(Q)$(INSTALL) -D -m 0644 support/misc/Buildroot-Initialize.cmake \
+		$(HOST_DIR)/share/buildroot/Platform/Buildroot-Initialize.cmake
 endef
 
 TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_CMAKE_INSTALL_FILES
diff --git a/support/misc/Buildroot-Initialize.cmake b/support/misc/Buildroot-Initialize.cmake
new file mode 100644
index 0000000000..3451562f08
--- /dev/null
+++ b/support/misc/Buildroot-Initialize.cmake
@@ -0,0 +1 @@
+include(Platform/Linux-Initialize)
-- 
2.52.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-04  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-17 10:31 [Buildroot] [PATCH 1/1] package/pkg-cmake.mk: add Platform/Buildroot-Initialize.cmake Julien Olivain via buildroot
2026-01-22 17:21 ` Gilles Talis
2026-02-04  9:13 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox