Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is CMake checking for the C++ compiler?

Tags:

cmake

I would like to build a minimal example to build a C program. I used this CMakeLists.txt file:

cmake_minimum_required(VERSION 3.6)

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
#set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")

set(CMAKE_EXE_LINKER_FLAGS "--specs=nosys.specs" CACHE INTERNAL "")

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

project("funambule")

list(
    APPEND src
        main.c
)

add_executable(
    funambule
    ${src}
)

When I run cmake .. CMake absolutely want to check the C++ compiler even though I don't need one. How can I prevent it to do this useless check?

-- The C compiler identification is GNU 5.4.1
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /cygdrive/c/Users/NoOne/Home/bin/arm-none-eabi-gcc
-- Check for working C compiler: /cygdrive/c/Users/NoOne/Home/bin/arm-none-eabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/CC
-- Check for working CXX compiler: /usr/bin/CC -- broken
...
like image 945
nowox Avatar asked Oct 11 '25 14:10

nowox


1 Answers

This is the default behaviour of CMake. To change it, you should specify language for your project using:

project(<PROJECT-NAME> [LANGUAGES])

From CMake documentation:

Optionally you can specify which languages your project supports. Example languages are C, CXX (i.e. C++), Fortran, etc. By default C and CXX are enabled if no language options are given. Specify language NONE, or use the LANGUAGES keyword and list no languages, to skip enabling any languages.

like image 97
syntagma Avatar answered Oct 16 '25 12:10

syntagma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!