@@ -16,22 +16,25 @@ find_path(
1616 DOC "leveldb include dir"
1717)
1818
19+ if (LEVELDB_USE_STATIC_LIBS)
20+ set (names ${CMAKE_STATIC_LIBRARY_PREFIX} leveldb${CMAKE_STATIC_LIBRARY_SUFFIX} )
21+ else ()
22+ set (names leveldb)
23+ endif ()
24+
1925find_library (
2026 LEVELDB_LIBRARY
21- NAMES leveldb
27+ NAMES ${names}
2228 DOC "leveldb library"
2329)
2430
2531set (LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR} )
2632set (LEVELDB_LIBRARIES ${LEVELDB_LIBRARY} )
2733
28- # When we're static linking (at least on OS X), leveldb also drags in snappy.
29- # This might be due to some dependency within leveldb which would be dead-code
30- # stripped if we were using a static lib for leveldb. We aren't (yet), because
31- # we only have partial static-linkage on OS X so far.
32- if (NOT BUILD_SHARED_LIBS AND APPLE )
34+ # When linking statically we should include also the snappy static lib.
35+ if (LEVELDB_LIBRARY MATCHES ${CMAKE_STATIC_LIBRARY_SUFFIX} )
3336 find_path (SNAPPY_INCLUDE_DIR snappy.h PATH_SUFFIXES snappy)
34- find_library (SNAPPY_LIBRARY snappy)
37+ find_library (SNAPPY_LIBRARY ${CMAKE_STATIC_LIBRARY_PREFIX} snappy${CMAKE_STATIC_LIBRARY_SUFFIX} )
3538 set (LEVELDB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIR} ${SNAPPY_INCLUDE_DIR} )
3639 set (LEVELDB_LIBRARIES ${LEVELDB_LIBRARY} ${SNAPPY_LIBRARY} )
3740endif ()
@@ -58,4 +61,3 @@ include(FindPackageHandleStandardArgs)
5861find_package_handle_standard_args(leveldb DEFAULT_MSG
5962 LEVELDB_LIBRARY LEVELDB_INCLUDE_DIR)
6063mark_as_advanced (LEVELDB_INCLUDE_DIR LEVELDB_LIBRARY)
61-
0 commit comments