加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

为什么CMake检查C编译器?

发布时间:2020-12-16 10:07:43 所属栏目:百科 来源:网络整理
导读:我想构建一个构建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-eab
我想构建一个构建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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读