例:
cmake_minimum_required(VERSION 3.9) project(test) set(CMAKE_BUILD_TYPE Debug) add_library(haha test.cpp) install(TARGET haha DESTINATION /home/linxisuo/project/test) install(DIRECTORY ${CMAKE_SOURCE_DIR}/test DESTINATION /home/linxisuo)
說明:
1.安裝目標 :
install(TARGETS mylibrary DESTINATION lib)
2.安裝指定目錄或檔案:
install(DIRECTORY ${CMAKE_SOURCE_DIR}/mydir DESTINATION share/mydir)
詳細說明參考:https://blog.csdn.net/qq_21438461/article/details/133418766