decrypt drsuapi attributes
[wireshark-sm.git] / cmake / modules / FindSMI.cmake
blob0fe39735fe6b2d64899e28b14271db6334711ff4
2 # - Find smi
3 # Find the native SMI includes and library
5 #  SMI_INCLUDE_DIRS - where to find smi.h, etc.
6 #  SMI_LIBRARIES    - List of libraries when using smi.
7 #  SMI_FOUND        - True if smi found.
8 #  SMI_DLL_DIR      - (Windows) Path to the SMI DLL.
9 #  SMI_DLL          - (Windows) Name of the SMI DLL.
10 #  SMI_SHARE_DIR    - (Windows) Path to the SMI MIBs.
13 IF (SMI_INCLUDE_DIR)
14   # Already in cache, be silent
15   SET(SMI_FIND_QUIETLY TRUE)
16 ENDIF (SMI_INCLUDE_DIR)
18 INCLUDE(FindWSWinLibs)
19 FindWSWinLibs("libsmi-.*" "SMI_HINTS")
21 FIND_PATH(SMI_INCLUDE_DIR smi.h HINTS "${SMI_HINTS}/include" )
23 IF(MSVC)
24   SET(SMI_NAMES libsmi-2)
25 ELSE()
26   SET(SMI_NAMES smi libsmi-2)
27 ENDIF()
28 FIND_LIBRARY(SMI_LIBRARY NAMES ${SMI_NAMES} HINTS "${SMI_HINTS}/lib" )
30 # handle the QUIETLY and REQUIRED arguments and set SMI_FOUND to TRUE if
31 # all listed variables are TRUE
32 INCLUDE(FindPackageHandleStandardArgs)
33 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SMI DEFAULT_MSG SMI_LIBRARY SMI_INCLUDE_DIR)
35 IF(SMI_FOUND)
36   SET( SMI_LIBRARIES ${SMI_LIBRARY} )
37   SET( SMI_INCLUDE_DIRS ${SMI_INCLUDE_DIR} )
38   if (WIN32)
39     set ( SMI_DLL_DIR "${SMI_HINTS}/bin"
40       CACHE PATH "Path to the SMI DLL"
41     )
42     set ( SMI_SHARE_DIR "${SMI_HINTS}/share"
43       CACHE PATH "Path to the SMI MIBs"
44     )
45     file( GLOB _smi_dll RELATIVE "${SMI_DLL_DIR}"
46       "${SMI_DLL_DIR}/libsmi-*.dll"
47     )
48     set ( SMI_DLL ${_smi_dll}
49       # We're storing filenames only. Should we use STRING instead?
50       CACHE FILEPATH "SMI DLL file name"
51     )
52     mark_as_advanced( SMI_DLL_DIR SMI_DLL )
53   endif()
55   include(CheckSymbolExists)
56   cmake_push_check_state()
57   set(CMAKE_REQUIRED_INCLUDES ${SMI_INCLUDE_DIRS})
58   set(CMAKE_REQUIRED_LIBRARIES ${SMI_LIBRARIES})
59   # On Windows symbol visibility for global variables defaults to hidden
60   # and libsmi doesn't use any visibility decorators.
61   check_symbol_exists("smi_version_string" "smi.h" HAVE_SMI_VERSION_STRING)
62   cmake_pop_check_state()
64 ELSE(SMI_FOUND)
65   SET( SMI_LIBRARIES )
66   SET( SMI_INCLUDE_DIRS )
67   SET( SMI_DLL_DIR )
68   SET( SMI_SHARE_DIR )
69   SET( SMI_DLL )
70 ENDIF(SMI_FOUND)
72 MARK_AS_ADVANCED( SMI_LIBRARIES SMI_INCLUDE_DIRS )