aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2019-09-03 20:28:52 +0200
committerPascal Quantin <pascal@wireshark.org>2019-09-28 10:24:34 +0000
commit990e409273b49650be5b89aaad75dba5a63460e2 (patch)
treee67a532e7dac8effe7294ddb3f1314baf063c5d5 /cmake
parentae750dc141e1658cf87a42eef37e4c755f56a133 (diff)
CMake: Use glib debug dlls in Windows debug builds
This prevents the mix of debug/release Universal CRT library in a Wireshark. Bug: 16030 Change-Id: I2961541824caf3bef0a08c72b242427b5406a9bd Reviewed-on: https://code.wireshark.org/review/34444 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Reviewed-by: João Valverde <j@v6e.pt> Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindGLIB2.cmake121
-rw-r--r--cmake/modules/FindGMODULE2.cmake6
-rw-r--r--cmake/modules/FindGTHREAD2.cmake6
-rw-r--r--cmake/modules/FindWSLibrary.cmake36
4 files changed, 127 insertions, 42 deletions
diff --git a/cmake/modules/FindGLIB2.cmake b/cmake/modules/FindGLIB2.cmake
index b78430e4e8..46bede9ec5 100644
--- a/cmake/modules/FindGLIB2.cmake
+++ b/cmake/modules/FindGLIB2.cmake
@@ -2,11 +2,13 @@
# - Try to find the GLIB2 libraries
# Once done this will define
#
-# GLIB2_FOUND - system has glib2
-# GLIB2_INCLUDE_DIRS - the glib2 include directory
-# GLIB2_LIBRARIES - glib2 library
-# GLIB2_DLL_DIR - (Windows) Path to required GLib2 DLLs.
-# GLIB2_DLLS - (Windows) List of required GLib2 DLLs.
+# GLIB2_FOUND - system has glib2
+# GLIB2_INCLUDE_DIRS - the glib2 include directory
+# GLIB2_LIBRARIES - glib2 library
+# GLIB2_DLL_DIR_DEBUG - (Windows) Path to required GLib2 DLLs in debug build.
+# GLIB2_DLL_DIR_RELEASE - (Windows) Path to required GLib2 DLLs in release builds.
+# GLIB2_DLLS_DEBUG - (Windows) List of required GLib2 DLLs in debug builds.
+# GLIB2_DLLS_RELEASE - (Windows) List of required GLib2 DLLs in release builds.
# Copyright (c) 2008 Laurent Montel, <montel@kde.org>
#
@@ -44,13 +46,15 @@ find_path( GLIB2_MAIN_INCLUDE_DIR
/usr/local/include
)
-find_library( GLIB2_LIBRARY
+include(FindWSLibrary)
+FindWSLibrary( GLIB2_LIBRARY
NAMES
glib-2.0
libglib-2.0
HINTS
"${PC_GLIB2_LIBDIR}"
- "${GLIB2_HINTS}/lib"
+ WIN32_HINTS
+ ${GLIB2_HINTS}
PATHS
/opt/gnome/lib64
/opt/gnome/lib
@@ -113,53 +117,94 @@ if( GLIB2_FOUND )
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"
- CACHE PATH "Path to GLib2 DLLs"
+ set ( GLIB2_DLL_DIR_RELEASE "${GLIB2_HINTS}/bin"
+ CACHE PATH "Path to GLib2 release DLLs"
)
+ set ( GLIB2_DLL_DIR_DEBUG "${GLIB2_HINTS}/debug/bin"
+ CACHE PATH "Path to GLib2 debug DLLs"
+ )
+
# GTK+ required GObject and GIO. We probably don't.
- file( GLOB _glib2_dlls RELATIVE "${GLIB2_DLL_DIR}"
- # "${GLIB2_DLL_DIR}/gio-2.dll"
- "${GLIB2_DLL_DIR}/glib-2.dll"
- "${GLIB2_DLL_DIR}/gmodule-2.dll"
- # "${GLIB2_DLL_DIR}/gobject-2.dll"
- "${GLIB2_DLL_DIR}/gthread-2.dll"
- "${GLIB2_DLL_DIR}/libcharset.dll"
+ file( GLOB _glib2_dlls_release RELATIVE "${GLIB2_DLL_DIR_RELEASE}"
+ # "${GLIB2_DLL_DIR_RELEASE}/gio-2.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/glib-2.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/gmodule-2.dll"
+ # "${GLIB2_DLL_DIR_RELEASE}/gobject-2.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/gthread-2.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/libcharset.dll"
+ # gnutls-3.6.3-1-win64ws ships with libffi-6.dll
+ # "${GLIB2_DLL_DIR_RELEASE}/libffi.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/libiconv.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/libintl.dll"
+ "${GLIB2_DLL_DIR_RELEASE}/pcre.dll"
+ # "${GLIB2_DLL_DIR_RELEASE}/pcre16.dll"
+ # "${GLIB2_DLL_DIR_RELEASE}/pcre32.dll"
+ # "${GLIB2_DLL_DIR_RELEASE}/pcrecpp.dll"
+ # "${GLIB2_DLL_DIR_RELEASE}/pcreposix.dll"
+ )
+ set ( GLIB2_DLLS_RELEASE ${_glib2_dlls_release}
+ # We're storing filenames only. Should we use STRING instead?
+ CACHE FILEPATH "GLib 2 release DLL list"
+ )
+ file( GLOB _glib2_dlls_debug RELATIVE "${GLIB2_DLL_DIR_DEBUG}"
+ # "${GLIB2_DLL_DIR_DEBUG}/gio-2.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/glib-2.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/gmodule-2.dll"
+ # "${GLIB2_DLL_DIR_DEBUG}/gobject-2.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/gthread-2.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/libcharset.dll"
# gnutls-3.6.3-1-win64ws ships with libffi-6.dll
- # "${GLIB2_DLL_DIR}/libffi.dll"
- "${GLIB2_DLL_DIR}/libiconv.dll"
- "${GLIB2_DLL_DIR}/libintl.dll"
- "${GLIB2_DLL_DIR}/pcre.dll"
- # "${GLIB2_DLL_DIR}/pcre16.dll"
- # "${GLIB2_DLL_DIR}/pcre32.dll"
- # "${GLIB2_DLL_DIR}/pcrecpp.dll"
- # "${GLIB2_DLL_DIR}/pcreposix.dll"
+ # "${GLIB2_DLL_DIR_DEBUG}/libffi.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/libiconv.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/libintl.dll"
+ "${GLIB2_DLL_DIR_DEBUG}/pcred.dll"
+ # "${GLIB2_DLL_DIR_DEBUG}/pcre16d.dll"
+ # "${GLIB2_DLL_DIR_DEBUG}/pcre32d.dll"
+ # "${GLIB2_DLL_DIR_DEBUG}/pcrecppd.dll"
+ # "${GLIB2_DLL_DIR_DEBUG}/pcreposixd.dll"
)
- set ( GLIB2_DLLS ${_glib2_dlls}
+ set ( GLIB2_DLLS_DEBUG ${_glib2_dlls_debug}
# We're storing filenames only. Should we use STRING instead?
- CACHE FILEPATH "GLib 2 DLL list"
+ CACHE FILEPATH "GLib 2 debug DLL list"
)
- file( GLOB _glib2_pdbs RELATIVE "${GLIB2_DLL_DIR}"
- "${GLIB2_DLL_DIR}/glib-2.pdb"
- "${GLIB2_DLL_DIR}/gmodule-2.pdb"
- "${GLIB2_DLL_DIR}/gthread-2.pdb"
- "${GLIB2_DLL_DIR}/libcharset.pdb"
- "${GLIB2_DLL_DIR}/libiconv.pdb"
- "${GLIB2_DLL_DIR}/libintl.pdb"
- "${GLIB2_DLL_DIR}/pcre.pdb"
+ file( GLOB _glib2_pdbs_release RELATIVE "${GLIB2_DLL_DIR_RELEASE}"
+ "${GLIB2_DLL_DIR_RELEASE}/glib-2.pdb"
+ "${GLIB2_DLL_DIR_RELEASE}/gmodule-2.pdb"
+ "${GLIB2_DLL_DIR_RELEASE}/gthread-2.pdb"
+ "${GLIB2_DLL_DIR_RELEASE}/libcharset.pdb"
+ "${GLIB2_DLL_DIR_RELEASE}/libiconv.pdb"
+ "${GLIB2_DLL_DIR_RELEASE}/libintl.pdb"
+ "${GLIB2_DLL_DIR_RELEASE}/pcre.pdb"
+ )
+ set ( GLIB2_PDBS_RELEASE ${_glib2_pdbs_release}
+ CACHE FILEPATH "GLib2 debug release PDB list"
+ )
+ file( GLOB _glib2_pdbs_debug RELATIVE "${GLIB2_DLL_DIR_DEBUG}"
+ "${GLIB2_DLL_DIR_DEBUG}/glib-2.pdb"
+ "${GLIB2_DLL_DIR_DEBUG}/gmodule-2.pdb"
+ "${GLIB2_DLL_DIR_DEBUG}/gthread-2.pdb"
+ "${GLIB2_DLL_DIR_DEBUG}/libcharset.pdb"
+ "${GLIB2_DLL_DIR_DEBUG}/libiconv.pdb"
+ "${GLIB2_DLL_DIR_DEBUG}/libintl.pdb"
+ "${GLIB2_DLL_DIR_DEBUG}/pcred.pdb"
)
- set ( GLIB2_PDBS ${_glib2_pdbs}
- CACHE FILEPATH "GLib2 PDB list"
+ set ( GLIB2_PDBS_DEBUG ${_glib2_pdbs_debug}
+ CACHE FILEPATH "GLib2 debug debug PDB list"
)
- mark_as_advanced( GLIB2_DLL_DIR GLIB2_DLLS GLIB2_PDBS )
+ mark_as_advanced( GLIB2_DLL_DIR_RELEASE GLIB2_DLLS_RELEASE GLIB2_PDBS_RELEASE )
+ mark_as_advanced( GLIB2_DLL_DIR_DEBUG GLIB2_DLLS_DEBUG GLIB2_PDBS_DEBUG )
endif()
elseif( GLIB2_FIND_REQUIRED )
message( SEND_ERROR "Package required but not found" )
else()
set( GLIB2_LIBRARIES )
set( GLIB2_MAIN_INCLUDE_DIRS )
- set( GLIB2_DLL_DIR )
+ set( GLIB2_DLL_DIR_RELEASE )
+ set( GLIB2_DLL_DIR_DEBUG )
+ set( GLIB2_PDBS_RELEASE )
+ set( GLIB2_PDBS_DEBUG )
set( GLIB2_DLLS )
endif()
diff --git a/cmake/modules/FindGMODULE2.cmake b/cmake/modules/FindGMODULE2.cmake
index 5bcfec7be3..46ff224068 100644
--- a/cmake/modules/FindGMODULE2.cmake
+++ b/cmake/modules/FindGMODULE2.cmake
@@ -24,12 +24,14 @@ find_path(GMODULE2_INCLUDE_DIR
${PC_GMODULE2_INCLUDE_DIRS}
"${GMODULE2_HINTS}/include"
)
-find_library(GMODULE2_LIBRARY
+include(FindWSLibrary)
+FindWSLibrary(GMODULE2_LIBRARY
NAMES
gmodule-2.0 gmodule
HINTS
${PC_GMODULE2_LIBRARY_DIRS}
- "${GMODULE2_HINTS}/lib"
+ WIN32_HINTS
+ ${GMODULE2_HINTS}
)
include(FindPackageHandleStandardArgs)
diff --git a/cmake/modules/FindGTHREAD2.cmake b/cmake/modules/FindGTHREAD2.cmake
index 57f8640007..3a3567591f 100644
--- a/cmake/modules/FindGTHREAD2.cmake
+++ b/cmake/modules/FindGTHREAD2.cmake
@@ -24,12 +24,14 @@ find_path(GTHREAD2_INCLUDE_DIR
${PC_GTHREAD2_INCLUDE_DIRS}
"${GTHREAD2_HINTS}/include"
)
-find_library(GTHREAD2_LIBRARY
+include(FindWSLibrary)
+FindWSLibrary(GTHREAD2_LIBRARY
NAMES
gthread-2.0 gthread
HINTS
${PC_GTHREAD2_LIBRARY_DIRS}
- "${GTHREAD2_HINTS}/lib"
+ WIN32_HINTS
+ ${GTHREAD2_HINTS}
)
include(FindPackageHandleStandardArgs)
diff --git a/cmake/modules/FindWSLibrary.cmake b/cmake/modules/FindWSLibrary.cmake
new file mode 100644
index 0000000000..20e183cfe1
--- /dev/null
+++ b/cmake/modules/FindWSLibrary.cmake
@@ -0,0 +1,36 @@
+#
+# - Find WS Library
+# This function is a wrapper for find_library() that does handle vcpkg exported
+# library directory structure
+
+function(FindWSLibrary OUTPUT_LIBRARY)
+ cmake_parse_arguments(PARSE_ARGV 1
+ WS_LIB
+ ""
+ "WIN32_HINTS"
+ "NAMES;HINTS;PATHS"
+ )
+
+ if (WIN32)
+ find_library(${OUTPUT_LIBRARY}_DEBUG
+ NAMES ${WS_LIB_NAMES}
+ HINTS "${WS_LIB_WIN32_HINTS}/debug/lib"
+ PATHS ${WS_LIB_PATHS}
+ )
+ find_library(${OUTPUT_LIBRARY}_RELEASE
+ NAMES ${WS_LIB_NAMES}
+ HINTS "${WS_LIB_WIN32_HINTS}/lib"
+ PATHS ${WS_LIB_PATHS}
+ )
+
+ if (${OUTPUT_LIBRARY}_DEBUG AND ${OUTPUT_LIBRARY}_RELEASE)
+ set(${OUTPUT_LIBRARY} debug ${${OUTPUT_LIBRARY}_DEBUG} optimized ${${OUTPUT_LIBRARY}_RELEASE} PARENT_SCOPE)
+ endif()
+ else()
+ find_library(${OUTPUT_LIBRARY}
+ NAMES ${WS_LIB_NAMES}
+ HINTS ${WS_LIB_HINTS}
+ PATHS ${WS_LIB_PATHS}
+ )
+ endif()
+endfunction()