cmake: Fold GObject detection into GLib detection

Everywhere that we want GLib, we also want GObject and GIO. Detecting
GLib and GIO but not GObject makes very little sense anyway, because
GIO depends on GObject.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105521
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
Simon McVittie 2017-10-23 12:00:29 +01:00
parent 27113c75f3
commit 4e3bfe0c97
5 changed files with 9 additions and 61 deletions

View file

@ -139,8 +139,7 @@ endif()
find_package(EXPAT)
find_package(X11)
find_package(GLib2)
find_package(GObject)
if(GLIB2_FOUND AND GOBJECT_FOUND)
if(GLIB2_FOUND)
option (DBUS_WITH_GLIB "build with glib" ON)
endif()

View file

@ -32,12 +32,17 @@ find_library(GLIB2_LIBRARY
HINTS ${PC_LibGLIB2_LIBDIR}
)
find_library(GOBJECT2_LIBRARY
NAMES gobject-2.0
HINTS ${PC_LibGLIB2_LIBDIR}
)
find_library(GIO2_LIBRARY
NAMES gio-2.0
HINTS ${PC_LibGLIB2_LIBDIR}
)
set(GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GIO2_LIBRARY})
set(GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GOBJECT2_LIBRARY} ${GIO2_LIBRARY})
# search the glibconfig.h include dir under the same root where the library is found
get_filename_component(glib2LibDir "${GLIB2_LIBRARY}" PATH)

View file

@ -1,52 +0,0 @@
# - Try to find GObject
# Once done this will define
#
# GOBJECT_FOUND - system has GObject
# GOBJECT_INCLUDE_DIR - the GObject include directory
# GOBJECT_LIBRARIES - the libraries needed to use GObject
# GOBJECT_DEFINITIONS - Compiler switches required for using GObject
# Copyright (c) 2011, Raphael Kubo da Costa <kubito@gmail.com>
# Copyright (c) 2006, Tim Beaulen <tbscope@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_GOBJECT gobject-2.0)
SET(GOBJECT_DEFINITIONS ${PC_GOBJECT_CFLAGS_OTHER})
FIND_PATH(GOBJECT_INCLUDE_DIR gobject.h
HINTS
${PC_GOBJECT_INCLUDEDIR}
${PC_GOBJECT_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0/gobject/
)
FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
FIND_LIBRARY(_GLibs NAMES glib-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
SET( GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs} )
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GOBJECT DEFAULT_MSG GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR)
MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR _GObjectLibs _GModuleLibs _GThreadLibs _GLibs)

View file

@ -89,14 +89,12 @@ if(DBUS_WITH_GLIB)
add_definitions(
${GLIB2_DEFINITIONS}
${GOBJECT_DEFINITIONS}
)
include_directories(
${GLIB2_INCLUDE_DIR}
${GOBJECT_INCLUDE_DIR}
)
set(TEST_LIBRARIES ${DBUS_INTERNAL_LIBRARIES} dbus-testutils dbus-testutils-glib ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES})
set(TEST_LIBRARIES ${DBUS_INTERNAL_LIBRARIES} dbus-testutils dbus-testutils-glib ${GLIB2_LIBRARIES})
add_test_executable(test-corrupt ${CMAKE_SOURCE_DIR}/../test/corrupt.c ${TEST_LIBRARIES})
add_test_executable(test-dbus-daemon ${CMAKE_SOURCE_DIR}/../test/dbus-daemon.c ${TEST_LIBRARIES})

View file

@ -261,9 +261,7 @@ case "$ci_buildsys" in
set "$@" -D CMAKE_INCLUDE_PATH="${mingw}/include"
set "$@" -D CMAKE_LIBRARY_PATH="${mingw}/lib"
set "$@" -D EXPAT_LIBRARY="${mingw}/lib/libexpat.dll.a"
set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a"
set "$@" -D GOBJECT_LIBRARIES="${mingw}/lib/libgobject-2.0.dll.a"
set "$@" -D GIO_LIBRARIES="${mingw}/lib/libgio-2.0.dll.a"
set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a ${mingw}/lib/libgobject-2.0.dll.a ${mingw}/lib/libgio-2.0.dll.a"
shift
# don't run tests yet, Wine needs Xvfb and more
# msys2 libraries