当前位置:网站首页>Cmake tips
Cmake tips
2022-06-28 06:32:00 【panamera12】
1、cmake to CMakeLists.txt Pass parameters
Command line cmake -DTARGET_CPU:STRING=x86
then , We can do that CMakeLists.txt Using it to help us implement some logic :
if(TARGET_CPU STREQUAL "x86")
#do something
else()
#do something
endif()
2、shell to CMakeLists.txt Pass parameters
a.sh
export TYPES_RELEASE_A20="A20"
export PROJECT_BUILD_TYPE=$1
CMakeLists.txt
if($ENV{PROJECT_BUILD_TYPE} STREQUAL $ENV{TYPES_DEBUG_X86} OR $ENV{PROJECT_BUILD_TYPE} STREQUAL $ENV{TYPES_DEBUG_NDK28})
add_definitions(-DAAA_HOST_BBB)
endif()
3、add_definitions Usage of
add_definitions The function and C/C++ Medium #define It's the same
For example, I have the following two files , A source file main.cpp, One CMakeLists.txt
Source file main.cpp
#include <iostream>
int main()
{
#ifdef TEST_IT_CMAKE
std::cout<<"in ifdef"<<std::endl;
#endif
std::cout<<"not in ifdef"<<std::endl;
}
cmake file CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(optiontest)
add_executable(optiontest main.cpp)
option(TEST_IT_CMAKE "test" ON)
message(${TEST_IT_CMAKE})
if(TEST_IT_CMAKE)
message("itis" ${TEST_IT_CMAKE})
add_definitions(-DTEST_IT_CMAKE)
endif()
adopt option Set a variable , And pass add_definitions Convert it to #define TEST_IT_CMAKE
When variables are ON when , The output of the program is
in ifdef
not in ifdef
When variables are OFF when , The output of the program is
not in ifdef
边栏推荐
- AutoCAD C polyline small acute angle detection
- Uni app wechat applet sharing function
- Call interface event API common event methods
- 浮动与定位
- FPGA - 7 Series FPGA selectio -09- io of advanced logic resources_ FIFO
- 搭建你jmeter+jenkins+ant
- Parsing ng template with let total in NZ Pagination
- Promotion intégrale et ordre des octets de fin de taille
- EasyUI reset multi condition query
- fpm工具安装
猜你喜欢

选拔赛题目代码

Unity packaging webgl uses IIS to solve the error

Floating and positioning

Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics

异常处理(一)——空指针和数组索引越界

Freeswitch sets the maximum call duration

The custom cube UI pop-up dialog supports multiple and multiple types of input boxes

Promotion intégrale et ordre des octets de fin de taille

Some habits of it veterans in the workplace

Interpretation of Blog
随机推荐
Object object to list collection
语音增强-频谱映射
Difficulty calculation of Ethereum classic
Apple MDM bypass jailfree bypass MDM configuration lock free
Freeswitch uses origin to dialplan
整型提升和大小端字节序
调接口事件API常用事件方法
Example of MVVM framework based on kotlin+jetpack
小程序页面设置100%高度还是留白怎么办?
AutoCAD C# 多段线小锐角检测
socke.io長連接實現推送、版本控制、實時活躍用戶量統計
@RequestParam
FPGA - 7 Series FPGA selectio -09- io of advanced logic resources_ FIFO
Linked list (II) - Design linked list
图片按日期批量导入WPS表格
助力涨点 | YOLOv5结合Alpha-IoU
death_ satan/hyperf-validate
Install and manage multiple versions of PHP under mac
Integer promotion and size side byte order
API learning of OpenGL (2007) gltexcoordpointer