TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / cmake / modules / FindSNAPPY.cmake
blob442dbfa52ab87e95e4338f464bdc55995fff3f00
2 # - Find snappy
3 # Find Snappy includes and library
5 #  SNAPPY_INCLUDE_DIRS - where to find snappy.h, etc.
6 #  SNAPPY_LIBRARIES    - List of libraries when using Snappy.
7 #  SNAPPY_FOUND        - True if Snappy found.
8 #  SNAPPY_DLL_DIR      - (Windows) Path to the Snappy DLL
9 #  SNAPPY_DLL          - (Windows) Name of the Snappy DLL
11 include( FindWSWinLibs )
12 FindWSWinLibs( "snappy-.*" "SNAPPY_HINTS" )
14 if( NOT USE_REPOSITORY)
15   find_package(PkgConfig QUIET)
16   pkg_search_module(SNAPPY QUIET libsnappy)
17 endif()
19 find_path(SNAPPY_INCLUDE_DIR
20   NAMES snappy.h
21   HINTS "${SNAPPY_INCLUDEDIR}" "${SNAPPY_HINTS}/include"
22   /usr/include
23   /usr/local/include
26 find_library(SNAPPY_LIBRARY
27   NAMES snappy
28   HINTS "${SNAPPY_LIBDIR}" "${SNAPPY_HINTS}/lib"
29   PATHS
30   /usr/lib
31   /usr/local/lib
34 include(FindPackageHandleStandardArgs)
35 find_package_handle_standard_args( SNAPPY DEFAULT_MSG SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR )
37 if( SNAPPY_FOUND )
38   set( SNAPPY_INCLUDE_DIRS ${SNAPPY_INCLUDE_DIR} )
39   set( SNAPPY_LIBRARIES ${SNAPPY_LIBRARY} )
40     set(_snappy_version_header "${SNAPPY_INCLUDE_DIR}/snappy-stubs-public.h")
42     file(STRINGS "${_snappy_version_header}" SNAPPY_VERSION_MAJOR
43     REGEX "#define[ ]+SNAPPY_MAJOR[ ]+[0-9]+")
44     # Older versions of snappy like snappy-0.2 have SNAPPY_VERSION but not SNAPPY_VERSION_MAJOR
45     if(SNAPPY_VERSION_MAJOR)
46     string(REGEX MATCH "[0-9]+" SNAPPY_VERSION_MAJOR ${SNAPPY_VERSION_MAJOR})
47     file(STRINGS "${_snappy_version_header}" SNAPPY_VERSION_MINOR
48     REGEX "#define[ ]+SNAPPY_MINOR[ ]+[0-9]+")
49     string(REGEX MATCH "[0-9]+" SNAPPY_VERSION_MINOR ${SNAPPY_VERSION_MINOR})
50     file(STRINGS "${_snappy_version_header}" SNAPPY_VERSION_PATCH
51     REGEX "#define[ ]+SNAPPY_PATCHLEVEL[ ]+[0-9]+")
52     string(REGEX MATCH "[0-9]+" SNAPPY_VERSION_PATCH ${SNAPPY_VERSION_PATCH})
53     set(SNAPPY_VERSION ${SNAPPY_VERSION_MAJOR}.${SNAPPY_VERSION_MINOR}.${SNAPPY_VERSION_PATCH})
54     endif()
56   if (WIN32)
57     set ( SNAPPY_DLL_DIR "${SNAPPY_HINTS}/bin"
58       CACHE PATH "Path to Snappy DLL"
59     )
60     file( GLOB _snappy_dll RELATIVE "${SNAPPY_DLL_DIR}"
61       "${SNAPPY_DLL_DIR}/snappy*.dll"
62     )
63     set ( SNAPPY_DLL ${_snappy_dll}
64       # We're storing filenames only. Should we use STRING instead?
65       CACHE FILEPATH "Snappy DLL file name"
66     )
67     mark_as_advanced( SNAPPY_DLL_DIR SNAPPY_DLL )
68   endif()
69 else()
70   set( SNAPPY_INCLUDE_DIRS )
71   set( SNAPPY_LIBRARIES )
72 endif()
74 mark_as_advanced( SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIRS )