Commit e09eb126 authored by Ralf Habacker's avatar Ralf Habacker
parent 497cc68c
......@@ -109,6 +109,11 @@ option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF)
find_package(EXPAT)
find_package(X11)
find_package(GLib2)
find_package(GObject)
if(GLIB2_FOUND AND GOBJECT_FOUND)
option (DBUS_WITH_GLIB "build with glib" ON)
endif()
# analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac
add_definitions(-D_GNU_SOURCE)
......@@ -539,6 +544,7 @@ message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} "
message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ")
message(" Building unit tests: ${DBUS_BUILD_TESTS} ")
message(" Building with GLib: ${DBUS_WITH_GLIB} ")
message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ")
message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ")
message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ")
......
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.
# - Try to find the GLIB library
# Once done this will define
#
# GLIB_FOUND - system has GLIB
# GLIB_INCLUDES - the GLIB include directories
# GLIB_LIBRARIES - The libraries needed to use GLIB
if (WIN32)
INCLUDE(MacroGetenvWinPath)
MACRO_GETENV_WIN_PATH(_program_FILES_DIR PROGRAMFILES)
FIND_PATH(GLIB_INCLUDE_DIR glib.h
${_program_FILES_DIR}/glib/include/glib-2.0
)
# search for GLIB in the default install directory for applications (default of (n)make install)
FIND_LIBRARY(GLIB_LIBRARY NAMES glib-2.0
PATHS
${_program_FILES_DIR}/glib/lib
)
if (GLIB_LIBRARY AND GLIB_INCLUDE_DIR)
set(GLIB_FOUND TRUE)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${GLIB_INCLUDES})
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${GLIB_LIBRARIES})
endif (GLIB_LIBRARY AND GLIB_INCLUDE_DIR)
if (GLIB_FOUND)
if (NOT GLIB_FIND_QUIETLY)
message(STATUS "Found GLIB: ${GLIB_LIBRARY}")
endif (NOT GLIB_FIND_QUIETLY)
else (GLIB_FOUND)
if (GLIB_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find GLIB library")
endif (GLIB_FIND_REQUIRED)
endif (GLIB_FOUND)
endif (WIN32)
# - Try to find the GLIB2 libraries
# Once done this will define
#
# GLIB2_FOUND - system has glib2
# GLIB2_INCLUDE_DIR - the glib2 include directory
# GLIB2_LIBRARIES - glib2 library
# Copyright (c) 2008 Laurent Montel, <montel@kde.org>
# Copyright (c) 2013 Ralf Habacker, <ralf.habacker@freenet.de>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# Already in cache, be silent
set(GLIB2_FIND_QUIETLY TRUE)
endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
if (NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(PC_LibGLIB2 QUIET glib-2.0)
endif()
find_path(GLIB2_MAIN_INCLUDE_DIR
NAMES glib.h
HINTS ${PC_LibGLIB2_INCLUDEDIR}
PATH_SUFFIXES glib-2.0)
find_library(GLIB2_LIBRARY
NAMES glib-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})
# search the glibconfig.h include dir under the same root where the library is found
get_filename_component(glib2LibDir "${GLIB2_LIBRARY}" PATH)
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include
HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}")
# not sure if this include dir is optional or required
# for now it is optional
if(GLIB2_INTERNAL_INCLUDE_DIR)
set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}")
endif(GLIB2_INTERNAL_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)
mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES)
# - 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)
......@@ -71,6 +71,51 @@ target_link_libraries(test-segfault ${DBUS_INTERNAL_LIBRARIES})
add_executable(test-sleep-forever ${test-sleep-forever_SOURCES})
target_link_libraries(test-sleep-forever ${DBUS_INTERNAL_LIBRARIES})
if(DBUS_WITH_GLIB)
message(STATUS "with glib test apps")
add_definitions(
${GLIB2_DEFINITIONS}
${GOBJECT_DEFINITIONS}
)
include_directories(
${GLIB2_INCLUDE_DIR}
${GOBJECT_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/../test
)
set (TEST_LIBRARIES dbus-testutils ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES})
add_executable(test-corrupt ${CMAKE_SOURCE_DIR}/../test/corrupt.c)
target_link_libraries(test-corrupt ${TEST_LIBRARIES})
add_executable(test-dbus-daemon ${CMAKE_SOURCE_DIR}/../test/dbus-daemon.c)
target_link_libraries(test-dbus-daemon ${TEST_LIBRARIES})
add_executable(test-dbus-daemon-eavesdrop ${CMAKE_SOURCE_DIR}/../test/dbus-daemon-eavesdrop.c)
target_link_libraries(test-dbus-daemon-eavesdrop ${TEST_LIBRARIES})
add_executable(test-loopback ${CMAKE_SOURCE_DIR}/../test/loopback.c)
target_link_libraries(test-loopback ${TEST_LIBRARIES})
add_executable(test-marshal ${CMAKE_SOURCE_DIR}/../test/marshal.c)
target_link_libraries(test-marshal ${TEST_LIBRARIES})
add_executable(test-refs ${CMAKE_SOURCE_DIR}/../test/internals/refs.c)
target_link_libraries(test-refs ${TEST_LIBRARIES})
add_executable(test-relay ${CMAKE_SOURCE_DIR}/../test/relay.c)
target_link_libraries(test-relay ${TEST_LIBRARIES})
add_executable(test-syntax ${CMAKE_SOURCE_DIR}/../test/syntax.c)
target_link_libraries(test-syntax ${TEST_LIBRARIES})
add_executable(test-syslog ${CMAKE_SOURCE_DIR}/../test/internals/syslog.c)
target_link_libraries(test-syslog ${TEST_LIBRARIES})
add_executable(manual-authz ${CMAKE_SOURCE_DIR}/../test/manual-authz.c)
target_link_libraries(manual-authz ${TEST_LIBRARIES})
endif()
### keep these in creation order, i.e. uppermost dirs first
set (TESTDIRS
test/data
......@@ -81,6 +126,7 @@ set (TESTDIRS
test/data/sha-1
test/data/valid-config-files
test/data/valid-config-files/basic.d
test/data/valid-config-files/session.d
test/data/valid-config-files/system.d
test/data/valid-config-files-system
test/data/valid-introspection-files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment