1. 程式人生 > 實用技巧 >Cmake 命令總結

Cmake 命令總結


set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_BUILD_TYPE "Release")

//找庫
find_package( OpenCV REQUIRED)
include_directories( 
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
)

//可執行檔案
add_executable(SuperPointPretrainC++ SuperPointPretrainC++.cpp)
target_link_libraries(SuperPointPretrainC++ ${PROJECT_NAME})
target_link_libraries(SuperPointPretrainC++ "${TORCH_LIBRARIES}")
target_link_libraries(SuperPointPretrainC++ ${OpenCV_LIBS})
//為可執行檔案新增動態連結庫
FILE(GLOB_RECURSE shareObject /usr/local/lib/superpoint_share_lib/* )
target_link_libraries(SuperPointPretrainC++ ${shareObject})
//為可執行檔案新增靜態庫
target_link_libraries(SuperPointPretrainC++ "${CMAKE_CURRENT_SOURCE_DIR}/lib/libcaculateDistance.a")
//輸出資訊
MESSAGE( STATUS "this var key = ${shareObject}.")
//打包靜態庫檔案
add_library(${PROJECT_NAME}
src/SPextractor.cc
src/SuperPoint.cc
src/SuperPointMatch.cc
)
target_link_libraries(${PROJECT_NAME}
${TORCH_LIBRARIES}
${OpenCV_LIBS}
${EIGEN3_LIBS}
)

//解析src資料夾內容,新增到變數SRC_LIST中
aux_source_directory(./src SRC_LIST)