summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2011-01-26 22:18:42 +0100
committerPeter Korsgaard <jacmet@sunsite.dk>2011-01-26 23:22:32 +0100
commit73144a6e02a67f9e7da276cd35c9d146e187653a (patch)
tree1b38a45bfc7d7b016524d774bc8c4209112717ce
parent0fa46e59db087478b4844b2358a496eacdef7569 (diff)
downloadbuildroot-novena-73144a6e02a67f9e7da276cd35c9d146e187653a.tar.gz
buildroot-novena-73144a6e02a67f9e7da276cd35c9d146e187653a.zip
Makefile: generate CMake toolchain-file in $(O)
A CMake toolchain-file makes it easy to develop CMake-based packages outside of Buildroot. Just give the toolchain-file to CMake via the -DCMAKE_TOOLCHAIN_FILE=... option. Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com> Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
-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