-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More correct way to find GLib2 and GThread2.
Modules from the KDE ECM project. This fixes build on FreeBSD.
- Loading branch information
1 parent
782ffa9
commit 840bde0
Showing
3 changed files
with
171 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,235 +1,100 @@ | ||
# - Try to find GLib2 | ||
# Once done this will define | ||
#.rst: | ||
# FindGLIB2 | ||
# --------- | ||
# | ||
# GLIB2_FOUND - system has GLib2 | ||
# GLIB2_INCLUDE_DIRS - the GLib2 include directory | ||
# GLIB2_LIBRARIES - Link these to use GLib2 | ||
# Try to locate the GLib2 library. | ||
# If found, this will define the following variables: | ||
# | ||
# HAVE_GLIB_GREGEX_H glib has gregex.h header and | ||
# supports g_regex_match_simple | ||
# ``GLIB2_FOUND`` | ||
# True if the GLib2 library is available | ||
# ``GLIB2_INCLUDE_DIRS`` | ||
# The GLib2 include directories | ||
# ``GLIB2_LIBRARIES`` | ||
# The GLib2 libraries for linking | ||
# ``GLIB2_INCLUDE_DIR`` | ||
# Deprecated, use ``GLIB2_INCLUDE_DIRS`` | ||
# ``GLIB2_LIBRARY`` | ||
# Deprecated, use ``GLIB2_LIBRARIES`` | ||
# | ||
# Copyright (c) 2006 Andreas Schneider <[email protected]> | ||
# Copyright (c) 2006 Philippe Bernery <[email protected]> | ||
# Copyright (c) 2007 Daniel Gollub <[email protected]> | ||
# Copyright (c) 2007 Alban Browaeys <[email protected]> | ||
# Copyright (c) 2008 Michael Bell <[email protected]> | ||
# Copyright (c) 2008-2009 Bjoern Ricks <[email protected]> | ||
# If ``GLIB2_FOUND`` is TRUE, it will also define the following | ||
# imported target: | ||
# | ||
# Redistribution and use is allowed according to the terms of the New | ||
# BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
# ``GLIB2::GLIB2`` | ||
# The GLIB2 library | ||
# | ||
# Since 5.41.0. | ||
|
||
|
||
IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) | ||
# in cache already | ||
SET(GLIB2_FOUND TRUE) | ||
ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) | ||
|
||
INCLUDE(FindPkgConfig) | ||
|
||
## Glib | ||
IF ( GLIB2_FIND_REQUIRED ) | ||
SET( _pkgconfig_REQUIRED "REQUIRED" ) | ||
ELSE ( GLIB2_FIND_REQUIRED ) | ||
SET( _pkgconfig_REQUIRED "" ) | ||
ENDIF ( GLIB2_FIND_REQUIRED ) | ||
|
||
IF ( GLIB2_MIN_VERSION ) | ||
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) | ||
ELSE ( GLIB2_MIN_VERSION ) | ||
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) | ||
ENDIF ( GLIB2_MIN_VERSION ) | ||
IF ( PKG_CONFIG_FOUND ) | ||
IF ( GLIB2_FOUND ) | ||
SET ( GLIB2_CORE_FOUND TRUE ) | ||
ELSE ( GLIB2_FOUND ) | ||
SET ( GLIB2_CORE_FOUND FALSE ) | ||
ENDIF ( GLIB2_FOUND ) | ||
ENDIF ( PKG_CONFIG_FOUND ) | ||
|
||
# Look for glib2 include dir and libraries w/o pkgconfig | ||
IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) | ||
FIND_PATH( | ||
_glibconfig_include_DIR | ||
NAMES | ||
glibconfig.h | ||
PATHS | ||
/opt/gnome/lib64 | ||
/opt/gnome/lib | ||
/opt/lib/ | ||
/opt/local/lib | ||
/sw/lib/ | ||
/usr/lib64 | ||
/usr/lib | ||
/usr/local/include | ||
${CMAKE_LIBRARY_PATH} | ||
PATH_SUFFIXES | ||
glib-2.0/include | ||
) | ||
|
||
FIND_PATH( | ||
_glib2_include_DIR | ||
NAMES | ||
glib.h | ||
PATHS | ||
/opt/gnome/include | ||
/opt/local/include | ||
/sw/include | ||
/usr/include | ||
/usr/local/include | ||
PATH_SUFFIXES | ||
glib-2.0 | ||
) | ||
|
||
#MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") | ||
|
||
FIND_LIBRARY( | ||
_glib2_link_DIR | ||
NAMES | ||
glib-2.0 | ||
glib | ||
PATHS | ||
/opt/gnome/lib | ||
/opt/local/lib | ||
/sw/lib | ||
/usr/lib | ||
/usr/local/lib | ||
) | ||
IF ( _glib2_include_DIR AND _glib2_link_DIR ) | ||
SET ( _glib2_FOUND TRUE ) | ||
ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) | ||
|
||
|
||
IF ( _glib2_FOUND ) | ||
SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) | ||
SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) | ||
SET ( GLIB2_CORE_FOUND TRUE ) | ||
ELSE ( _glib2_FOUND ) | ||
SET ( GLIB2_CORE_FOUND FALSE ) | ||
ENDIF ( _glib2_FOUND ) | ||
|
||
# Handle dependencies | ||
# libintl | ||
IF ( NOT LIBINTL_FOUND ) | ||
FIND_PATH(LIBINTL_INCLUDE_DIR | ||
NAMES | ||
libintl.h | ||
PATHS | ||
/opt/gnome/include | ||
/opt/local/include | ||
/sw/include | ||
/usr/include | ||
/usr/local/include | ||
) | ||
|
||
FIND_LIBRARY(LIBINTL_LIBRARY | ||
NAMES | ||
intl | ||
PATHS | ||
/opt/gnome/lib | ||
/opt/local/lib | ||
/sw/lib | ||
/usr/local/lib | ||
/usr/lib | ||
) | ||
|
||
IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) | ||
SET (LIBINTL_FOUND TRUE) | ||
ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) | ||
ENDIF ( NOT LIBINTL_FOUND ) | ||
|
||
# libiconv | ||
IF ( NOT LIBICONV_FOUND ) | ||
FIND_PATH(LIBICONV_INCLUDE_DIR | ||
NAMES | ||
iconv.h | ||
PATHS | ||
/opt/gnome/include | ||
/opt/local/include | ||
/opt/local/include | ||
/sw/include | ||
/sw/include | ||
/usr/local/include | ||
/usr/include | ||
PATH_SUFFIXES | ||
glib-2.0 | ||
) | ||
|
||
FIND_LIBRARY(LIBICONV_LIBRARY | ||
NAMES | ||
iconv | ||
PATHS | ||
/opt/gnome/lib | ||
/opt/local/lib | ||
/sw/lib | ||
/usr/lib | ||
/usr/local/lib | ||
) | ||
|
||
IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) | ||
SET (LIBICONV_FOUND TRUE) | ||
ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) | ||
ENDIF ( NOT LIBICONV_FOUND ) | ||
|
||
IF (LIBINTL_FOUND) | ||
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) | ||
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) | ||
ENDIF (LIBINTL_FOUND) | ||
|
||
IF (LIBICONV_FOUND) | ||
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) | ||
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) | ||
ENDIF (LIBICONV_FOUND) | ||
|
||
ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) | ||
## | ||
|
||
IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) | ||
SET (GLIB2_FOUND TRUE) | ||
ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) | ||
|
||
IF (GLIB2_FOUND) | ||
IF (NOT GLIB2_FIND_QUIETLY) | ||
MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") | ||
ENDIF (NOT GLIB2_FIND_QUIETLY) | ||
ELSE (GLIB2_FOUND) | ||
IF (GLIB2_FIND_REQUIRED) | ||
MESSAGE (SEND_ERROR "Could not find GLib2") | ||
ENDIF (GLIB2_FIND_REQUIRED) | ||
ENDIF (GLIB2_FOUND) | ||
|
||
# show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view | ||
MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) | ||
MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) | ||
MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) | ||
|
||
ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) | ||
|
||
IF ( WIN32 ) | ||
# include libiconv for win32 | ||
IF ( NOT LIBICONV_FOUND ) | ||
FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h PATH_SUFFIXES glib-2.0) | ||
|
||
FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv) | ||
|
||
IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) | ||
SET (LIBICONV_FOUND TRUE) | ||
ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) | ||
ENDIF ( NOT LIBICONV_FOUND ) | ||
IF (LIBICONV_FOUND) | ||
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) | ||
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) | ||
ENDIF (LIBICONV_FOUND) | ||
ENDIF ( WIN32 ) | ||
|
||
IF ( GLIB2_FOUND ) | ||
# Check if system has a newer version of glib | ||
# which supports g_regex_match_simple | ||
INCLUDE( CheckIncludeFiles ) | ||
SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) | ||
CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) | ||
CHECK_INCLUDE_FILES ( glib/gchecksum.h HAVE_GLIB_GCHECKSUM_H ) | ||
# Reset CMAKE_REQUIRED_INCLUDES | ||
SET( CMAKE_REQUIRED_INCLUDES "" ) | ||
ENDIF( GLIB2_FOUND ) | ||
#============================================================================= | ||
# Copyright (c) 2008 Laurent Montel, <[email protected]> | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# 1. Redistributions of source code must retain the copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# 3. The name of the author may not be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#============================================================================= | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_GLIB2 QUIET glib-2.0) | ||
|
||
find_path(GLIB2_INCLUDE_DIRS | ||
NAMES glib.h | ||
HINTS ${PC_GLIB2_INCLUDEDIR} | ||
PATH_SUFFIXES glib-2.0) | ||
|
||
find_library(GLIB2_LIBRARIES | ||
NAMES glib-2.0 | ||
HINTS ${PC_GLIB2_LIBDIR} | ||
) | ||
|
||
# search the glibconfig.h include dir under the same root where the library is found | ||
get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) | ||
|
||
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h | ||
PATH_SUFFIXES glib-2.0/include | ||
HINTS ${PC_GLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) | ||
|
||
# not sure if this include dir is optional or required | ||
# for now it is optional | ||
if(GLIB2_INTERNAL_INCLUDE_DIR) | ||
list(APPEND GLIB2_INCLUDE_DIRS "${GLIB2_INTERNAL_INCLUDE_DIR}") | ||
endif() | ||
|
||
# Deprecated synonyms | ||
set(GLIB2_INCLUDE_DIR "${GLIB2_INCLUDE_DIRS}") | ||
set(GLIB2_LIBRARY "${GLIB2_LIBRARIES}") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_INCLUDE_DIRS) | ||
|
||
if(GLIB2_FOUND AND NOT TARGET GLIB2::GLIB2) | ||
add_library(GLIB2::GLIB2 UNKNOWN IMPORTED) | ||
set_target_properties(GLIB2::GLIB2 PROPERTIES | ||
IMPORTED_LOCATION "${GLIB2_LIBRARIES}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${GLIB2_INCLUDE_DIRS}") | ||
endif() | ||
|
||
mark_as_advanced(GLIB2_INCLUDE_DIRS GLIB2_INCLUDE_DIR | ||
GLIB2_LIBRARIES GLIB2_LIBRARY) | ||
|
||
include(FeatureSummary) | ||
set_package_properties(GLIB2 PROPERTIES | ||
URL "https://wiki.gnome.org/Projects/GLib" | ||
DESCRIPTION "Event loop and utility library") |
Oops, something went wrong.