kdelibs/cmake/modules/FindUDisks2.cmake
Ivailo Monev 3eb17fdf2b cmake: review modules rewritten so far by me
using pkg-config search as primary method with fallback to path lookup,
this may result in overlinking however if libraries require additional
include paths (as is the case with PulseAudio) with this change that will
not be a problem.

it will also reduce the lookups done during configuration/build since path
lookups will not be done, unless pkg-config lookup does not set the
required variables.

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
2020-02-10 20:52:45 +00:00

44 lines
1.2 KiB
CMake

# - Try to find UDisks2
#
# Once done this will define
#
# UDISKS2_FOUND - system has UDisks2
# UDISKS2_INCLUDE_DIR - the UDisks2 include directory
# UDISKS2_LIBRARIES - The libraries needed to use UDisks2
#
# Copyright (c) 2014-2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(UDISKS2_INCLUDE_DIR AND UDISKS2_LIBRARIES)
set(UDISKS2_FIND_QUIETLY TRUE)
endif()
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_UDISKS2 QUIET udisks2)
set(UDISKS2_INCLUDE_DIR ${PC_UDISKS2_INCLUDE_DIRS})
set(UDISKS2_LIBRARIES ${PC_UDISKS2_LIBRARIES})
endif()
if(NOT UDISKS2_INCLUDE_DIR OR NOT UDISKS2_LIBRARIES)
find_path(UDISKS2_INCLUDE_DIR
NAMES udisks2/udisks/udisks.h
HINTS $ENV{UDISKS2DIR}/include
)
find_library(UDISKS2_LIBRARIES
NAMES udisks2
HINTS $ENV{UDISKS2DIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UDisks2
VERSION_VAR PC_UDISKS2_VERSION
REQUIRED_VARS UDISKS2_LIBRARIES UDISKS2_INCLUDE_DIR
)
mark_as_advanced(UDISKS2_INCLUDE_DIR UDISKS2_LIBRARIES)