Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Let CMake not detect C++ compiler

Tags:

cmake

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?

like image 845
ekd123 Avatar asked Aug 19 '12 02:08

ekd123


People also ask

How does CMake know which compiler to use?

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.

Does CMake use GCC?

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.

What is CXX compiler?

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 .


2 Answers

It is better to use LANGUAGES C That also combines with the more common use

project(projectName VERSION 1.0 LANGUAGES C)

like image 24
user3021380 Avatar answered Sep 28 '22 18:09

user3021380


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.

like image 198
dans3itz Avatar answered Sep 28 '22 16:09

dans3itz