CMake Help
系列基于CMake Tutorial
本文基于Step 5: Installing and Testing
Exercise 1 - Install Rules
修改MathFunctions/CMakeLists.txt
,添加
1 | set(installable_libs MathFunctions tutorial_compiler_flags) |
修改CMakeLists.txt
,添加
1 | install(FILES "${PROJECT_BINARY_DIR}/MyProject.h" |
运行命令
1 | cmake -B build |
执行安装
1 | cmake --install build |
默认情况下,安装路径为/usr/local
,window系统为C:/Program Files/${PROJECT_NAME}
。可以设定安装路径:
1 | cmake --install build --prefix "/home/myuser/installdir" |
安装成功后,执行命令
1 | cd /home/myuser/installdir |
可以得到如下文件目录结构
1 | . |
可执行文件在bin
目录中。