Skip to content

Set project as C project in CMakeLists.txt#2312

Merged
Mab879 merged 1 commit intoOpenSCAP:mainfrom
Tropicao:enforce-c-in-cmakelist
Feb 16, 2026
Merged

Set project as C project in CMakeLists.txt#2312
Mab879 merged 1 commit intoOpenSCAP:mainfrom
Tropicao:enforce-c-in-cmakelist

Conversation

@Tropicao
Copy link
Contributor

The openscap tool has been recently integrated in the buildroot build system ([1]), which makes the openscap tool buildable for a wide variety or architectures/OSes, with a wide variety of toolchains. When the corresponding compilers are not supporting C++ projects (as it is often the case with a buildroot toolchain in minimal configuration), the build breaks on the following error (see [2] for an example):

-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /bin/false
-- Check for working CXX compiler: /bin/false - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:73 (message):
The C++ compiler

  "/bin/false"

is not able to compile a simple test program.

It fails with the following output:

  Change Dir: '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'

  Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_1834b/fast
  make[1]: Entering directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'
  /usr/bin/make  -f CMakeFiles/cmTC_1834b.dir/build.make CMakeFiles/cmTC_1834b.dir/build
  make[2]: Entering directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'
  Building CXX object CMakeFiles/cmTC_1834b.dir/testCXXCompiler.cxx.o
  /bin/false    -o CMakeFiles/cmTC_1834b.dir/testCXXCompiler.cxx.o -c /home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI/testCXXCompiler.cxx
  make[2]: *** [CMakeFiles/cmTC_1834b.dir/build.make:81: CMakeFiles/cmTC_1834b.dir/testCXXCompiler.cxx.o] Error 1
  make[2]: Leaving directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'
  make[1]: *** [Makefile:134: cmTC_1834b/fast] Error 2
  make[1]: Leaving directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'

CMake will not be able to correctly generate this project.

Call Stack (most recent call first):
CMakeLists.txt:11 (project)

openscap does not have any C++ code to build, so restricting builds to toolchains supporting C++ is likely over-constraining, the configuration step should rather not try to check C++ support.

Enforce the project as a C project in CMakeLists.txt to make sure not to test C++ features on the used toolchain.

[1] https://buildroot.org/
[2] https://autobuild.buildroot.org/results/1fe550ffa79f0a083a450ae03fe067a8ab7336be/build-end.log

The openscap tool has been recently integrated in the buildroot build
system ([1]), which makes the openscap tool buildable for a wide variety
or architectures/OSes, with a wide variety of _compilers_. And so when
such compilers are not supporting C++ projects (as it is the case with a
default buildroot toolchain), the build breaks on the following error
(see [2] for an example):

  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - failed
  -- Check for working CXX compiler: /bin/false
  -- Check for working CXX compiler: /bin/false - broken
  CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:73 (message):
    The C++ compiler

      "/bin/false"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'

      Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_1834b/fast
      make[1]: Entering directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'
      /usr/bin/make  -f CMakeFiles/cmTC_1834b.dir/build.make CMakeFiles/cmTC_1834b.dir/build
      make[2]: Entering directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'
      Building CXX object CMakeFiles/cmTC_1834b.dir/testCXXCompiler.cxx.o
      /bin/false    -o CMakeFiles/cmTC_1834b.dir/testCXXCompiler.cxx.o -c /home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI/testCXXCompiler.cxx
      make[2]: *** [CMakeFiles/cmTC_1834b.dir/build.make:81: CMakeFiles/cmTC_1834b.dir/testCXXCompiler.cxx.o] Error 1
      make[2]: Leaving directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'
      make[1]: *** [Makefile:134: cmTC_1834b/fast] Error 2
      make[1]: Leaving directory '/home/autobuild/autobuild/instance-6/output-1/build/openscap-1.3.12/buildroot-build/CMakeFiles/CMakeScratch/TryCompile-tUydqI'

    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:11 (project)

openscap does not have any C++ code to build, so restricting builds to
toolchains supporting C++ is overconstraining, the configuration step
should rather not try to check C++ support.

Enforce the project as a C project in CMakeLists.txt to make sure not to
test C++ features on the used toolchain.

[1] https://buildroot.org/
[2] https://autobuild.buildroot.org/results/1fe550ffa79f0a083a450ae03fe067a8ab7336be/build-end.log

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
@Mab879 Mab879 self-assigned this Feb 16, 2026
@Mab879 Mab879 merged commit 5a8c7f1 into OpenSCAP:main Feb 16, 2026
20 checks passed
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