CMakeLists.txt如何添加uninstall
时间: 2023-08-19 17:24:25 浏览: 91
CMakeLists.txt
要添加uninstall目标,需要在CMakeLists.txt中添加以下内容:
```
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
```
这段代码会生成一个`cmake_uninstall.cmake`文件,然后通过`add_custom_target`添加一个名为`uninstall`的自定义目标,这个目标的命令是执行`cmake_uninstall.cmake`文件,即卸载命令。
阅读全文