aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindWSWinLibs.cmake
blob: 75568d49d83f5d7fecfe165e5e82adc82d8a17c6 (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
#
# - Find WSWin Libs
#  Due to the layout of the Wireshark Win support libs,
#  CMake needs some support to find them
#
#  The function is passed the directory name to search for and the variable
#  to set in the callers scope.

function( FindWSWinLibs _WS_LIB_SEARCH_PATH _LIB_HINT_VAR )
  if( WIN32 )
    if( ARGN )
      set( _PROJECT_LIB_DIR ${ARGN} )
    else()
      if( DEFINED ENV{WIRESHARK_LIB_DIR} )
        # The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
        file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
      else()
        file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
        set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
      endif()
    endif()

    file( GLOB _SUBDIR "${_PROJECT_LIB_DIR}/*" )
    # We might be able to use $ENV{VSCMD_ARG_TGT_ARCH} here.
    set (_vcpkg_arch x64)
    if(WIRESHARK_TARGET_PLATFORM MATCHES "win32")
      set (_vcpkg_arch x86)
    endif()

    foreach( _DIR ${_SUBDIR} )
      if( IS_DIRECTORY ${_DIR} )
        if( "${_DIR}" MATCHES ".*/${_WS_LIB_SEARCH_PATH}" )
          set(_vcpkg_dir "${_DIR}/installed/${_vcpkg_arch}-windows")
          if( IS_DIRECTORY "${_vcpkg_dir}")
            set( ${_LIB_HINT_VAR} ${_vcpkg_dir} PARENT_SCOPE )
          else()
            set( ${_LIB_HINT_VAR} ${_DIR} PARENT_SCOPE )
          endif()
        endif()
      endif()
    endforeach()
  endif()
endfunction()