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)
19 find_path(SNAPPY_INCLUDE_DIR
21 HINTS "${SNAPPY_INCLUDEDIR}" "${SNAPPY_HINTS}/include"
26 find_library(SNAPPY_LIBRARY
28 HINTS "${SNAPPY_LIBDIR}" "${SNAPPY_HINTS}/lib"
34 include(FindPackageHandleStandardArgs)
35 find_package_handle_standard_args( SNAPPY DEFAULT_MSG SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR )
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})
57 set ( SNAPPY_DLL_DIR "${SNAPPY_HINTS}/bin"
58 CACHE PATH "Path to Snappy DLL"
60 file( GLOB _snappy_dll RELATIVE "${SNAPPY_DLL_DIR}"
61 "${SNAPPY_DLL_DIR}/snappy*.dll"
63 set ( SNAPPY_DLL ${_snappy_dll}
64 # We're storing filenames only. Should we use STRING instead?
65 CACHE FILEPATH "Snappy DLL file name"
67 mark_as_advanced( SNAPPY_DLL_DIR SNAPPY_DLL )
70 set( SNAPPY_INCLUDE_DIRS )
71 set( SNAPPY_LIBRARIES )
74 mark_as_advanced( SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIRS )