aboutsummaryrefslogtreecommitdiff
path: root/support/misc
diff options
context:
space:
mode:
authorGravatar Samuel Martin <s.martin49@gmail.com>2014-06-01 11:24:24 +0200
committerGravatar Peter Korsgaard <peter@korsgaard.com>2014-06-01 22:15:43 +0200
commit9033d90118689a50b13b3764a927ec1b202624bf (patch)
treed22e74d2644ae7c82c217c16a652f67dcc37cdb3 /support/misc
parent85fea5d9538e8ea1d1f83c7aa517ffebff7a4f1f (diff)
downloadbuildroot-9033d90118689a50b13b3764a927ec1b202624bf.tar.gz
buildroot-9033d90118689a50b13b3764a927ec1b202624bf.tar.bz2
pkg-cmake.mk: do not hardcode absolute path in toolchainfile.cmake
The patch allows sharing or moving the toolchains. This is a step toward making the toolchain/sdk relocatable. Closes #6818 [Peter: reword comment as suggested by Thomas] Signed-off-by: Samuel Martin <s.martin49@gmail.com> Cc: Uwe Strempel <u.strempel@googlemail.com> Cc: Arnout Vandecappelle <arnout@mind.be> Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'support/misc')
-rw-r--r--support/misc/toolchainfile.cmake.in17
1 files changed, 12 insertions, 5 deletions
diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index e8cc378be8..27a0af1e8e 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -3,18 +3,25 @@
# CMake toolchain file for Buildroot
#
+# In order to allow the toolchain to be relocated, we calculate the
+# HOST_DIR based on this file's location: $(HOST_DIR)/usr/share/buildroot
+# and store it in RELOCATED_HOST_DIR.
+# All the other variables that need to refer to HOST_DIR will use the
+# RELOCATED_HOST_DIR variable.
+string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST_DIR})
+
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS" FORCE)
set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS" FORCE)
set(CMAKE_INSTALL_SO_NO_EXE 0)
-set(CMAKE_PROGRAM_PATH "@@HOST_DIR@@/usr/bin")
-set(CMAKE_FIND_ROOT_PATH "@@STAGING_DIR@@")
+set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")
+set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(ENV{PKG_CONFIG_SYSROOT_DIR} "@@STAGING_DIR@@")
+set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
-set(CMAKE_C_COMPILER "@@TARGET_CC_NOCCACHE@@")
-set(CMAKE_CXX_COMPILER "@@TARGET_CXX_NOCCACHE@@")
+set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")