From 2940dd75d550270d369bdf41418268d5956060b8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 8 May 2018 09:37:32 +0200 Subject: Make use of interface include directories and link libraries. Instead of manually specifying the libraries to link against and the include directories to include we'd much rather have a single target to link against. find_package already defines the Gpgme target for some reason, which seems like a waste, but with the lowercase gpgme target we can work around that problem. --- cmake/modules/FindGpgme.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'cmake') diff --git a/cmake/modules/FindGpgme.cmake b/cmake/modules/FindGpgme.cmake index ea4a750d..cb1b19b7 100644 --- a/cmake/modules/FindGpgme.cmake +++ b/cmake/modules/FindGpgme.cmake @@ -1,5 +1,18 @@ find_path(GPGME_INCLUDE_DIR NAMES gpgme.h) -find_library(GPGME_LIBRARIES NAMES gpgme) +find_path(GPGERROR_INCLUDE_DIR NAMES gpg-error.h) +find_library(GPGME_LIBRARY NAMES gpgme) +find_library(GPGERROR_LIBRARY NAMES gpg-error) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GPGME DEFAULT_MSG GPGME_INCLUDE_DIR GPGME_LIBRARIES) +find_package_handle_standard_args(GPGME DEFAULT_MSG GPGME_INCLUDE_DIR GPGERROR_INCLUDE_DIR GPGME_LIBRARY GPGERROR_LIBRARY) + +mark_as_advanced(GPGME_INCLUDE_DIR GPGME_LIBRARY GPGME_INCLUDE_DIR GPGME_LIBRARY) + +set(GPGME_LIBRARIES ${GPGME_LIBRARY} ${GPGERROR_LIBRARY}) +set(GPGME_INCLUDE_DIRS ${GPGME_INCLUDE_DIR} ${GPGERROR_INCLUDE_DIR}) + +if (NOT ${gpgme}) + add_library(gpgme INTERFACE) + target_link_libraries(gpgme INTERFACE ${GPGME_LIBRARIES}) + target_include_directories(gpgme INTERFACE ${GPGME_INCLUDE_DIRS}) +endif() -- cgit v1.2.3