aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-10-18 18:54:24 +0200
committerAnders Broman <a.broman58@gmail.com>2018-10-18 20:05:43 +0000
commite6e2137459750cfac0b9ce7bcf259fe8bbccbede (patch)
treed9654cdd26712d53ec0892b77bf71d23b500e035 /cmake
parent021b305bcbf8b9cbd8f7a600c69c9b0e18ff9ffb (diff)
cmake: rewrite FindGMODULE2.cmake and FindGTHREAD2.cmake
These modules currently set the library variables from PkgConfig directly, but these are not absolute paths. These modules are therefore not usable for static linking. Rewrite these files to follow a more familiar pattern: collect hints, find absolute header/library paths and let FPHSA handle the REQUIRED check. The old modules had some special cases for Apple, but I believe that these cases are no longer relevant. Change-Id: Idaef7e35b40a3ab4449d92ccb12a9febde962cf6 Reviewed-on: https://code.wireshark.org/review/30251 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindGMODULE2.cmake75
-rw-r--r--cmake/modules/FindGTHREAD2.cmake73
2 files changed, 65 insertions, 83 deletions
diff --git a/cmake/modules/FindGMODULE2.cmake b/cmake/modules/FindGMODULE2.cmake
index 98ddc76467..5f22f81444 100644
--- a/cmake/modules/FindGMODULE2.cmake
+++ b/cmake/modules/FindGMODULE2.cmake
@@ -2,56 +2,45 @@
# - Try to find GModule2
# Find GModule headers, libraries and the answer to all questions.
#
-# GMODULE2_FOUND True if GMODULE2 got found
+# GMODULE2_FOUND True if GMODULE2 was found
# GMODULE2_INCLUDE_DIRS Location of GMODULE2 headers
# GMODULE2_LIBRARIES List of libraries to use GMODULE2
#
-# Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
-#
-# Redistribution and use is allowed according to the terms of the New
-# BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
-
-if( NOT WIN32 )
- include( FindPkgConfig )
- if( GMODULE2_FIND_REQUIRED )
- set( _pkgconfig_REQUIRED "REQUIRED" )
- else()
- set( _pkgconfig_REQUIRED "" )
- endif()
+include(FindWSWinLibs)
+FindWSWinLibs("glib2-*" "GMODULE2_HINTS")
- if( GMODULE2_MIN_VERSION )
- pkg_search_module( GMODULE2 ${_pkgconfig_REQUIRED} gmodule-2.0>=${GMODULE2_MIN_VERSION} )
- else()
- pkg_search_module( GMODULE2 ${_pkgconfig_REQUIRED} gmodule-2.0 )
- endif()
+if(NOT WIN32)
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(PC_GMODULE2 gmodule-2.0)
endif()
-if( GMODULE2_FOUND )
- if( GMODULE2_LIBRARY_DIRS )
- LINK_DIRECTORIES( ${GMODULE2_LIBRARY_DIRS} )
- endif()
+find_path(GMODULE2_INCLUDE_DIR
+ NAMES
+ gmodule.h
+ PATH_SUFFIXES
+ glib-2.0
+ HINTS
+ ${PC_GMODULE2_INCLUDE_DIRS}
+ "${GMODULE2_HINTS}/include"
+)
+find_library(GMODULE2_LIBRARY
+ NAMES
+ gmodule-2.0 gmodule
+ HINTS
+ ${PC_GMODULE2_LIBRARY_DIRS}
+ "${GMODULE2_HINTS}/lib"
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GMODULE2 DEFAULT_MSG GMODULE2_LIBRARY GMODULE2_INCLUDE_DIR)
+
+if(GMODULE2_FOUND)
+ set(GMODULE2_INCLUDE_DIRS ${GMODULE2_INCLUDE_DIR})
+ set(GMODULE2_LIBRARIES ${GMODULE2_LIBRARY})
else()
- include( FindWSWinLibs )
- FindWSWinLibs( "glib2-*" "GMODULE2_HINTS" )
- find_path( GMODULE2_INCLUDE_DIRS
- NAMES
- gmodule.h
- PATH_SUFFIXES
- glib-2.0
- HINTS
- "${GMODULE2_HINTS}/include"
- )
- find_library( GMODULE2_LIBRARIES NAMES gmodule-2.0 gmodule HINTS "${GMODULE2_HINTS}/lib" )
- if( NOT GMODULE2_LIBRARIES AND APPLE )
- # Fallback as APPLE glib libs already contain this - except
- # Homebrew which needs the non-Apple setup
- find_library( GMODULE2_LIBRARIES glib )
- endif()
- include( FindPackageHandleStandardArgs )
- find_package_handle_standard_args( GMODULE2 DEFAULT_MSG GMODULE2_LIBRARIES GMODULE2_INCLUDE_DIRS )
+ set(GMODULE2_INCLUDE_DIRS)
+ set(GMODULE2_LIBRARIES)
endif()
-mark_as_advanced( GMODULE2_LIBRARIES GMODULE2_INCLUDE_DIRS )
+mark_as_advanced(GMODULE2_LIBRARIES GMODULE2_INCLUDE_DIRS)
diff --git a/cmake/modules/FindGTHREAD2.cmake b/cmake/modules/FindGTHREAD2.cmake
index 3aa75e57d4..57cc5c17b6 100644
--- a/cmake/modules/FindGTHREAD2.cmake
+++ b/cmake/modules/FindGTHREAD2.cmake
@@ -1,53 +1,46 @@
-# - Try to find GThread2
#
+# - Try to find GThread2
# Find GThread headers, libraries and the answer to all questions.
#
-# GTHREAD2_FOUND True if GTHREAD2 got found
+# GTHREAD2_FOUND True if GTHREAD2 was found
# GTHREAD2_INCLUDE_DIRS Location of GTHREAD2 headers
# GTHREAD2_LIBRARIES List of libraries to use GTHREAD2
#
-# Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
-#
-# Redistribution and use is allowed according to the terms of the New
-# BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
-if( NOT WIN32 )
- include( FindPkgConfig )
+include(FindWSWinLibs)
+FindWSWinLibs("glib2-*" "GTHREAD2_HINTS")
- if( GTHREAD2_MIN_VERSION )
- PKG_SEARCH_MODULE( GTHREAD2 gthread-2.0>=${GTHREAD2_MIN_VERSION} )
- else()
- PKG_SEARCH_MODULE( GTHREAD2 gthread-2.0 )
- endif()
+if(NOT WIN32)
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(PC_GTHREAD2 gthread-2.0)
endif()
-if( GTHREAD2_FOUND )
- if( GMODULE2_LIBRARY_DIRS )
- LINK_DIRECTORIES( ${GMODULE2_LIBRARY_DIRS} )
- endif()
+find_path(GTHREAD2_INCLUDE_DIR
+ NAMES
+ glib/gthread.h
+ PATH_SUFFIXES
+ glib-2.0
+ HINTS
+ ${PC_GTHREAD2_INCLUDE_DIRS}
+ "${GTHREAD2_HINTS}/include"
+)
+find_library(GTHREAD2_LIBRARY
+ NAMES
+ gthread-2.0 gthread
+ HINTS
+ ${PC_GTHREAD2_LIBRARY_DIRS}
+ "${GTHREAD2_HINTS}/lib"
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GTHREAD2 DEFAULT_MSG GTHREAD2_LIBRARY GTHREAD2_INCLUDE_DIR)
+
+if(GTHREAD2_FOUND)
+ set(GTHREAD2_INCLUDE_DIRS ${GTHREAD2_INCLUDE_DIR})
+ set(GTHREAD2_LIBRARIES ${GTHREAD2_LIBRARY})
else()
- include( FindWSWinLibs )
- FindWSWinLibs( "glib2-*" "GTHREAD2_HINTS" )
- find_path( GTHREAD2_INCLUDE_DIRS gthread.h PATH_SUFFIXES glib-2.0 glib GLib.framework/Headers/glib glib-2.0/glib HINTS "${GTHREAD2_HINTS}/include" )
- find_library( GTHREAD2_LIBRARIES gthread-2.0 HINTS "${GTHREAD2_HINTS}/lib" )
- if( NOT GTHREAD2_LIBRARIES )
- # GLib contains GThread in some cases.
- if( APPLE )
- # Fallback as APPLE glib libs already contain this - except
- # Homebrew which needs the non-Apple setup
- find_library( GTHREAD2_LIBRARIES glib )
- elseif( WIN32 )
- find_library( GTHREAD2_LIBRARIES glib-2.0 HINTS "${GTHREAD2_HINTS}/lib" )
- endif()
- endif()
- include( FindPackageHandleStandardArgs )
- find_package_handle_standard_args( GTHREAD2 DEFAULT_MSG GTHREAD2_LIBRARIES GTHREAD2_INCLUDE_DIRS )
- if( NOT GTHREAD2_FOUND AND GTHREAD2_FIND_REQUIRED )
- message( SEND_ERROR "Package required but not found" )
- endif()
+ set(GTHREAD2_INCLUDE_DIRS)
+ set(GTHREAD2_LIBRARIES)
endif()
-
-mark_as_advanced( GTHREAD2_LIBRARIES GTHREAD2_INCLUDE_DIRS )
+mark_as_advanced(GTHREAD2_LIBRARIES GTHREAD2_INCLUDE_DIRS)