Commit 91d8df12 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use more target-centric cmake code

Also...
... bump min KF version to 5.80 (implies min Qt 5.14), needed for
    target-argument variant of ecm_qt_declare_logging_category()
    as well as min CMake version to 3.11, needed for add_library()
    without sources
... set TRANSLATION_DOMAIN also for ksanetwain
parent a5f8ae77
cmake_minimum_required(VERSION 3.5.0)
cmake_minimum_required(VERSION 3.11.0)
# KDE Applications version, managed by release script.
set(RELEASE_SERVICE_VERSION_MAJOR "21")
......@@ -13,7 +13,7 @@ message(STATUS "Starting CMake configuration for: libksane")
# ECM setup (Extended Cmake Modules)
include(FeatureSummary)
set(KF5_VERSION "5.55.0")
set(KF5_VERSION "5.80.0")
find_package(ECM ${KF5_VERSION} REQUIRED NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
# ECM setup2 and include find same cmake module (copied from /usr/share/kde4/apps/cmake/modules/FindSane.cmake)
......@@ -41,7 +41,7 @@ ecm_setup_version(
)
# Dependencies
set(REQUIRED_QT_VERSION "5.10.0")
set(REQUIRED_QT_VERSION "5.14.0")
# Required Qt5 components to build this framework
find_package(Qt5 ${REQUIRED_QT_VERSION} NO_MODULE REQUIRED Core Widgets)
......
......@@ -18,3 +18,11 @@ INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sane DEFAULT_MSG SANE_LIBRARY SANE_INCLUDE_DIR )
MARK_AS_ADVANCED(SANE_INCLUDE_DIR SANE_LIBRARY)
if(Sane_FOUND AND NOT TARGET Sane::Sane)
add_library(Sane::Sane UNKNOWN IMPORTED)
set_target_properties(Sane::Sane PROPERTIES
IMPORTED_LOCATION "${SANE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SANE_INCLUDE_DIR}"
)
endif()
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_BINARY_DIR}
)
add_library(KF5Sane)
add_library(KF5::Sane ALIAS KF5Sane)
target_compile_definitions(KF5Sane PRIVATE -DTRANSLATION_DOMAIN=\"libksane\")
IF( WIN32 )
ADD_DEFINITIONS( -DMAKE_KSANE_LIB )
target_compile_definitions(KF5Sane PRIVATE -DMAKE_KSANE_LIB )
ENDIF( WIN32 )
set(ktwain_src
target_sources(KF5Sane PRIVATE
twainiface.cpp
ktwain_widget.cpp
../src/ksanewidget.h
......@@ -15,11 +15,14 @@ set(ktwain_src
ksaneoption.cpp
)
add_library(KF5Sane ${ktwain_src})
generate_export_header(KF5Sane BASE_NAME KSane)
add_library(KF5::Sane ALIAS KF5Sane)
target_include_directories(KF5Sane INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KSane>")
target_include_directories(KF5Sane
INTERFACE
"$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KSane>"
PRIVATE
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(KF5Sane
PUBLIC
......
add_definitions(-DTRANSLATION_DOMAIN=\"libksane\")
add_library(KF5Sane)
add_library(KF5::Sane ALIAS KF5Sane)
target_compile_definitions(KF5Sane PRIVATE -DTRANSLATION_DOMAIN=\"libksane\")
if (KF5Wallet_FOUND)
add_definitions(-DHAVE_KF5WALLET)
set(WALLET_LIB KF5::Wallet)
target_compile_definitions(KF5Sane PRIVATE -DHAVE_KF5WALLET)
target_link_libraries(KF5Sane PRIVATE KF5::Wallet)
endif()
include_directories(${SANE_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/options
${CMAKE_CURRENT_SOURCE_DIR}/widgets
)
set(ksane_SRCS
target_sources(KF5Sane PRIVATE
widgets/gammadisp.cpp
widgets/labeledgamma.cpp
widgets/labeledcheckbox.cpp
......@@ -46,28 +44,31 @@ set(ksane_SRCS
options/ksanepagesizeoption.cpp
)
ecm_qt_declare_logging_category(ksane_SRCS
ecm_qt_declare_logging_category(KF5Sane
HEADER ksane_debug.h
IDENTIFIER KSANE_LOG
CATEGORY_NAME org.kde.ksane
)
add_library(KF5Sane ${ksane_SRCS})
generate_export_header(KF5Sane BASE_NAME KSane)
add_library(KF5::Sane ALIAS KF5Sane)
target_include_directories(KF5Sane INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KSane>")
target_include_directories(KF5Sane
INTERFACE
"$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KSane>"
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/options
${CMAKE_CURRENT_SOURCE_DIR}/widgets
)
target_link_libraries(KF5Sane
PUBLIC
Qt5::Widgets
PRIVATE
${SANE_LIBRARY}
Sane::Sane
KF5::I18n
KF5::WidgetsAddons
KF5::TextWidgets
${WALLET_LIB}
)
set_target_properties(KF5Sane
......@@ -87,12 +88,10 @@ ecm_generate_headers(KSane_HEADERS
# Install files
set(ksane_ICONS
ecm_install_icons(ICONS
16-actions-black-white.png
16-actions-color.png
16-actions-gray-scale.png
)
ecm_install_icons(ICONS ${ksane_ICONS}
DESTINATION ${KDE_INSTALL_ICONDIR})
install(TARGETS KF5Sane
......
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