mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-23 08:20:09 +01:00
With this support cmake and autotools generates cmake equivalent of pkgconfig files on configure time named DBus1Config*.cmake. These files are installed into the related directory where cmake expects find_package related config files. For instructions how to use this feature with clients see readme.cmake. With previous DBus versions each cmake client using DBus as dependency needed a related FindDBus*.cmake in its source distribution or in the cmake binary packages. With the 'config' find package style support provided by this patch this requirement has been removed. The generated config file uses pkgconfig on unix or autotools to fetch package build flags, which is the prefered way. On Windows we do not want to require CMake users to have pkg-config installed so it uses cmake buildin target export support for exporting all targets into DBus1ConfigTargets*.cmake. [smcv: make sure variable substitution works in Autotools too] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99721 Reviewed-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Signed-off-by: Simon McVittie <smcv@collabora.com>
48 lines
2 KiB
Text
48 lines
2 KiB
Text
# - Config file for the DBus1 package
|
|
# It defines the following variables
|
|
# DBus1_FOUND - Flag for indicating that DBus1 package has been found
|
|
# DBus1_DEFINITIONS - compile definitions for DBus1 [1]
|
|
# DBus1_INCLUDE_DIRS - include directories for DBus1 [1]
|
|
# DBus1_LIBRARIES - cmake targets to link against
|
|
|
|
# [1] This variable is not required if DBus1_LIBRARIES is added
|
|
# to a target with target_link_libraries
|
|
|
|
get_filename_component(DBus1_PKGCONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/../../pkgconfig" ABSOLUTE)
|
|
find_package(PkgConfig)
|
|
set(ENV{PKG_CONFIG_DIR})
|
|
set(ENV{PKG_CONFIG_PATH} ${DBus1_PKGCONFIG_DIR})
|
|
set(ENV{PKG_CONFIG_LIBDIR} ${DBus1_PKGCONFIG_DIR})
|
|
# for debugging
|
|
#set(ENV{PKG_CONFIG_DEBUG_SPEW} 1)
|
|
pkg_check_modules(PC_DBUS1 QUIET dbus-1)
|
|
set(DBus1_DEFINITIONS ${PC_DBUS1_CFLAGS_OTHER})
|
|
|
|
# find the real stuff and use pkgconfig variables as hints
|
|
# because cmake provides more search options
|
|
find_path(DBus1_INCLUDE_DIR dbus/dbus.h
|
|
HINTS ${PC_DBUS1_INCLUDEDIR} ${PC_DBUS1_INCLUDE_DIRS}
|
|
PATH_SUFFIXES dbus-1.0)
|
|
find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h
|
|
HINTS ${PC_DBUS1_INCLUDE_DIRS}
|
|
PATH_SUFFIXES dbus-1.0)
|
|
find_library(DBus1_LIBRARY NAMES ${PC_DBUS1_LIBRARIES}
|
|
HINTS ${PC_DBUS1_LIBDIR} ${PC_DBUS1_LIBRARY_DIRS})
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
# handle the QUIETLY and REQUIRED arguments and set DBus1_FOUND to TRUE
|
|
# if all listed variables are TRUE
|
|
find_package_handle_standard_args(DBus1 DEFAULT_MSG
|
|
DBus1_LIBRARY DBus1_INCLUDE_DIR DBus1_ARCH_INCLUDE_DIR)
|
|
|
|
# make the mentioned variables only visible in cmake gui with "advanced" enabled
|
|
mark_as_advanced(DBus1_INCLUDE_DIR DBus1_LIBRARY)
|
|
|
|
set(DBus1_LIBRARIES dbus-1)
|
|
set(DBus1_INCLUDE_DIRS "${DBus1_INCLUDE_DIR}" "${DBus1_ARCH_INCLUDE_DIR}")
|
|
|
|
# setup imported target
|
|
add_library(dbus-1 SHARED IMPORTED)
|
|
set_property(TARGET dbus-1 APPEND PROPERTY IMPORTED_LOCATION ${DBus1_LIBRARY})
|
|
set_property(TARGET dbus-1 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${DBus1_INCLUDE_DIRS})
|
|
set_property(TARGET dbus-1 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ${DBus1_DEFINITIONS})
|