Skip to contentSkip to conversation

pkg-cmake: force check_language(CXX) to be false

PATCH Applied Thomas Devoogdt 3 participants 3 messages May 16, 2025 – Jun 3, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pkg-cmake: force check_language(CXX) to be false

See the code snippet below, which typically is used to check if C++ support can be enabled.

If we manually set CMAKE_CXX_COMPILER to /bin/false, then cmake will assume that it's fine, without having a real check. Otherwise, it will do a test run but somehow it falls back to /bin/c++, even when cross-compiling. Fix that by setting CXX to /bin/false.

```cmake
include(CheckLanguage)
check_language(CXX)

if(CMAKE_CXX_COMPILER)
    enable_language(CXX)
endif()
```
---
 package/pkg-cmake.mk | 1 +
 1 file changed, 1 insertion(+)
package/pkg-cmake.mk +1 -0
index c7032312fb..ba287d244a 100644
@@ -102,6 +102,7 @@ define $(2)_CONFIGURE_CMDS
 	cd $$($$(PKG)_BUILDDIR) && \
 	rm -f CMakeCache.txt && \
 	PATH=$$(BR_PATH) \
+	$$(if $$(BR2_INSTALL_LIBSTDCPP),,CXX=/bin/false) \
 	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
 		-G$$($$(PKG)_GENERATOR) \
 		-DCMAKE_MAKE_PROGRAM="$$($$(PKG)_GENERATOR_PROGRAM)" \
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 19 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Devoogdt <[email protected]> writes:

See the code snippet below, which typically is used to check if C++ support can be enabled.

If we manually set CMAKE_CXX_COMPILER to /bin/false, then cmake will assume that it's fine, without having a real check. Otherwise, it will do a test run but somehow it falls back to /bin/c++, even when cross-compiling. Fix that by setting CXX to /bin/false.

```cmake
include(CheckLanguage)
check_language(CXX)

if(CMAKE_CXX_COMPILER)
    enable_language(CXX)
endif()
```
Quoted 1 line

Committed, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Thomas Devoogdt
Quoted 17 lines · Thomas Devoogdt

See the code snippet below, which typically is used to check if C++ support can be enabled.

If we manually set CMAKE_CXX_COMPILER to /bin/false, then cmake will assume that it's fine, without having a real check. Otherwise, it will do a test run but somehow it falls back to /bin/c++, even when cross-compiling. Fix that by setting CXX to /bin/false.

```cmake
include(CheckLanguage)
check_language(CXX)

if(CMAKE_CXX_COMPILER)
     enable_language(CXX)
endif()
```
Quoted 1 line

Applied to 2025.02.x, thanks.

Regards,
Arnout

Quoted 9 lines
---
  package/pkg-cmake.mk | 1 +
  1 file changed, 1 insertion(+)
package/pkg-cmake.mk +0 -0
index c7032312fb..ba287d244a 100644

package/pkg-cmake.mk define $(2)_CONFIGURE_CMDS · line 108

Quoted 7 lines
package/pkg-cmake.mk +1 -0
@@ -102,6 +102,7 @@ define $(2)_CONFIGURE_CMDS
  	cd $$($$(PKG)_BUILDDIR) && \
  	rm -f CMakeCache.txt && \
  	PATH=$$(BR_PATH) \
+	$$(if $$(BR2_INSTALL_LIBSTDCPP),,CXX=/bin/false) \
  	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
  		-G$$($$(PKG)_GENERATOR) \
  		-DCMAKE_MAKE_PROGRAM="$$($$(PKG)_GENERATOR_PROGRAM)" \

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot