当前位置:网站首页>CMake的安装和测试
CMake的安装和测试
2022-07-30 03:20:00 【CAir2】
上篇一文读懂CMake我们已经熟练掌握了CMake的脚本编写。安装顾名思义就是安装应用程序,例如将生成的可执行文件和动态库,拷贝到指定的安装位置。下面是install的基本语法。
安装
install(TARGETS <target>... [...])
install({
FILES | PROGRAMS} <file>... [...])
install(DIRECTORY <dir>... [...])
install(SCRIPT <file> [...])
install(CODE <code> [...])
install(EXPORT <export-name> [...])
#DESTINATION 表示安装位置
#如果设置了CMAKE_INSTALL_PREFIX则表示在CMAKE_INSTALL_PREFIX的基础位置+DESTINATION
#TARGETS 表示目标文件列表 例如可执行文件,库文件
install(TARGETS MathFunctions DESTINATION lib)
#FILES 表示文件列表
install(FILES MathFunctions.h DESTINATION include)
设置完成之后执行cmake --install 目录(cmake的输出目录,一般都是当前目录:build)
#执行Cmake
#cmake ../
#编译文件
#cmake --build .
#安装
#cmake --install .
#文件末尾添加
#设置安装目录,linux默认为/usr/local,windows默认为“C:\Program Files (x86)”
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install/")
#打印当前安装目录
install(CODE "message(\"CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}\")")
#安装指定文件
install(TARGETS hellow DESTINATION bin)

这样安装OK了,但是linux需要注意so的搜寻规则,否则可能导致so找不到,从而程序运行失败。
测试
边栏推荐
猜你喜欢

Overview of Federated Learning (1) - Background, Definition and Value of Federated Learning
![[C Supplement] Conversion of Integer to String](/img/61/4261ea9bf3001dfa8deed424fce145.jpg)
[C Supplement] Conversion of Integer to String

Open address method hash implementation - secondary detection method

英诺特生物上市市值45亿:年营收降68% 红杉与元生是股东

【无标题】

雪花是否一样问题

JUC (four): five/six states of shorthand thread
自定义 View 实现汉字笔顺动画

基于全志D1-H和XR806的名贵植物监控装置

QT基础第三天(3)widget,dialog和mainwindow
随机推荐
A transaction is in Mysql?What's the use?
Nuxt3学习
JUC(七):变量的线程安全分析
应用在光伏逆变器中的IGBT晶圆
JUC (four): five/six states of shorthand thread
答对这3个面试问题,薪资直涨20K
Successfully resolved AttributeError: 'PngImageFile' object has no attribute 'imshow'
JS Navigator appName appVersion userAgent platform
WPF 学习笔记《WPF布局基础》
分类之决策树分类
【JS】iframe 嵌入页面用法
一本通1922——乒乓球
Testers, what else do you need to know besides testing?
Record NLP various resource URLs
Simple Operations on Sequence
开放地址法哈希实现——线性探测法
phpoffice 编辑excel文档
【GPU并行计算】利用OpenCL&OpenCLUtilty进行GPU并行计算
如何有效进行回顾会议(上)?
Answer these 3 interview questions correctly, and the salary will go up by 20K