[OpenWrt-Devel] [PATCH] fix include/cmake.mk so it allows out of source tree builds

Luke McKee hojuruku at gmail.com
Sat Jul 23 15:11:50 EDT 2016


If you change PKG_BUILD_DIR it could work - but then you can't patch
the source directory.
https://github.com/openwrt/openwrt/pull/41

Some packages need out of source tree building with cmake, for example
when building kernel modules.
See an example here:
https://sourceforge.net/p/accel-ppp/code/ci/master/tree/README

This adds a new variable that can be used in Makefiles $(CMAKE_BINARY_DIR)

Signed-off-by: Luke McKee hojuruku at gmail.com

@nbd168 agrees, patching the include is the only way to go.

This also needs to get merged into LEDE or a new package I'm working
on accel-ppp (give me a week of testing etc) won't work.

diff --git a/include/cmake.mk b/include/cmake.mk
index 009c6c2..d75b3ef 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -6,7 +6,8 @@ ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
   MAKE_FLAGS+=VERBOSE=1
 endif

-CMAKE_SOURCE_DIR:=.
+CMAKE_BINARY_DIR?=$(PKG_BUILD_DIR)
+CMAKE_SOURCE_DIR?=.

 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
   cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1)
@@ -35,7 +36,7 @@
CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOST)
 CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions

 define Build/Configure/Default
-       (cd $(PKG_BUILD_DIR); \
+       (cd $(CMAKE_BINARY_DIR); \
                CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
                CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
                LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list