FindLevelDB.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Find leveldb
  2. #
  3. # Find the leveldb includes and library
  4. #
  5. # if you need to add a custom library search path, do it via via CMAKE_PREFIX_PATH
  6. #
  7. # This module defines
  8. # LEVELDB_INCLUDE_DIRS, where to find header, etc.
  9. # LEVELDB_LIBRARIES, the libraries needed to use leveldb.
  10. # LEVELDB_FOUND, If false, do not try to use leveldb.
  11. # only look in default directories
  12. find_path(
  13. LEVELDB_INCLUDE_DIR
  14. NAMES leveldb/db.h
  15. DOC "leveldb include dir"
  16. )
  17. find_library(
  18. LEVELDB_LIBRARY
  19. NAMES leveldb
  20. DOC "leveldb library"
  21. )
  22. set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR})
  23. set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY})
  24. # When we're static linking (at least on OS X), leveldb also drags in snappy.
  25. # This might be due to some dependency within leveldb which would be dead-code
  26. # stripped if we were using a static lib for leveldb. We aren't (yet), because
  27. # we only have partial static-linkage on OS X so far.
  28. if (STATIC_LINKING AND APPLE)
  29. find_path(SNAPPY_INCLUDE_DIR snappy.h PATH_SUFFIXES snappy)
  30. find_library(SNAPPY_LIBRARY snappy)
  31. set(LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR} ${SNAPPY_INCLUDE_DIR})
  32. set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY} ${SNAPPY_LIBRARY})
  33. endif()
  34. # debug library on windows
  35. # same naming convention as in qt (appending debug library with d)
  36. # boost is using the same "hack" as us with "optimized" and "debug"
  37. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  38. find_library(
  39. LEVELDB_LIBRARY_DEBUG
  40. NAMES leveldbd
  41. DOC "leveldb debug library"
  42. )
  43. list(APPEND LEVELDB_LIBRARIES "shlwapi")
  44. list(APPEND LEVELDB_LIBRARY_DEBUG "shlwapi")
  45. set(LEVELDB_LIBRARIES optimized ${LEVELDB_LIBRARIES} debug ${LEVELDB_LIBRARY_DEBUG})
  46. endif()
  47. # handle the QUIETLY and REQUIRED arguments and set LEVELDB_FOUND to TRUE
  48. # if all listed variables are TRUE, hide their existence from configuration view
  49. include(FindPackageHandleStandardArgs)
  50. find_package_handle_standard_args(leveldb DEFAULT_MSG
  51. LEVELDB_LIBRARY LEVELDB_INCLUDE_DIR)
  52. mark_as_advanced (LEVELDB_INCLUDE_DIR LEVELDB_LIBRARY)