当前位置:网站首页>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
边栏推荐
- 【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
- AutoCAD C polyline self intersection detection
- Unity packaging webgl uses IIS to solve the error
- sql及list去重操作
- Teach you how to use UCOS
- Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
- Difficulty calculation of Ethereum classic
- 调接口事件API常用事件方法
- Freeswitch使用originate转dialplan
- KMP string
猜你喜欢

Unity packaging webgl uses IIS to solve the error

慢内容广告:品牌增长的长线主义

death_ satan/hyperf-validate

Yolov5 adds a small target detection layer

ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map

选拔赛题目代码

整型提昇和大小端字節序

Students who do not understand the code can also send their own token. The current universal dividend model can be divided into BSC and any generation B

YOLOv5增加小目标检测层

Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
随机推荐
Unity packaging webgl uses IIS to solve the error
Idea automatically adds comments when creating classes
Scripting and programming languages
mysql常用函数
[interval DP] stone consolidation
Build your jmeter+jenkins+ant
freeswitch设置最大呼叫时长
AttributeError: 'callable_iterator' object has no attribute 'next'
YYGH-BUG-02
Interpretation of Blog
FPGA - 7 Series FPGA selectio -08- oserdese2 of advanced logic resources
idea根据数据库表生成实体类
UPC -- expression evaluation
AutoCAD C # Polyline Small Sharp angle Detection
Floating and positioning
Configure multiple database connections using the SSM framework
sql及list去重操作
整型提昇和大小端字節序
Deleting MySQL under Linux
Uni app wechat applet sharing function