cmake文件基本结构
文件名 CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
# set the project name
project(Tutorial)
# add the executable
add_executable(Tutorial tutorial.cxx)
指令介绍
| 名称 | 参数 | 说明 |
|---|---|---|
| set | 参数名 值 | 定义变量 |
| add_executable | 可执行程序名 源文件 | 生成可执行程序 |
| target_link_libraries | ||
| messages | ||
| find_package | ||
| include_directories | ||
| include |
简单使用技巧
保存安装和编译信息
make | tee LOG_make.txt
make install | tee LOG_install.txt
make >& LOG_make.txt
make install >& LOG_install.txt
C++ 版本设置

本文详细介绍了CMake的基本结构和常用指令,如set、add_executable、target_link_libraries等。同时展示了如何设置C++版本、编译器以及输出路径。还分享了如何保存安装和编译信息,以及通过file指令进行文件操作。最后,文章提及了检查C++11至C++17标准支持的方法,并给出了错误处理示例。
最低0.47元/天 解锁文章
349

被折叠的 条评论
为什么被折叠?



