当前位置:网站首页>[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的编译参数。
边栏推荐
- 800+ PHP grammar and words are proficient only after you have used them
- Php+sql get the field name and detailed attributes of MySQL data table
- IS_ERR()
- traefik ingress实践
- Sound and shadow 2022 heavy release! Detailed explanation of the new functions of Huisheng Huiying 2022
- C语言刷题 | 输入一个数输出对应的值(13)
- Centos7安装PostgreSQL12
- File expert ---multer
- XSS vulnerability attack
- Express bird of Express query demonstration code (php+curl)
猜你喜欢

希望越来越多的女性从事科技工作
![[network security officer] an attack technology that needs to be understood - high hidden and high persistent threats](/img/c9/c0ee95e816cac698f5397cc369d9ec.jpg)
[network security officer] an attack technology that needs to be understood - high hidden and high persistent threats

DOM编程

Volumedetect of ffmpeg
![[node] theory + practice enables you to win sessions and cookies](/img/26/ef15896094d1887619c6ba9f6f287a.png)
[node] theory + practice enables you to win sessions and cookies

为啥要使用梯度下降法

MySQL中常用的SQL语句

逻辑回归和线性回归

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

File upload attack and protection
随机推荐
为啥要使用梯度下降法
Audio and video 2022 beauty function introduction teach you to play video beauty
Originality: dozens of lines of pure PHP code decrypt goto encrypted PHP single file [for learning only]
Win+sublime Text3 + go 1.9.2 environment setup diagram
Apprentissage automatique | nltk Erreur de téléchargement des données | solution d'erreur de téléchargement du corpus stopwords pour nltk
Curl grasping stock information
Traifik ingress practice
Servlet的生命周期
Logistic regression and linear regression
Php+sql get the field name and detailed attributes of MySQL data table
mknod
simple_strtoull字符转换相关函数
希望越来越多的女性从事科技工作
In the monorepo learning, execute NPM run build to report error[err\u require\esm] of ES module
VMware安装Kali
两个线程各执行100次i++,得到的可能值
逻辑回归和线性回归
800+ PHP grammar and words are proficient only after you have used them
DHCP中继代理
Embedded development terminology concept summary