[OpenWrt-Devel] include/cmake: fix compilation with a host subdir
diff mbox series

Message ID 20200206193343.23727-1-rosenp@gmail.com
State New
Headers show
Series
  • [OpenWrt-Devel] include/cmake: fix compilation with a host subdir
Related show

Commit Message

Rosen Penev Feb. 6, 2020, 7:33 p.m. UTC
Some packages such as libcxx do not accept being build in the same
directory, which breaks host compilation.

This commit adds the same behavior present for target builds.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 include/cmake.mk      | 4 +++-
 include/host-build.mk | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/include/cmake.mk b/include/cmake.mk
index 2726b83a1e..3f69d403e9 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -8,6 +8,7 @@  endif
 
 CMAKE_BINARY_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR))
 CMAKE_SOURCE_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
+HOST_CMAKE_BINARY_DIR = $(HOST_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR))
 HOST_CMAKE_SOURCE_DIR = $(HOST_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
 MAKE_PATH = $(firstword $(CMAKE_BINARY_SUBDIR) .)
 
@@ -84,7 +85,8 @@  endef
 Build/InstallDev = $(if $(CMAKE_INSTALL),$(Build/InstallDev/cmake))
 
 define Host/Configure/Default
-	(cd $(HOST_BUILD_DIR); \
+	mkdir -p $(HOST_CMAKE_BINARY_DIR)
+	(cd $(HOST_CMAKE_BINARY_DIR); \
 		CFLAGS="$(HOST_CFLAGS)" \
 		CXXFLAGS="$(HOST_CFLAGS)" \
 		LDFLAGS="$(HOST_LDFLAGS)" \
diff --git a/include/host-build.mk b/include/host-build.mk
index 9fc14241c6..1270ca393e 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -102,7 +102,7 @@  endef
 
 define Host/Compile/Default
 	+$(HOST_MAKE_VARS) \
-	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR)/$(MAKE_PATH) \
 		$(HOST_MAKE_FLAGS) \
 		$(1)
 endef