source: CMakeModules/FindDBus.cmake@ 12775

Last change on this file since 12775 was 10700, checked in by Michael Tänzer, 12 years ago

Merge CMake branch into trunk

File size: 3.5 KB
Line 
1# - Find D-Bus
2# Find the D-Bus inter-process messaging library
3#
4# respects the BUILD_STATIC_BINS variable => searches for static library and its
5# dependencies
6#
7# DBUS_INCLUDE_DIR - where to find dbus/dbus.h etc.
8# DBUS_LIBRARIES - List of libraries when using D-Bus.
9# DBUS_FOUND - True if D-Bus was found.
10
11
12# [License]
13# The Ariba-Underlay Copyright
14#
15# Copyright (c) 2008-2012, Institute of Telematics, UniversitÀt Karlsruhe (TH)
16#
17# Institute of Telematics
18# UniversitÀt Karlsruhe (TH)
19# Zirkel 2, 76128 Karlsruhe
20# Germany
21#
22# Redistribution and use in source and binary forms, with or without
23# modification, are permitted provided that the following conditions are
24# met:
25#
26# 1. Redistributions of source code must retain the above copyright
27# notice, this list of conditions and the following disclaimer.
28# 2. Redistributions in binary form must reproduce the above copyright
29# notice, this list of conditions and the following disclaimer in the
30# documentation and/or other materials provided with the distribution.
31#
32# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
33# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
36# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43#
44# The views and conclusions contained in the software and documentation
45# are those of the authors and should not be interpreted as representing
46# official policies, either expressed or implied, of the Institute of
47# Telematics.
48# [License]
49
50find_package(PkgConfig)
51pkg_check_modules(PC_DBUS QUIET dbus-1)
52
53# Build static binaries?
54if(BUILD_STATIC_BINS)
55 set(STATIC_ "STATIC_")
56endif(BUILD_STATIC_BINS)
57
58set(DBUS_DEFINITIONS ${PC_DBUS_${STATIC_}CFLAGS_OTHER})
59
60
61# Look for the header files.
62find_path(DBUS_INCLUDE_DIR NAMES dbus/dbus.h
63 HINTS
64 ${PC_DBUS_${STATIC_}INCLUDEDIR}
65 ${PC_DBUS_${STATIC_}INCLUDE_DIRS})
66mark_as_advanced(DBUS_INCLUDE_DIR)
67set(handle_standard_args_variables DBUS_INCLUDE_DIR)
68
69
70# Look for the libraries
71if(NOT PC_DBUS_${STATIC_}LIBRARIES)
72 set(PC_DBUS_${STATIC_}LIBRARIES dbus-1)
73endif()
74
75foreach(LIBRARY ${PC_DBUS_${STATIC_}LIBRARIES})
76 find_library(DBUS_${STATIC_}LIBRARY_${LIBRARY} NAMES ${LIBRARY}
77 DOC "The path to the ${LIBRARY} library used by D-Bus"
78 HINTS
79 ${PC_DBUS_${STATIC_}LIBDIR}
80 ${PC_DBUS_LIBRARY_${STATIC_}DIRS}
81 )
82 mark_as_advanced(DBUS_${STATIC_}LIBRARY_${LIBRARY})
83 list(APPEND handle_standard_args_variables
84 "DBUS_${STATIC_}LIBRARY_${LIBRARY}"
85 )
86endforeach()
87
88
89# handle the QUIETLY and REQUIRED arguments and set DBUS_FOUND to TRUE
90# if all listed variables are TRUE
91find_package(PackageHandleStandardArgs)
92find_package_handle_standard_args(DBus DEFAULT_MSG
93 ${handle_standard_args_variables}
94 )
95
96if(DBUS_FOUND)
97 foreach(LIBRARY ${PC_DBUS_${STATIC_}LIBRARIES})
98 list(APPEND DBUS_LIBRARIES
99 ${DBUS_${STATIC_}LIBRARY_${LIBRARY}}
100 )
101 endforeach()
102endif()
Note: See TracBrowser for help on using the repository browser.