aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindSNAPPY.cmake
blob: 7964c9d14587aa91a9eedbb20ea6d37b78f3e574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# - Find snappy
# Find Snappy includes and library
#
#  SNAPPY_INCLUDE_DIRS - where to find snappy.h, etc.
#  SNAPPY_LIBRARIES    - List of libraries when using Snappy.
#  SNAPPY_FOUND        - True if Snappy found.
#  SNAPPY_DLL_DIR      - (Windows) Path to the Snappy DLL
#  SNAPPY_DLL          - (Windows) Name of the Snappy DLL

include( FindWSWinLibs )
FindWSWinLibs( "snappy-.*" "SNAPPY_HINTS" )

if( NOT WIN32)
  find_package(PkgConfig)
  pkg_search_module(SNAPPY libsnappy)
endif()

find_path(SNAPPY_INCLUDE_DIR
  NAMES snappy.h
  HINTS "${SNAPPY_INCLUDEDIR}" "${SNAPPY_HINTS}/include"
  /usr/include
  /usr/local/include
)

find_library(SNAPPY_LIBRARY
  NAMES snappy
  HINTS "${SNAPPY_LIBDIR}" "${SNAPPY_HINTS}/lib"
  PATHS
  /usr/lib
  /usr/local/lib
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( SNAPPY DEFAULT_MSG SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR )

if( SNAPPY_FOUND )
  set( SNAPPY_INCLUDE_DIRS ${SNAPPY_INCLUDE_DIR} )
  set( SNAPPY_LIBRARIES ${SNAPPY_LIBRARY} )
  if (WIN32)
    set ( SNAPPY_DLL_DIR "${SNAPPY_HINTS}/bin"
      CACHE PATH "Path to Snappy DLL"
    )
    file( GLOB _snappy_dll RELATIVE "${SNAPPY_DLL_DIR}"
      "${SNAPPY_DLL_DIR}/libsnappy-*.dll"
    )
    set ( SNAPPY_DLL ${_snappy_dll}
      # We're storing filenames only. Should we use STRING instead?
      CACHE FILEPATH "Snappy DLL file name"
    )
    mark_as_advanced( SNAPPY_DLL_DIR SNAPPY_DLL )
  endif()
else()
  set( SNAPPY_INCLUDE_DIRS )
  set( SNAPPY_LIBRARIES )
endif()

mark_as_advanced( SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIRS )