diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-10-18 18:54:24 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-10-18 20:05:43 +0000 |
commit | e6e2137459750cfac0b9ce7bcf259fe8bbccbede (patch) | |
tree | d9654cdd26712d53ec0892b77bf71d23b500e035 /cmake/modules/FindGMODULE2.cmake | |
parent | 021b305bcbf8b9cbd8f7a600c69c9b0e18ff9ffb (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/modules/FindGMODULE2.cmake')
-rw-r--r-- | cmake/modules/FindGMODULE2.cmake | 75 |
1 files changed, 32 insertions, 43 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) |