当前位置:网站首页>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
边栏推荐
猜你喜欢

FPM tool installation

mac下安装多个版本php并且进行管理

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

YOLOv5增加小目标检测层

socke. IO long connection enables push, version control, and real-time active user statistics

Yolov5 adds a small target detection layer

Install and manage multiple versions of PHP under mac

链表(二)——设计链表

death_ satan/hyperf-validate

Freeswitch使用originate转dialplan
随机推荐
Install redis on windows and permanently change the password, and integrate redis with the SSM framework
RN7302三相电量检测(基于STM32单片机)
Floating and positioning
OpenGL API learning (2008) client server client server
整型提升和大小端字节序
Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
使用SSM框架,配置多个数据库连接
AutoCAD C polyline self intersection detection
API learning of OpenGL (2006) glclientactivetexture
Uni app wechat applet sharing function
Yolact++ Pytorch环境
记JPA使用自定义VO接收 JPQL查询结果
Differences between overloads, rewrites, abstract classes and interfaces
链表(二)——设计链表
AttributeError: 'callable_ iterator' object has no attribute 'next'
图片按日期批量导入WPS表格
5-minute NLP: summary of time chronology from bag of words to transformer
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]
MySQL common functions
基本类型和包装类的区别