当前位置:网站首页>CMakeLists中的add_definitions()函数
CMakeLists中的add_definitions()函数
2022-06-24 23:43:00 【惊鸿一博】
引言
其实这个函数在安装一些库的时候,它的CMakeLists里面就有这样的函数。典型的就是opencv了。
opencv安装时候有一些指令也是针对这个函数的,比如安装命令(随便搜索的):
cmake ../opencv-3.4.1 -DWITH_GTK_2_X=ON -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_TBB=ON\
-DBUILD_NEW_PYTHON_SUPPORT=ON -DWITH_V4L=ON -DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_OPENGL=ON \
-DENABLE_FAST_MATH=1 -DCUDA_FAST_MATH=1 -DWITH_CUBLAS=1 -DWITH_OPENMP=ON
其中-D后面的参数就是控制程序流向。
1.add_definitions()
官方解释. add_definitions — CMake 3.0.2 Documentation
2.应用
这种可以在我们更改别人代码做实验时使用,既不对其源码进行破坏,又可以添加自己的功能。之前都是在程序中进行#define,有了这个后可以直接在编译的时候进行选择。具体的,在工程CMakeLists.txt 中,使用add_definitions()函数控制代码的开启和关闭:
option(TEST_DEBUG "option for debug" OFF)
if (TEST_DEBUG)
add_definitions(-DTEST_DEBUG)
endif(TEST_DEBUG)
运行构建项目的时候可以添加参数控制宏的开启和关闭.
cmake -DTEST_DEBUG=1 .. #打开
cmake -DTEST_DEBUG=0 .. #关闭
在源码中就可以使用:
#ifdef TEST_DEBUG
...
...
#else
...
#endif
边栏推荐
- Intranet learning notes (6)
- After reciting the eight part essay, I won the hemp in June
- 14 bs对象.节点名称.name attrs string 获取节点名称 属性 内容
- Transformers Roberta如何添加tokens
- Network planning | [four network layers] knowledge points and examples
- automated testing
- GO同步等待组
- UnityShader入门精要——PBS基于物理的渲染
- js正则匹配数字、大小写字母、下划线、中线和点[通俗易懂]
- qt打包exe文件,解决“无法定位程序输入点_ZdaPvj于动态链接库Qt5Cored.dll”
猜你喜欢

Once beego failed to find bee after passing the go get command Exe's pit

Random list random generation of non repeating numbers

Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification

DSPACE的性能渲染问题

Is it out of reach to enter Ali as a tester? Here may be the answer you want

When they are in private, they have a sense of propriety

Leetcode 210: curriculum II (topological sorting)

Are programmers from Huawei, Alibaba and other large manufacturers really easy to find?

折叠屏将成国产手机分食苹果市场的重要武器

Software testing salary in first tier cities - are you dragging your feet
随机推荐
Folding screen will become an important weapon for domestic mobile phones to share the apple market
[I.MX6UL] U-Boot移植(六) 网络驱动修改 LAN8720A
当他们在私域里,掌握了分寸感
使用ShaderGraph制作边缘融合粒子Shader的启示
Random list random generation of non repeating numbers
Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (3) -- set the database to archive mode
Using qdomdocument to manipulate XML files in QT
Jetson nano from introduction to practice (cases: opencv configuration, face detection, QR code detection)
Detailed explanation of cache (for the postgraduate entrance examination of XD)
Test / development programmers, 30, do you feel confused? And where to go
软件测试人员的7个等级,据说只有1%的人能做到级别7
internship:svn的使用
Use of hashcat
計網 | 【四 網絡層】知識點及例題
请问polarDB数据库可以通过mysql进行数据源连接吗
微信小程序获取扫描二维码后携带的参数
NPM package publishing tutorial
Centos7.3 modifying MySQL default password_ Explain centos7 modifying the password of the specified user in MySQL
Resolution of cross reference in IDA
Smartctl opens the device and encounters permission denied problem troubleshooting process record