forked from osmocom/wireshark
Windows: Add preliminary support for MSYS2
If we are using MSYS2 we use those packages to build Wireshark using MinGW-w64 and disable most or all of our win-setup.ps1 codepaths. Fix GLib configuration. Disable copying of DLLs with MSYS2. Some tests in the suite_capture test suite are failing with MSYS MINGW64. That particular set of tests is way too brittle regarding file system paths; more work is needed to improve that situation.
This commit is contained in:
parent
1c8752935d
commit
6c5e56f752
|
@ -87,15 +87,33 @@ endif()
|
||||||
# %WIRESHARK_TARGET_PLATFORM%.
|
# %WIRESHARK_TARGET_PLATFORM%.
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_package(PowerShell REQUIRED)
|
# Are we using MSYS2? If we are we don't use our own third party
|
||||||
|
# libraries.
|
||||||
|
if(DEFINED ENV{MSYSTEM})
|
||||||
|
set(_msystem $ENV{MSYSTEM})
|
||||||
|
set(_repositoy False)
|
||||||
|
message(STATUS "Using MSYS2 with MSYSTEM=${_msystem}")
|
||||||
|
else()
|
||||||
|
set(_msystem False)
|
||||||
|
set(_repositoy True)
|
||||||
|
message(STATUS "Using 3rd party repository")
|
||||||
|
endif()
|
||||||
|
set(USE_MSYSTEM ${_msystem} CACHE INTERNAL "Use MSYS2 subsystem")
|
||||||
|
set(USE_REPOSITORY ${_repositoy} CACHE INTERNAL "Use Wireshark 3rd Party Repository")
|
||||||
|
|
||||||
if(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES "Win64")
|
if(DEFINED ENV{WIRESHARK_TARGET_PLATFORM})
|
||||||
|
string(TOLOWER $ENV{WIRESHARK_TARGET_PLATFORM} _target_platform)
|
||||||
|
set(WIRESHARK_TARGET_PLATFORM ${_target_platform})
|
||||||
|
elseif(USE_MSYSTEM MATCHES "MINGW64")
|
||||||
|
set(WIRESHARK_TARGET_PLATFORM win64)
|
||||||
|
elseif(USE_MSYSTEM MATCHES "MINGW32")
|
||||||
|
set(WIRESHARK_TARGET_PLATFORM win32)
|
||||||
|
elseif(USE_MSYSTEM)
|
||||||
|
message(WARNING "Building for MSYSTEM=${USE_MSYSTEM} is not officially supported")
|
||||||
|
elseif(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES "Win64")
|
||||||
set(WIRESHARK_TARGET_PLATFORM win64)
|
set(WIRESHARK_TARGET_PLATFORM win64)
|
||||||
elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
|
elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||||
set(WIRESHARK_TARGET_PLATFORM win32)
|
set(WIRESHARK_TARGET_PLATFORM win32)
|
||||||
elseif(DEFINED ENV{WIRESHARK_TARGET_PLATFORM})
|
|
||||||
string(TOLOWER $ENV{WIRESHARK_TARGET_PLATFORM} _target_platform)
|
|
||||||
set(WIRESHARK_TARGET_PLATFORM ${_target_platform})
|
|
||||||
else()
|
else()
|
||||||
message(WARNING "Assuming \"win64\" target platform")
|
message(WARNING "Assuming \"win64\" target platform")
|
||||||
set(WIRESHARK_TARGET_PLATFORM win64)
|
set(WIRESHARK_TARGET_PLATFORM win64)
|
||||||
|
@ -127,40 +145,44 @@ if(WIN32)
|
||||||
endif()
|
endif()
|
||||||
message(STATUS
|
message(STATUS
|
||||||
"Building for ${WIRESHARK_TARGET_PLATFORM} using \"${CMAKE_GENERATOR}\" \
|
"Building for ${WIRESHARK_TARGET_PLATFORM} using \"${CMAKE_GENERATOR}\" \
|
||||||
and CPU target architecture \"${WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE}\""
|
and CPU target ${WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Determine where the 3rd party libraries will be
|
# Determine where the 3rd party libraries will be
|
||||||
if( DEFINED ENV{WIRESHARK_LIB_DIR} )
|
if(USE_REPOSITORY)
|
||||||
# The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
|
find_package(PowerShell REQUIRED)
|
||||||
file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
|
|
||||||
elseif( DEFINED ENV{WIRESHARK_BASE_DIR} )
|
if( DEFINED ENV{WIRESHARK_LIB_DIR} )
|
||||||
file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
|
# The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
|
||||||
set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
|
file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
|
||||||
else()
|
elseif( DEFINED ENV{WIRESHARK_BASE_DIR} )
|
||||||
# Don't know what to do
|
file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
|
||||||
message(FATAL_ERROR "Neither WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR are defined")
|
set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
|
||||||
|
else()
|
||||||
|
# Don't know what to do
|
||||||
|
message(FATAL_ERROR "Neither WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR are defined")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Download third-party libraries
|
||||||
|
file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
|
||||||
|
file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir)
|
||||||
|
|
||||||
|
# Is it possible to have a one-time, non-cached option in CMake? If
|
||||||
|
# so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
|
||||||
|
# win-setup.ps1.
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM}
|
||||||
|
RESULT_VARIABLE _win_setup_failed
|
||||||
|
ERROR_VARIABLE _win_setup_error_output
|
||||||
|
)
|
||||||
|
if(_win_setup_failed)
|
||||||
|
message(FATAL_ERROR "Windows setup (win-setup.ps1) failed: ${_win_setup_error_output}.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(EXTRA_INSTALLER_DIR ${_ws_lib_dir})
|
||||||
|
|
||||||
|
# XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Download third-party libraries
|
|
||||||
file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
|
|
||||||
file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir)
|
|
||||||
|
|
||||||
# Is it possible to have a one-time, non-cached option in CMake? If
|
|
||||||
# so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
|
|
||||||
# win-setup.ps1.
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM}
|
|
||||||
RESULT_VARIABLE _win_setup_failed
|
|
||||||
ERROR_VARIABLE _win_setup_error_output
|
|
||||||
)
|
|
||||||
if(_win_setup_failed)
|
|
||||||
message(FATAL_ERROR "Windows setup (win-setup.ps1) failed: ${_win_setup_error_output}.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(EXTRA_INSTALLER_DIR ${_ws_lib_dir})
|
|
||||||
|
|
||||||
# XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
|
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
include(UseCustomIncludes)
|
include(UseCustomIncludes)
|
||||||
|
@ -1959,7 +1981,7 @@ if(NOT WIN32)
|
||||||
list(APPEND INSTALL_FILES COPYING)
|
list(APPEND INSTALL_FILES COPYING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(USE_REPOSITORY)
|
||||||
set(_dll_output_dir "${DATAFILE_DIR}")
|
set(_dll_output_dir "${DATAFILE_DIR}")
|
||||||
add_custom_target(copy_cli_dlls)
|
add_custom_target(copy_cli_dlls)
|
||||||
set_target_properties(copy_cli_dlls PROPERTIES FOLDER "Copy Tasks")
|
set_target_properties(copy_cli_dlls PROPERTIES FOLDER "Copy Tasks")
|
||||||
|
@ -2159,7 +2181,7 @@ if(WIN32)
|
||||||
WORKING_DIRECTORY "${_dll_output_dir}"
|
WORKING_DIRECTORY "${_dll_output_dir}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif(WIN32)
|
endif()
|
||||||
|
|
||||||
# List of extra dependencies for the "copy_data_files" target
|
# List of extra dependencies for the "copy_data_files" target
|
||||||
set(copy_data_files_depends)
|
set(copy_data_files_depends)
|
||||||
|
|
|
@ -24,7 +24,7 @@ endif()
|
||||||
include( FindWSWinLibs )
|
include( FindWSWinLibs )
|
||||||
FindWSWinLibs( "vcpkg-export-*" "GLIB2_HINTS" )
|
FindWSWinLibs( "vcpkg-export-*" "GLIB2_HINTS" )
|
||||||
|
|
||||||
if (NOT WIN32)
|
if (NOT USE_REPOSITORY)
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
pkg_search_module( PC_GLIB2 glib-2.0 )
|
pkg_search_module( PC_GLIB2 glib-2.0 )
|
||||||
endif()
|
endif()
|
||||||
|
@ -65,7 +65,7 @@ FindWSLibrary( GLIB2_LIBRARY
|
||||||
/usr/lib
|
/usr/lib
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (USE_REPOSITORY)
|
||||||
# In the Windows vcpkg port glibconfig.h is in
|
# In the Windows vcpkg port glibconfig.h is in
|
||||||
# installed/$ARCH-windows/lib/glib-2.0/include.
|
# installed/$ARCH-windows/lib/glib-2.0/include.
|
||||||
set( glib2LibDir "${GLIB2_HINTS}/lib" )
|
set( glib2LibDir "${GLIB2_HINTS}/lib" )
|
||||||
|
@ -79,6 +79,7 @@ find_path( GLIB2_INTERNAL_INCLUDE_DIR
|
||||||
NAMES
|
NAMES
|
||||||
glibconfig.h
|
glibconfig.h
|
||||||
HINTS
|
HINTS
|
||||||
|
"${PC_GLIB2_LIBDIR}"
|
||||||
"${glib2LibDir}"
|
"${glib2LibDir}"
|
||||||
"${GLIB2_INCLUDEDIR}"
|
"${GLIB2_INCLUDEDIR}"
|
||||||
${CMAKE_SYSTEM_LIBRARY_PATH}
|
${CMAKE_SYSTEM_LIBRARY_PATH}
|
||||||
|
@ -121,7 +122,7 @@ if( GLIB2_FOUND )
|
||||||
list(APPEND GLIB2_LIBRARIES -pthread ${PCRE_LIBRARY})
|
list(APPEND GLIB2_LIBRARIES -pthread ${PCRE_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
set( GLIB2_INCLUDE_DIRS ${GLIB2_MAIN_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR} )
|
set( GLIB2_INCLUDE_DIRS ${GLIB2_MAIN_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR} )
|
||||||
if ( WIN32 AND GLIB2_FOUND )
|
if ( USE_REPOSITORY AND GLIB2_FOUND )
|
||||||
set ( GLIB2_DLL_DIR_RELEASE "${GLIB2_HINTS}/bin"
|
set ( GLIB2_DLL_DIR_RELEASE "${GLIB2_HINTS}/bin"
|
||||||
CACHE PATH "Path to GLib2 release DLLs"
|
CACHE PATH "Path to GLib2 release DLLs"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue