qt5base-lts/cmake/FindGSSAPI.cmake
Johannes Kauffmann 029e118a4e CMake: Unify usage of pkg_check_modules
According to the CMake documentation, IMPORTED_TARGET should be
specified before the moduleSpec, and after QUIET.

Additionally, double-quote the moduleSpec everywhere, since before, it
was only quoted in some cases.

While this is not required for pkg_check_modules to work, it unifies the
coding style.

Pick-to: 6.5
Change-Id: Ic8ad708a8146f9b39ee40e9a719412441e231452
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-01-06 17:57:17 +01:00

48 lines
1.5 KiB
CMake

# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(PC_GSSAPI QUIET "krb5-gssapi")
if (NOT PC_GSSAPI_FOUND)
pkg_check_modules(PC_GSSAPI QUIET "mit-krb5-gssapi")
endif()
find_path(GSSAPI_INCLUDE_DIRS
NAMES gssapi/gssapi.h
HINTS ${PC_GSSAPI_INCLUDEDIR}
)
find_library(GSSAPI_LIBRARIES
NAMES
GSS # framework
gss # solaris
gssapi # FreeBSD
gssapi_krb5
HINTS ${PC_GSSAPI_LIBDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIRS)
if(GSSAPI_FOUND AND NOT TARGET GSSAPI::GSSAPI)
if(GSSAPI_LIBRARIES MATCHES "/([^/]+)\\.framework$")
add_library(GSSAPI::GSSAPI INTERFACE IMPORTED)
set_target_properties(GSSAPI::GSSAPI PROPERTIES
INTERFACE_LINK_LIBRARIES "${GSSAPI_LIBRARIES}")
else()
add_library(GSSAPI::GSSAPI UNKNOWN IMPORTED)
set_target_properties(GSSAPI::GSSAPI PROPERTIES
IMPORTED_LOCATION "${GSSAPI_LIBRARIES}")
endif()
set_target_properties(GSSAPI::GSSAPI PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GSSAPI_INCLUDE_DIRS}")
endif()
mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
include(FeatureSummary)
set_package_properties(GSSAPI PROPERTIES
DESCRIPTION "Generic Security Services Application Program Interface")