Commit 29e58f89 authored by Nicolas Fella's avatar Nicolas Fella

Make use of PkgConfig to find dependencies

It provides imported targets which makes everything much nicer
parent 30694cba
......@@ -44,17 +44,18 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
I18n
Plasma
)
find_package(PulseAudio 5.0.0 REQUIRED)
find_package(Canberra REQUIRED)
find_package(GLIB2 REQUIRED)
option(USE_GCONF "Use legacy GConf instead of GSettings")
pkg_check_modules(GOBJECT gobject-2.0 REQUIRED)
pkg_check_modules(LIBPULSE libpulse REQUIRED IMPORTED_TARGET)
pkg_check_modules(LIBPULSE_MAINLOOP libpulse-mainloop-glib REQUIRED IMPORTED_TARGET)
if(USE_GCONF)
pkg_check_modules(GCONF gconf-2.0 REQUIRED)
pkg_check_modules(GCONF gconf-2.0 REQUIRED IMPORTED_TARGET)
pkg_check_modules(GOBJECT gobject-2.0 REQUIRED IMPORTED_TARGET)
else()
find_package(GIO REQUIRED)
pkg_check_modules(GIO gio-2.0 REQUIRED IMPORTED_TARGET)
set(USE_GSETTINGS True)
endif()
......
# - Try to find the GIO libraries
# Once done this will define
#
# GIO_FOUND - system has GIO
# GIO_INCLUDE_DIR - the GIO include directory
# GIO_LIBRARIES - GIO library
#
# Copyright (c) 2010 Dario Freddi <drf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(GIO_INCLUDE_DIR AND GIO_LIBRARIES)
# Already in cache, be silent
set(GIO_FIND_QUIETLY TRUE)
endif(GIO_INCLUDE_DIR AND GIO_LIBRARIES)
if (NOT WIN32)
include(UsePkgConfig)
pkgconfig(gio-2.0 _LibGIOIncDir _LibGIOLinkDir _LibGIOLinkFlags _LibGIOCflags)
endif(NOT WIN32)
MESSAGE(STATUS "gio include dir: ${_LibGIOIncDir}")
# first try without default paths to respect PKG_CONFIG_PATH
find_path(GIO_MAIN_INCLUDE_DIR glib.h
PATH_SUFFIXES glib-2.0
PATHS ${_LibGIOIncDir}
NO_DEFAULT_PATH)
find_path(GIO_MAIN_INCLUDE_DIR glib.h
PATH_SUFFIXES glib-2.0
PATHS ${_LibGIOIncDir} )
MESSAGE(STATUS "found gio main include dir: ${GIO_MAIN_INCLUDE_DIR}")
# search the glibconfig.h include dir under the same root where the library is found
find_library(GIO_LIBRARIES
NAMES gio-2.0
PATHS ${_LibGIOLinkDir}
NO_DEFAULT_PATH)
find_library(GIO_LIBRARIES
NAMES gio-2.0
PATHS ${_LibGIOLinkDir})
get_filename_component(GIOLibDir "${GIO_LIBRARIES}" PATH)
find_path(GIO_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include
PATHS ${_LibGIOIncDir} "${GIOLibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}
NO_DEFAULT_PATH)
find_path(GIO_INTERNAL_INCLUDE_DIR glibconfig.h
PATH_SUFFIXES glib-2.0/include
PATHS ${_LibGIOIncDir} "${GIOLibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
set(GIO_INCLUDE_DIR "${GIO_MAIN_INCLUDE_DIR}")
# not sure if this include dir is optional or required
# for now it is optional
if(GIO_INTERNAL_INCLUDE_DIR)
set(GIO_INCLUDE_DIR ${GIO_INCLUDE_DIR} "${GIO_INTERNAL_INCLUDE_DIR}")
endif(GIO_INTERNAL_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GIO DEFAULT_MSG GIO_LIBRARIES GIO_MAIN_INCLUDE_DIR)
mark_as_advanced(GIO_INCLUDE_DIR GIO_LIBRARIES)
add_definitions(-DTRANSLATION_DOMAIN=\"kcm_pulseaudio\")
include_directories(${PULSEAUDIO_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR})
set(cpp_SRCS
card.cpp
client.cpp
......@@ -41,12 +39,10 @@ set_property(SOURCE qml/dbus/osdService.xml APPEND PROPERTY CLASSNAME OsdService
qt5_add_dbus_interface(dbus_SRCS qml/dbus/osdService.xml osdservice)
if (USE_GCONF)
include_directories(${GCONF_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS})
set(cpp_SRCS ${cpp_SRCS} gconfitem.cpp)
endif()
if (USE_GSETTINGS)
include_directories(${GIO_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS})
set(cpp_SRCS ${cpp_SRCS} gsettingsitem.cpp)
endif()
......@@ -60,22 +56,16 @@ target_link_libraries(plasma-volume-declarative
KF5::I18n
KF5::Notifications
Canberra::Canberra
${PULSEAUDIO_LIBRARY}
${PULSEAUDIO_MAINLOOP_LIBRARY}
${GOBJECT_LDFLAGS}
PkgConfig::LIBPULSE
PkgConfig::LIBPULSE_MAINLOOP
)
if (USE_GCONF)
target_link_libraries(plasma-volume-declarative
${GCONF_LDFLAGS}
)
target_link_libraries(plasma-volume-declarative PkgConfig::GCONF PkgConfig::GOBJECT)
endif()
if (USE_GSETTINGS)
target_link_libraries(plasma-volume-declarative
${GIO_LIBRARIES}
GLIB2::GLIB2
)
target_link_libraries(plasma-volume-declarative PkgConfig::GIO)
endif()
set(PRIVATE_QML_INSTALL_DIR ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/volume)
......
add_library(kcm_pulseaudio MODULE module.cpp)
target_include_directories(kcm_pulseaudio PRIVATE ${CMAKE_BINARY_DIR})
target_include_directories(kcm_pulseaudio PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
target_link_libraries(kcm_pulseaudio
Qt5::Quick
......@@ -9,8 +8,6 @@ target_link_libraries(kcm_pulseaudio
KF5::Declarative
KF5::I18n
KF5::QuickAddons
${PULSEAUDIO_LIBRARY}
${PULSEAUDIO_MAINLOOP_LIBRARY}
)
kcoreaddons_desktop_to_json(kcm_pulseaudio "package/metadata.desktop")
......
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