2013-09-23 21:45:55 +00:00
|
|
|
#
|
|
|
|
# - 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.
|
|
|
|
|
2013-10-11 07:38:45 +00:00
|
|
|
function( FindWSWinLibs _WS_LIB_SEARCH_PATH _LIB_HINT_VAR )
|
|
|
|
if( WIN32 )
|
|
|
|
if( ARGN )
|
|
|
|
set( _PROJECT_LIB_DIR ${ARGN} )
|
|
|
|
else()
|
2013-11-24 19:12:07 +00:00
|
|
|
file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
|
2013-10-11 07:38:45 +00:00
|
|
|
set( _WS_TARGET_PLATFORM $ENV{WIRESHARK_TARGET_PLATFORM} )
|
|
|
|
set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${_WS_TARGET_PLATFORM}-libs" )
|
|
|
|
endif()
|
2013-09-23 21:45:55 +00:00
|
|
|
file( GLOB _SUBDIR "${_PROJECT_LIB_DIR}/*" )
|
|
|
|
foreach( _DIR ${_SUBDIR} )
|
2013-09-27 22:30:34 +00:00
|
|
|
if( IS_DIRECTORY ${_DIR} )
|
|
|
|
if( "${_DIR}" MATCHES ".*/${_WS_LIB_SEARCH_PATH}" )
|
2013-09-23 21:45:55 +00:00
|
|
|
set( ${_LIB_HINT_VAR} ${_DIR} PARENT_SCOPE )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2013-10-10 13:37:15 +00:00
|
|
|
endfunction()
|
2013-09-23 21:45:55 +00:00
|
|
|
|
2014-05-16 19:43:17 +00:00
|
|
|
# Massage the list of paths to external libraries to output a batch file to update the PATH
|
|
|
|
# So that running an executable can load the DLL's
|
|
|
|
|
2013-10-11 07:38:45 +00:00
|
|
|
function( WSExtendPath _LIB_PATH_LIST _PATH_FILE )
|
|
|
|
if ( WIN32 )
|
2013-10-10 13:37:15 +00:00
|
|
|
#message( STATUS "All libs: ${_LIB_PATH_LIST}." )
|
2014-05-16 19:43:17 +00:00
|
|
|
# Convert each path that ends in "lib" to "bin" as linking requires the lib, running requires the dll.
|
2013-10-10 13:37:15 +00:00
|
|
|
foreach( THIS_LIB_PATH ${_LIB_PATH_LIST} )
|
2014-05-16 19:43:17 +00:00
|
|
|
if ( THIS_LIB_PATH MATCHES "[.]lib$" )
|
|
|
|
# lib is required for linking, the dlls are in bin so fix the path
|
|
|
|
# by chopping the library off the end and tacking "/bin" on
|
|
|
|
get_filename_component( LIB_PATH ${THIS_LIB_PATH} PATH )
|
|
|
|
string( REGEX REPLACE "/lib$" "/bin" LIB_PATH "${LIB_PATH}" )
|
|
|
|
else()
|
|
|
|
set ( LIB_PATH "${THIS_LIB_PATH}" )
|
|
|
|
endif()
|
|
|
|
#message( STATUS "Raw path ${THIS_LIB_PATH} processed to ${LIB_PATH}" )
|
2013-10-10 13:37:15 +00:00
|
|
|
set( WS_LOCAL_LIB_PATHS "${WS_LOCAL_LIB_PATHS}" ${LIB_PATH} )
|
|
|
|
endforeach()
|
|
|
|
list( REMOVE_DUPLICATES WS_LOCAL_LIB_PATHS )
|
|
|
|
# All generated libs go here, so start our libsearch in this place
|
|
|
|
set( WS_LOCAL_LIB_PATHS "${CMAKE_BINARY_DIR}/lib" "${WS_LOCAL_LIB_PATHS}" )
|
|
|
|
file( TO_NATIVE_PATH "${WS_LOCAL_LIB_PATHS}" WS_NATIVE_LIB_PATHS )
|
|
|
|
if ( EXISTS ${_PATH_FILE} )
|
|
|
|
file( READ ${_PATH_FILE} OLD_FILE_CONTENT )
|
|
|
|
else()
|
|
|
|
set( OLD_FILE_CONTENT " " )
|
|
|
|
endif()
|
|
|
|
#message( STATUS "Searching for ${WS_NATIVE_LIB_PATHS}\nin ${OLD_FILE_CONTENT}" )
|
|
|
|
string( FIND "${OLD_FILE_CONTENT}" "${WS_NATIVE_LIB_PATHS}" PATH_FOUND_AT )
|
|
|
|
#message( STATUS "Location of substr: ${PATH_FOUND_AT}" )
|
|
|
|
if( PATH_FOUND_AT GREATER -1 )
|
|
|
|
message( "\n${_PATH_FILE} is up to date.\n" )
|
|
|
|
else()
|
|
|
|
#message( STATUS "Native paths: ${WS_NATIVE_LIB_PATHS}" )
|
|
|
|
file( WRITE ${_PATH_FILE} "set PATH=%PATH%;${WS_NATIVE_LIB_PATHS}" )
|
|
|
|
message( "\n${_PATH_FILE} is new/updated, please run it.\n" )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|