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

JDBC learning (I) -- implementing simple CRUD operations

The code is correct, and the rendering page does not display the reason

MySQL (I) - Installation

Floating and positioning

Exception handling (I) -- null pointer and array index out of bounds

整型提升和大小端字节序

Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance
![[staff] arpeggio mark](/img/45/0ee0089b947b467344b247839893d7.jpg)
[staff] arpeggio mark

MySQL(一)——安装

Integer promotion and size side byte order
随机推荐
创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
CAD secondary development +nettopologysuite+pgis reference multi version DLL
Introduction to browser tools: think sky browser, team work browser
Exception handling (I) -- null pointer and array index out of bounds
socke. IO long connection enables push, version control, and real-time active user statistics
D3D11_ Chili_ Tutorial (3): design a bindable/drawable system
Use the SQL SELECT count distinct query statement to count the total number of unique values of a field in the database
Freeswitch uses origin to dialplan
记JPA使用自定义VO接收 JPQL查询结果
[staff] arpeggio mark
CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题
Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
Working principle of es9023 audio decoding chip
Build your jmeter+jenkins+ant
Interpretation of Blog
慢内容广告:品牌增长的长线主义
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
AutoCAD C polyline small acute angle detection
小程序页面设置100%高度还是留白怎么办?
4~20ma input /0~5v output i/v conversion circuit