rs项目改为cpm下载
项目 leveldb 和 basiccache, basiccache依赖 leveldb,下载都是在主项目中,
设置 INTERFACE_INCLUDE_DIRECTORIES后, 在basiccache中都不需要find_package了
set( leveldb_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" ) set( leveldb_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" ) ADD_LIBRARY(leveldb STATIC IMPORTED GLOBAL) set_property(TARGET leveldb PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${leveldb_INCLUDE_DIRS})
add_library(basiccache STATIC ${srcs}) target_link_libraries(basiccache leveldb)
https://docs.conan.io/en/1.8/reference/generators/cmake_find_package.html
#find_package(leveldb REQUIRED)
#IF( leveldb_FOUND )
# message(STATUS "found leveldb: ${leveldb_INCLUDE_DIRS}" )
#ENDIF()
#include_directories(${LEVELDB_INCLUDE_DIRS})
#message(STATUS "leveldb is in ${LEVELDB_INCLUDE_DIRS}")
搞了半天,leveldb_INCLUDE_DIRS变量总是空,按到要 Findleveldb.cmake?
>>>>>>>>>>>>>>>>>>>>>>>
在CMake里想要引用外部库,最好是使用find_package。可惜要使用find_package,要有对应的FindXXX.cmake存在才可以,对于比较小众的库就不太好找。
https://zhuanlan.zhihu.com/p/380244006
标签:DIRS,leveldb,cmake,target,basiccache,DIRECTORIES,INCLUDE,find From: https://www.cnblogs.com/kuipertan/p/16829627.html