]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
build: pass CPPFLAGS to cmake build 22042/head
authorHauke Mehrtens <hauke@hauke-m.de>
Sun, 15 Feb 2026 23:49:15 +0000 (00:49 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 17 Feb 2026 00:29:57 +0000 (01:29 +0100)
The TARGET_CPPFLAGS contain the include paths used by OpenWrt. This also
contains the including of the fortify sources headers. If they are not
provided, the applications will not use fortify sources headers when
compiled against musl. Add them to cmake builds too. cmake does not
support a special CPPFLGS option [0], just add them to CFLAGS and
CXXFLAGS like we also do it for meson and normal make.
This should fix fortify sources support for cmake builds.

I found this explanation for the flags:
 * CFLAGS: C flags, passed during compile AND link
 * CXXFLAGS: C++ flags, passed during compile AND link
 * CPPFLAGS: pre-processor flags, passed ONLY during compile
 * LDFLAGS: linker flags, passed ONLY during link

[0]: https://gitlab.kitware.com/cmake/cmake/-/issues/12928

Link: https://github.com/openwrt/openwrt/pull/22042
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
include/cmake.mk

index b6e485eb4ffe20a612707bf9cea7658ac7d349b9..29c5aacb83191a8cfacddfd818d106e871bc1136 100644 (file)
@@ -89,8 +89,8 @@ endif
 define Build/Configure/Default
        mkdir -p $(CMAKE_BINARY_DIR)
        (cd $(CMAKE_BINARY_DIR); \
-               CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
-               CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
+               CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
+               CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
                LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
                cmake \
                        --no-warn-unused-cli \