I'm working on a C project. But others told me that they couldn't build it because they didn't have a C++ compiler.
I have no idea how to disable C++'s detection. How to do this?
CMake needs a way to determine which compiler to use to invoke the linker. This is determined by the LANGUAGE property of source files of the target , and in the case of static libraries, the LANGUAGE of the dependent libraries. The choice CMake makes may be overridden with the LINKER_LANGUAGE target property.
Usually under Linux, one uses CMake to generate a GNU make file which then uses gcc or g++ to compile the source file and to create the executable. A CMake project is composed of source files and of one or several CMakeLists.
This is a CMake Environment Variable. Its initial value is taken from the calling process environment. Preferred executable for compiling CXX language files. Will only be used by CMake on the first configuration to determine CXX compiler, after which the value for CXX is stored in the cache as CMAKE_CXX_COMPILER .
It is better to use LANGUAGES C That also combines with the more common use
project(projectName VERSION 1.0 LANGUAGES C)
Detecting C and C++ toolchains is the default behavior for CMake. To disable this behavior, you'll need to manually enable the language. If it's project wide, you can explicitly tag the project as 'C' by using project(projectName C)
. This information is in the CMake documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With