set
可以将多个库文件“打包命名为LIBS(随便起的库名)”。比如我们需要OpenCV库和Sophus库,一般这样写,
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_DIRECTORIES})
find_package(Sophus REQUIRED)
include_directories(${Sophus_DIRECTORIES})
add_executable(main main.cpp)
target_link_libraries(main ${OpenCV_LIBRARIES} ${Sophus_LIBRARIES})
利用set
语句可以将OpenCV库和Sophus库进行类似于打包的操作,
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_DIRECTORIES})
find_package(Sophus REQUIRED)
include_directories(${Sophus_DIRECTORIES})
set(LIBS ${OpenCV_LIBRARIES} ${Sophus_LIBRARIES})
add_executable(main main.cpp)
target_link_libraries(main ${LIBS})