Skip to content

cmake: require CXX only for selected build targets - #188

Open
fhgffy wants to merge 2 commits into
radarsat1:masterfrom
fhgffy:fix-cmake-c-only-tests-off
Open

fhgffy wants to merge 2 commits into
radarsat1:masterfrom
fhgffy:fix-cmake-c-only-tests-off

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 6, 2026 •

Copy link
Copy Markdown

With WITH_TESTS=OFF, the default C library still enabled CXX at project() because WITH_CPP_TESTS was checked before the later tests-off handling.

Enable CXX only when both test options are enabled, or when BUILD_LANGUAGE=CXX is explicitly requested. The production fix remains this one condition change.

Add a Debian C-only CI job that installs the C build dependencies, verifies that g++, c++ and clang++ are absent, and builds with both CMake and Autotools. Removed the invalid-CXX-path configuration probe and its source-distribution entry.

Validation in a Debian bookworm chroot with GCC 12 and no C++ compiler:

  • Exact base 025f277: CMake with WITH_TESTS=OFF fails because no CMAKE_CXX_COMPILER can be found.
  • Patched production source: CMake with WITH_TESTS=OFF and WITH_CPP_TESTS=OFF builds succeed; Autotools with --disable-tests --disable-doc builds and installs successfully.
  • Build directories were reused during the final replay; no fresh full test-suite run is claimed. The new hosted CI run is separate and pending.

Earlier local tests and consumer checks used a different toolchain with C++ installed. They are historical evidence. Windows and macOS were not rerun locally; BUILD_LANGUAGE=CXX and network-enabled tests retain the previously reported baseline limitations.

@fhgffy
fhgffy marked this pull request as ready for review October 6, 2026 18:09
@radarsat1

Copy link
Copy Markdown
Owner

Hm. I think I see the problem you're describing, but I think the proposed solution seems a bit convoluted. I don't like sniffing things at build time like that if it can be avoided, it's maybe better to just give cmake the right flags. But what I'd be for is maybe adding a build environment to the github action that explicitly tests both build systems in an environment with no C++ compiler. Then go from there with figuring out the minimal changes needed to ensure it works without a C++ compiler.

@fhgffy

fhgffy commented Oct 9, 2026

Copy link
Copy Markdown
Author

Added a Debian C-only CI job for both CMake and Autotools in 3cee5b4, and removed the invalid-CXX-path probe. In a bookworm chroot with GCC 12 and no C++ compiler, the exact base fails CMake configuration at project(), while the patched source builds with WITH_TESTS=OFF and WITH_CPP_TESTS=OFF; Autotools with --disable-tests --disable-doc builds and installs too. The production change remains the single condition. The new hosted CI is still pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants