diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 64b5d7d57..886dbaff5 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -125,11 +125,11 @@ ecm_add_test(signatureformtest.cpp LINK_LIBRARIES Qt5::Test okularcore ) -find_package(Discount "2") +find_package(Discount) -if(discount_FOUND) +if(Discount_FOUND) ecm_add_test(markdowntest.cpp ../generators/markdown/converter.cpp TEST_NAME "markdowntest" - LINK_LIBRARIES Qt5::Test okularcore KF5::I18n discount::Lib + LINK_LIBRARIES Qt5::Test okularcore KF5::I18n PkgConfig::Discount ) endif() diff --git a/cmake/modules/FindDiscount.cmake b/cmake/modules/FindDiscount.cmake index 583fb0598..8e1b1375a 100644 --- a/cmake/modules/FindDiscount.cmake +++ b/cmake/modules/FindDiscount.cmake @@ -2,9 +2,8 @@ # Find the discount markdown library. # # This module defines -# discount_FOUND - whether the discount library was found -# discount_LIBRARIES - the discount library -# discount_INCLUDE_DIR - the include path of the discount library +# Discount_FOUND - whether the discount library was found +# PkgConfig::Discount - the discount target to link to # Copyright (c) 2017, Julian Wolff, # Copyright (c) 2018, Sune Vuorela, @@ -12,30 +11,10 @@ # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. +include(FindPackageHandleStandardArgs) -if (discount_INCLUDE_DIR AND discount_LIBRARIES) +find_package(PkgConfig REQUIRED) - # Already in cache - set (discount_FOUND TRUE) +pkg_check_modules(Discount IMPORTED_TARGET "libmarkdown") -else (discount_INCLUDE_DIR AND discount_LIBRARIES) - - find_library (discount_LIBRARIES - NAMES markdown libmarkdown - ) - - find_path (discount_INCLUDE_DIR - NAMES mkdio.h - ) - - include (FindPackageHandleStandardArgs) - find_package_handle_standard_args (discount DEFAULT_MSG discount_LIBRARIES discount_INCLUDE_DIR) - -endif (discount_INCLUDE_DIR AND discount_LIBRARIES) - -mark_as_advanced(discount_INCLUDE_DIR discount_LIBRARIES) - -if (discount_FOUND) - add_library(discount::Lib UNKNOWN IMPORTED) - set_target_properties(discount::Lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${discount_INCLUDE_DIR} IMPORTED_LOCATION ${discount_LIBRARIES}) -endif() +find_package_handle_standard_args(Discount DEFAULT_MSG Discount_LIBRARIES) diff --git a/generators/CMakeLists.txt b/generators/CMakeLists.txt index 0667b85b5..0354f375f 100644 --- a/generators/CMakeLists.txt +++ b/generators/CMakeLists.txt @@ -92,8 +92,8 @@ set_package_properties("libqmobipocket" PROPERTIES TYPE RECOMMENDED PURPOSE "Support for Mobipocket documents in Okular.") -find_package(Discount "2") -set_package_properties("discount" PROPERTIES +find_package(Discount) +set_package_properties("Discount" PROPERTIES DESCRIPTION "A library that gives you formatting functions suitable for marking down entire documents or lines of text" URL "https://www.pell.portland.or.us/~orc/Code/discount/" TYPE RECOMMENDED @@ -149,6 +149,6 @@ if(QMobipocket_FOUND) add_subdirectory(mobipocket) endif() -if(discount_FOUND) +if(Discount_FOUND) add_subdirectory(markdown) endif() diff --git a/generators/markdown/CMakeLists.txt b/generators/markdown/CMakeLists.txt index 6e8b0f1a4..0d1c3036c 100644 --- a/generators/markdown/CMakeLists.txt +++ b/generators/markdown/CMakeLists.txt @@ -16,7 +16,7 @@ set(okularGenerator_md_PART_SRCS okular_add_generator(okularGenerator_md ${okularGenerator_md_PART_SRCS}) -target_link_libraries(okularGenerator_md PRIVATE okularcore KF5::I18n KF5::KIOCore discount::Lib) +target_link_libraries(okularGenerator_md PRIVATE okularcore KF5::I18n KF5::KIOCore PkgConfig::Discount) ########### install files ############### install( FILES okularMd.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )