当前位置:网站首页>[cmake命令笔记]target_compile_options
[cmake命令笔记]target_compile_options
2022-06-22 09:17:00 【蓝域小兵】
编译basalt时碰到这个命令,basalt使用的第三方库pangolin老是报错:
CMake Error at thirdparty/CMakeLists.txt:67 (target_compile_options):
Cannot specify compile options for target "pangolin" which is not built by
this project.
CMake Error at thirdparty/CMakeLists.txt:118 (get_target_property):
get_target_property() called with non-existent target "pangolin".
CMake Error at thirdparty/CMakeLists.txt:134 (get_target_property):
get_target_property() called with non-existent target "pangolin".
CMake Error at thirdparty/CMakeLists.txt:142 (set_target_properties):
set_target_properties Can not find target to add properties to: pangolin
但是这和这个命令并没有什么关系,这个错误貌似是因为我在下载第三方库的时候,不是使用的git clone --recursive,而是手动下载的第三方库到thirdparty目录下,因此可能没有感知到pangolin的存在,然后我在basalt项目根目录下使用git submodule init和git submodule update,问题愉快地解决了。
这里记录target_compile_options命令的用法
cmake原始文档地址
这个命令是为某个需要编译的目标增加编译选项,比如在前面添加的add_executable()或者add_library(),这两个命令表示你要编译一个可执行文件或者一个库,这就是编译目标(target)。
命令的参数选项如下:
target_compile_options(<target> [BEFORE]
<INTERFACE|PUBLIC|PRIVATE> [items1...]
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
target_compile_options会增加选项(options)到COMPILE_OPTIONS或者INTERFACE_COMPILE_OPOTIONS目标属性(也就是增加编译选项的意思)。这些选项会在编译给定目标(<target>)时使用,给定目标必须已经通过add_executable()或者add_library()这种命令添加到项目中,并且不能是别名目标。
下面看可选参数
如果指定了BEFORE,这个命令中的选项将放到所有属性之前(prepended)而不是之后(appended)。INTERFACE, PUBLIC和PRIVATE关键词用于指定随后的参数的作用域。PRIVATE和PUBLIC项将填充<target>的COMPILE_OPTIONS属性。PUBLIC和INTERFACE项将填充<target>的INTERFACE_COMPILE_OPTIONS属性。
随后的参数就是指定的编译选项。
编译选项就是CMAKE调用编译器时的编译参数,每个编译器都有一些编译参数,有的是共通的,有的是编译器相关的,其实我认为所有的构建工具,编译工具,最终都是为了得到一个编译器命令行,这个命令行的执行命令是编译器的编译程序,命令参数就是这些编译参数。使用VisualStudio的同学可以查看属性配置-C/C+±命令行,里面就是VS的编译参数。
边栏推荐
- Php+mysqli create a table, read multiple items, add, modify and query a complete instance
- [uni app] actual combat summary (including multi terminal packaging)
- Php+stripe payment API, the latest PHP version of stripe overseas payment tutorial
- Kali Trojan invades win7 system
- . A use of file link library
- 在ensp上做多出口服務器映射
- 在ensp上做防火墙的双机热备
- Stream stream creation_ Operation_ Collection_ case
- 重写?重载?你晕了吗?
- copy_from_user和copy_to_user
猜你喜欢

一个老开源人的自述-如何干好开源这件事

Audio and video 2022 beauty function introduction teach you to play video beauty

Lifecycle of Servlet

File expert ---multer

Common SQL statements in MySQL

模糊查询和聚合函数

Shengdun technology joined dragon lizard community to build a new open source ecosystem

Byte/byte? Don't get dizzy!

使用ELK保存Syslog、Netflow日志和审计网络接口流量
![Let you get started [uni app]](/img/e7/bc33d54a345901f67afa856769045f.png)
Let you get started [uni app]
随机推荐
Comparison of interface abstract classes
Process status summary
C language question brushing | three item operation to realize capital judgment (16)
PHP login registration page
一个老开源人的自述-如何干好开源这件事
Network security Kali penetration learning how to conduct Nessus vulnerability detection
C语言刷题 | 输入一个数输出对应的值(13)
Zabbix5系列-使用温湿度传感器监控机房温湿度 (二十)
==经典面试题
Lifecycle of Servlet
Introduction to ten free and open source PHP online stores abroad
Fuzzy query and aggregate function
How C processes use non static methods
PHP online common color comparison table
微服务架构概述
Common SQL statements in MySQL
重写?重载?你晕了吗?
C语言刷题 | 三目运算实现判断大写(16)
The difference between scnprintf and snprintf
Logistic regression and linear regression