Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Martin <s.martin49@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 4/4] toolchainfile.cmake: set CXX variables wrt BR2_INSTALL_LIBSTDCPP value
Date: Sun,  8 Mar 2015 10:47:23 +0100	[thread overview]
Message-ID: <1425808043-32292-5-git-send-email-s.martin49@gmail.com> (raw)
In-Reply-To: <1425808043-32292-1-git-send-email-s.martin49@gmail.com>

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 package/pkg-cmake.mk                |  1 +
 support/misc/toolchainfile.cmake.in | 33 +++++++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 2404c40..c6b9eff 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -231,6 +231,7 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 	@mkdir -p $(@D)
 	sed \
 		-e 's:@@STAGING_SUBDIR@@:$(call qstrip,$(STAGING_SUBDIR)):' \
+		-e 's:@@TARGET_HAS_LIBSTDCXX@@:$(if $(BR2_INSTALL_LIBSTDCPP),TRUE,FALSE):' \
 		-e 's:@@TARGET_CFLAGS@@:$(call qstrip,$(TARGET_CFLAGS)):' \
 		-e 's:@@TARGET_CXXFLAGS@@:$(call qstrip,$(TARGET_CXXFLAGS)):' \
 		-e 's:@@TARGET_LDFLAGS@@:$(call qstrip,$(TARGET_LDFLAGS)):' \
diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index cd41254..395cf3f 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -17,6 +17,7 @@ set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot C
 set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")
 set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS")
 set(CMAKE_INSTALL_SO_NO_EXE 0)
+set(TARGET_HAS_LIBSTDCXX @@TARGET_HAS_LIBSTDCXX@@)
 
 set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")
 set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
@@ -35,25 +36,45 @@ if(DEFINED USE_CCACHE)
 	if(USE_CCACHE)
 		set(CMAKE_ASM_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
 		set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/usr/bin/ccache")
-		set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/usr/bin/ccache")
 		set(CMAKE_C_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
-		set(CMAKE_CXX_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		if(TARGET_HAS_LIBSTDCXX)
+			set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/usr/bin/ccache")
+			set(CMAKE_CXX_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		else()
+			message(STATUS "Disabling C++ compiler because libstdc++ is not installed in the target filsystem")
+			set(CMAKE_CXX_COMPILER "CMAKE_CXX_COMPILER-NOTFOUND")
+		endif()
 	else()
 		set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
-		set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		if(TARGET_HAS_LIBSTDCXX)
+			set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		else()
+			message(STATUS "Disabling C++ compiler because libstdc++ is not installed in the target filsystem")
+			set(CMAKE_CXX_COMPILER "CMAKE_CXX_COMPILER-NOTFOUND")
+		endif()
 	endif()
 else()
 	find_program(CCACHE ccache HINTS "${RELOCATED_HOST_DIR}/usr/bin")
 	if(CCACHE)
 		set(CMAKE_ASM_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
 		set(CMAKE_C_COMPILER "${CCACHE}")
-		set(CMAKE_CXX_COMPILER "${CCACHE}")
 		set(CMAKE_C_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
-		set(CMAKE_CXX_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		if(TARGET_HAS_LIBSTDCXX)
+			set(CMAKE_CXX_COMPILER "${CCACHE}")
+			set(CMAKE_CXX_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		else()
+			message(STATUS "Disabling C++ compiler because libstdc++ is not installed in the target filsystem")
+			set(CMAKE_CXX_COMPILER "CMAKE_CXX_COMPILER-NOTFOUND")
+		endif()
 		message(STATUS "ccache program has been found and will be used for the build.")
 		message(STATUS "  To disable ccache, add -DUSE_CCACHE=OFF on the cmake command line.")
 	else()
 		set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
-		set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		if(TARGET_HAS_LIBSTDCXX)
+			set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		else()
+			message(STATUS "Disabling C++ compiler because libstdc++ is not installed in the target filsystem")
+			set(CMAKE_CXX_COMPILER "CMAKE_CXX_COMPILER-NOTFOUND")
+		endif()
 	endif()
 endif()
-- 
2.3.2

  parent reply	other threads:[~2015-03-08  9:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-08  9:47 [Buildroot] [PATCH 0/4] CMake package and infra improvements Samuel Martin
2015-03-08  9:47 ` [Buildroot] [PATCH 1/4 v5] package/cmake: make ctest a target package too Samuel Martin
2015-03-08  9:53   ` Baruch Siach
2015-03-08 11:29     ` Samuel Martin
2015-03-15 17:41   ` Thomas Petazzoni
2015-03-08  9:47 ` [Buildroot] [PATCH 2/4 v2] package/cmake: only build what is necessary Samuel Martin
2015-03-15 17:52   ` Thomas Petazzoni
2015-03-08  9:47 ` [Buildroot] [PATCH 3/4] toolchainfile.cmake: only search the sysroot for CMake module Samuel Martin
2015-03-08 10:23   ` Yegor Yefremov
2015-03-16 21:17   ` Thomas Petazzoni
2015-03-08  9:47 ` Samuel Martin [this message]
2015-03-16 21:24   ` [Buildroot] [PATCH 4/4] toolchainfile.cmake: set CXX variables wrt BR2_INSTALL_LIBSTDCPP value Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425808043-32292-5-git-send-email-s.martin49@gmail.com \
    --to=s.martin49@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox