gpt4 book ai didi

cmake - 为什么 CMake 检查 C++ 编译器?

转载 作者:行者123 更新时间:2023-12-01 09:47:21 25 4
gpt4 key购买 nike

我想构建一个最小示例来构建 C 程序。我使用了这个 CMakeLists.txt 文件:

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}
)

当我运行 cmake . 时。 CMake 绝对想检查 C++ 编译器,即使我不需要。我怎样才能阻止它进行这种无用的检查?

-- 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
...

最佳答案

这是 CMake 的默认行为。要更改它,您应该使用以下方法为您的项目指定语言:

project(<PROJECT-NAME> [LANGUAGES])

来自 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.

关于cmake - 为什么 CMake 检查 C++ 编译器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45904483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com