FindGLIB2.cmake: workaround to make static linking work

When using pkg_search_module(GLIB2 glib-2.0), it will also include
transitive dependencies (pcre) in GLIB2_STATIC_LIBRARIES, but it will
still lack -pthread (which is in GLIB2_STATIC_LDFLAGS). For simplicity
just hardcode these.

Change-Id: Ia227f8b56e088c71210a748aeb2dedaba521c090
Reviewed-on: https://code.wireshark.org/review/30252
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2018-10-18 19:38:51 +02:00 committed by Anders Broman
parent e6e2137459
commit 54286eb09c
1 changed files with 5 additions and 0 deletions

View File

@ -111,6 +111,11 @@ find_package_handle_standard_args( GLIB2
if( GLIB2_FOUND )
set( GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GOBJECT_LIBRARY} )
# Include transitive dependencies for static linking.
if(UNIX AND CMAKE_FIND_LIBRARY_SUFFIXES STREQUAL ".a")
find_library(PCRE_LIBRARY pcre)
list(APPEND GLIB2_LIBRARIES -pthread ${PCRE_LIBRARY})
endif()
set( GLIB2_INCLUDE_DIRS ${GLIB2_MAIN_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR} )
if ( WIN32 AND GLIB2_FOUND )
set ( GLIB2_DLL_DIR "${GLIB2_HINTS}/bin"