cmake: cleanup Findleveldb.cmake

* and reference leveldb library and include dir with fullpath

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2016-08-11 14:48:35 +08:00
parent 6c12edbf9d
commit 96fdb6914a
4 changed files with 13 additions and 37 deletions

View File

@ -237,7 +237,7 @@ option(WITH_RBD "Remote block storage is here" ON)
option(WITH_LEVELDB "LevelDB is here" ON)
if(${WITH_LEVELDB})
find_package(leveldb REQUIRED)
find_file(HAVE_LEVELDB_FILTER_POLICY filter_policy.h PATHS /usr/include/leveldb)
find_file(HAVE_LEVELDB_FILTER_POLICY leveldb/filter_policy.h PATHS ${LEVELDB_INCLUDE_DIR})
endif(${WITH_LEVELDB})
option(WITH_EXPAT "EXPAT is here" ON)

View File

@ -1,42 +1,18 @@
# - Find LevelDB
#
# LEVELDB_INCLUDE - Where to find leveldb/db.h
# LEVELDB_LIBS - List of libraries when using LevelDB.
# LEVELDB_INCLUDE_DIR - Where to find leveldb/db.h
# LEVELDB_LIBRARIES - List of libraries when using LevelDB.
# LEVELDB_FOUND - True if LevelDB found.
get_filename_component(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH)
find_path(LEVELDB_INCLUDE_DIR leveldb/db.h
HINTS $ENV{LEVELDB_ROOT}/include
DOC "Path in which the file leveldb/db.h is located." )
# Look for the header file.
find_path(LEVELDB_INCLUDE NAMES leveldb/db.h PATHS $ENV{LEVELDB_ROOT}/include /opt/local/include /usr/local/include /usr/include DOC "Path in which the file leveldb/db.h is located." )
mark_as_advanced(LEVELDB_INCLUDE)
find_library(LEVELDB_LIBRARIES leveldb
HINTS $ENV{LEVELDB_ROOT}/lib
DOC "Path to leveldb library." )
# Look for the library.
# Does this work on UNIX systems? (LINUX)
find_library(LEVELDB_LIBS NAMES leveldb PATHS /usr/lib $ENV{LEVELDB_ROOT}/lib DOC "Path to leveldb library." )
mark_as_advanced(LEVELDB_LIBS)
mark_as_advanced(LEVELDB_INCLUDE_DIR LEVELDB_LIBRARIES)
# Copy the results to the output variables.
if (LEVELDB_INCLUDE AND LEVELDB_LIBS)
message(STATUS "Found leveldb in ${LEVELDB_INCLUDE} ${LEVELDB_LIBS}")
set(LEVELDB_FOUND 1)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_LIBRARY ${LEVELDB_LIBS} pthread)
set(CMAKE_REQUIRED_INCLUDES ${LEVELDB_INCLUDE})
else ()
set(LEVELDB_FOUND 0)
endif ()
# Report the results.
if (NOT LEVELDB_FOUND)
set(LEVELDB_DIR_MESSAGE "LEVELDB was not found. Make sure LEVELDB_LIBS and LEVELDB_INCLUDE are set.")
if (LEVELDB_FIND_REQUIRED)
message(FATAL_ERROR "${LEVELDB_DIR_MESSAGE}")
elseif (NOT LEVELDB_FIND_QUIETLY)
message(STATUS "${LEVELDB_DIR_MESSAGE}")
endif ()
endif ()
# handle the QUIETLY and REQUIRED arguments and set GPERFTOOLS_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(leveldb DEFAULT_MSG LEVELDB_LIBS LEVELDB_INCLUDE)
find_package_handle_standard_args(leveldb DEFAULT_MSG LEVELDB_LIBRARIES LEVELDB_INCLUDE_DIR)

View File

@ -7,7 +7,7 @@ add_library(kv_objs OBJECT ${kv_srcs})
add_library(kv STATIC $<TARGET_OBJECTS:kv_objs>)
target_include_directories(kv_objs PUBLIC ${ROCKSDB_INCLUDE_DIR})
target_include_directories(kv PUBLIC ${ROCKSDB_INCLUDE_DIR})
target_link_libraries(kv leveldb rocksdb snappy z)
target_link_libraries(kv ${LEVELDB_LIBRARIES} rocksdb snappy z)
# rocksdb detects bzlib and lz4 in its Makefile, which forces us to do the same.
find_package(BZip2 QUIET)

View File

@ -33,7 +33,7 @@ add_library(osd STATIC ${osd_srcs}
$<TARGET_OBJECTS:global_common_objs>
$<TARGET_OBJECTS:heap_profiler_objs>
$<TARGET_OBJECTS:common_util_obj>)
target_link_libraries(osd leveldb ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
target_link_libraries(osd ${LEVELDB_LIBRARIES} ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
if(WITH_LTTNG)
add_dependencies(osd osd-tp)
endif()