summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile17
-rw-r--r--package/Makefile.in8
2 files changed, 24 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a5a37a1ee..04783f2ef 100644
--- a/Makefile
+++ b/Makefile
@@ -363,7 +363,7 @@ $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
dirs: $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
$(HOST_DIR) $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(STAMP_DIR)
-$(BASE_TARGETS): dirs
+$(BASE_TARGETS): dirs $(O)/toolchainfile.cmake
$(BUILD_DIR)/buildroot-config/auto.conf: $(CONFIG_DIR)/.config
$(MAKE) $(EXTRAMAKEARGS) silentoldconfig
@@ -372,6 +372,21 @@ prepare: $(BUILD_DIR)/buildroot-config/auto.conf
world: prepare dependencies dirs $(BASE_TARGETS) $(TARGETS_ALL)
+$(O)/toolchainfile.cmake:
+ @echo -en "\
+ set(CMAKE_SYSTEM_NAME Linux)\n\
+ set(CMAKE_C_COMPILER $(CMAKE_TARGET_CC))\n\
+ set(CMAKE_CXX_COMPILER $(CMAKE_TARGET_CXX))\n\
+ set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(CMAKE_TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\
+ set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(CMAKE_TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\
+ set(CMAKE_INSTALL_SO_NO_EXE 0)\n\
+ set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\
+ set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\
+ set(ENV{PKG_CONFIG_SYSROOT_DIR} \"$(STAGING_DIR)\")\n\
+ " > $@
.PHONY: all world dirs clean distclean source outputmakefile \
$(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
diff --git a/package/Makefile.in b/package/Makefile.in
index 644eb1f47..599f68494 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -143,6 +143,14 @@ TARGET_CC := $(CCACHE) $(TARGET_CC)
TARGET_CXX := $(CCACHE) $(TARGET_CXX)
endif
+# * CMake doesn't support having the --sysroot option directly in the
+# compiler path, so move this option to CFLAGS/CXXFLAGS variables.
+# * Don't use ccache because then CMake will fail to detect compiler.
+CMAKE_TARGET_CC = $(filter-out --sysroot=%,$(TARGET_CC_NOCCACHE))
+CMAKE_TARGET_CXX = $(filter-out --sysroot=%,$(TARGET_CXX_NOCCACHE))
+CMAKE_TARGET_CFLAGS = $(filter --sysroot=%,$(TARGET_CC_NOCCACHE)) $(TARGET_CFLAGS)
+CMAKE_TARGET_CXXFLAGS = $(filter --sysroot=%,$(TARGET_CXX_NOCCACHE)) $(TARGET_CXXFLAGS)
+
ifeq ($(BR2_STRIP_strip),y)
STRIP_DISCARD_ALL:=--discard-all
STRIP_STRIP_UNNEEDED:=--strip-unneeded