sq epan/dissectors/packet-dcerpc-netlogon.c
[wireshark-sm.git] / cmake / modules / FindZSTD.cmake
blob5107d6a3a2e5480537d6bd3b188c2f23755b3cb6
2 # - Find zstd
3 # Find Zstd includes and library
5 #  ZSTD_INCLUDE_DIRS - where to find zstd.h, etc.
6 #  ZSTD_LIBRARIES    - List of libraries when using Zstd.
7 #  ZSTD_FOUND        - True if Zstd found.
8 #  ZSTD_DLL_DIR      - (Windows) Path to the Zstd DLL
9 #  ZSTD_DLL          - (Windows) Name of the Zstd DLL
11 include( FindWSWinLibs )
12 FindWSWinLibs( "zstd-.*" "ZSTD_HINTS" )
14 if( NOT USE_REPOSITORY)
15   find_package(PkgConfig)
16   pkg_search_module(ZSTD libzstd)
17 endif()
19 find_path(ZSTD_INCLUDE_DIR
20   NAMES zstd.h
21   HINTS "${ZSTD_INCLUDEDIR}" "${ZSTD_HINTS}/include"
22   /usr/include
23   /usr/local/include
26 find_library(ZSTD_LIBRARY
27   NAMES zstd
28   HINTS "${ZSTD_LIBDIR}" "${ZSTD_HINTS}/lib"
29   PATHS
30   /usr/lib
31   /usr/local/lib
34 if( ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY )
35   file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_MAJOR
36     REGEX "#define[ ]+ZSTD_VERSION_MAJOR[ ]+[0-9]+")
37   string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MAJOR ${ZSTD_VERSION_MAJOR})
38   file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_MINOR
39     REGEX "#define[ ]+ZSTD_VERSION_MINOR[ ]+[0-9]+")
40   string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MINOR ${ZSTD_VERSION_MINOR})
41   file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_RELEASE
42     REGEX "#define[ ]+ZSTD_VERSION_RELEASE[ ]+[0-9]+")
43   string(REGEX MATCH "[0-9]+" ZSTD_VERSION_RELEASE ${ZSTD_VERSION_RELEASE})
44   set(ZSTD_VERSION ${ZSTD_VERSION_MAJOR}.${ZSTD_VERSION_MINOR}.${ZSTD_VERSION_RELEASE})
45 endif()
47 include(FindPackageHandleStandardArgs)
48 find_package_handle_standard_args(ZSTD
49     REQUIRED_VARS   ZSTD_LIBRARY ZSTD_INCLUDE_DIR
50     VERSION_VAR     ZSTD_VERSION)
52 if( ZSTD_FOUND )
53   set( ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR} )
54   set( ZSTD_LIBRARIES ${ZSTD_LIBRARY} )
55   if (WIN32)
56     set ( ZSTD_DLL_DIR "${ZSTD_HINTS}/bin"
57       CACHE PATH "Path to Zstd DLL"
58     )
59     file( GLOB _zstd_dll RELATIVE "${ZSTD_DLL_DIR}"
60       "${ZSTD_DLL_DIR}/zstd*.dll"
61     )
62     set ( ZSTD_DLL ${_zstd_dll}
63       # We're storing filenames only. Should we use STRING instead?
64       CACHE FILEPATH "Zstd DLL file name"
65     )
66     mark_as_advanced( ZSTD_DLL_DIR ZSTD_DLL )
67   endif()
68 else()
69   set( ZSTD_INCLUDE_DIRS )
70   set( ZSTD_LIBRARIES )
71 endif()
73 mark_as_advanced( ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS )