CMake引入第三方库
find_package(PkgConfig REQUIRED)
pkg_search_module(alibabacloud-oss-cpp-sdk IMPORTED_TARGET alibabacloud-oss-cpp-sdk)
message(STATUS "AliOSS include path: ${alibabacloud-oss-cpp-sdk_INCLUDE_DIRS}")
message(STATUS "AliOSS library path: ${alibabacloud-oss-cpp-sdk_LIBRARY_DIRS}")
message(STATUS "AliOSS library: ${alibabacloud-oss-cpp-sdk_LIBRARIES}")
target_link_libraries(${SOURCE} ... PkgConfig::alibabacloud-oss-cpp-sdk)
在CmakeLists中使用pkg-config引入三方库,需要先使用pkg_search_module或者pkg_check_modules在当前文件内引入对应的库,然后使用PkgConfig::xxx将第三方库链接到对应的可执行文件中,其中xxx必须与pkg_search_module第一个参数一致