当前位置:网站首页>Cmake common command category notes
Cmake common command category notes
2022-06-22 02:11:00 【Leaves that go to bed early】
List of articles
1. Set the path of the header file
target_include_directories(Tutorial PUBLIC
"${PROJECT_BINARY_DIR}"
)
# Link header file path
target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
)
2. Setup profile
configure_file(TutorialConfig.h.in TutorialConfig.h)
TutorialConfig.h.in :
// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @[email protected]
#define Tutorial_VERSION_MINOR @[email protected]
Access profile :
if (argc < 2) {
// report version
std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
<< Tutorial_VERSION_MINOR << std::endl;
std::cout << "Usage: " << argv[0] << " number" << std::endl;
return 1;
}
3. Set up c/c++ edition
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
4. Compile instructions
cd Step1_build
cmake --build .
5. Link to third-party libraries
target_link_libraries(Tutorial PUBLIC MathFunctions)
add_library(hello::library ALIAS hello_library)
6. Macro control
# Set a variable
option(USE_MYMATH "Use tutorial provided math implementation" ON)
# Macro control
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions")
endif()
# Set the number
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
7. Search for files
# Find all the source files in the directory
# And save the name to DIR_SRCS Variable
aux_source_directory(. DIR_SRCS)
aux_source_directory(<dir> <variable>)
8. Compile result type settings
# Specify generation MathFunctions Link library
add_library (MathFunctions ${DIR_LIB_SRCS})
9. Set a variable
set(SOURCES
src/Hello.cpp
src/main.cpp
)
# Add an executable with the above sources
add_executable(hello_headers ${SOURCES})
10. Print a message
# Print path to generated files
message ("PROTO_SRCS = ${PROTO_SRCS}")
message ("PROTO_HDRS = ${PROTO_HDRS}")
边栏推荐
- MATLAB 学习笔记(4)MATLAB 数组
- Mathematical knowledge in the first round of noip preliminary round csp-j1 csp-s1 Xinjiang Olympic Games (II)
- Chapter 21 design of pavement crack detection and identification system -- matlab deep learning practice
- 理财产品到期赎回时间是什么意思?
- Idea ---- copy and paste
- Machine learning compilation lesson 1: overview of machine learning compilation
- Zhongang Mining Co., Ltd.: fluorite is a scarce resource with enhanced attributes, and there may be a gap between supply and demand in the future
- Ansible 配置文件
- 回到成都开启我的软件测试职业生涯
- word中mathtype公式右编号右对齐
猜你喜欢

机器学习编译第1讲:机器学习编译概述

微信小程序影视评论交流平台系统毕业设计毕设(6)开题答辩PPT

Pdf to word PDF to picture picture to PDF modifying PDF files is as convenient as operating word (Introduction to acrobat DC)

Machine learning compilation lesson 1: overview of machine learning compilation

word文档转markdown文档?

Appium面试题

Wechat applet Film & TV Review Exchange Platform System Graduation Design (4) Rapport d'ouverture

Games-101 personal summary rasterization

微信小程序影视评论交流平台系统毕业设计毕设(2)小程序功能

Minecraft 1.18.2 生化8 模组 1.3版本 物品3D化+更加复杂村庄
随机推荐
Shadertoy realizes simple compass
Atguigu---- collect form data
atguigu----过滤器
Completion of graduation design of wechat small program film and television review and exchange platform system (5) assignment
Chapter 12 panoramic image mosaic based on block matching -- Application of MATLAB in-depth learning and actual combat image processing
pdf转word pdf转图片 图片转pdf 修改pdf文件就像操作Word一样方便(Acrobat DC使用介绍)
Qt程序怎么实现选中ListWidget中的某一行为默认选中
Mba-day23 at most at least questions - exercises
Idea ---- copy and paste
Mysql数据库轻松学06—数据分析师常用:数据查询语言DQL之单表查询
Mysql database easy learning 09 - commonly used by data analysts: multi table query of data query language DQL
软件测试工程师面试接口测试常见问题
众昂矿业:萤石稀缺资源属性增强,未来或出现供需缺口
Software Test Engineer Interview interface test FAQ
Zhongang Mining Co., Ltd.: fluorite is a scarce resource with enhanced attributes, and there may be a gap between supply and demand in the future
Rational Rose installation tutorial
Wechat applet Film & TV Review Exchange Platform System Graduation Design (4) Rapport d'ouverture
atguigu----列表渲染
Array common methods
剑指offer 26:树的子结构