[openwrt/openwrt] build: pass CPPFLAGS to cmake build

LEDE Commits lede-commits at lists.infradead.org
Mon Feb 16 16:48:59 PST 2026


hauke pushed a commit to openwrt/openwrt.git, branch openwrt-25.12:
https://git.openwrt.org/ff3fad172d285b1504d54739f9ab7dfb23cf66cb

commit ff3fad172d285b1504d54739f9ab7dfb23cf66cb
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Mon Feb 16 00:49:15 2026 +0100

    build: pass CPPFLAGS to cmake build
    
    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 at hauke-m.de>
    (cherry picked from commit 7bf8d568f6c83411041e504e0ca231d4081c2534)
---
 include/cmake.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/cmake.mk b/include/cmake.mk
index b6e485eb4f..29c5aacb83 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -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 \




More information about the lede-commits mailing list