Commit 4af2f689 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use more target-centric cmake code

Also move cmake config generation into src/ folder

GIT_SILENT
parent 06ad4c39
Pipeline #93793 skipped
......@@ -5,8 +5,8 @@
#
set(CMAKE_MIN_VERSION "3.5.0")
set(ECM_MIN_VERSION "5.68.0")
set(QT_MIN_VERSION "5.12.0")
set(ECM_MIN_VERSION "5.80.0")
set(QT_MIN_VERSION "5.15.0")
set(LIBRAW_MIN_VERSION "0.18")
cmake_minimum_required(VERSION ${CMAKE_MIN_VERSION})
......@@ -63,7 +63,6 @@ include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMGenerateHeaders)
include(ECMSetupVersion)
include(ECMMarkNonGuiExecutable)
include(CMakePackageConfigHelpers)
include(ECMQtDeclareLoggingCategory)
include(GenerateExportHeader)
......@@ -85,17 +84,10 @@ set_package_properties("LibRaw" PROPERTIES
PURPOSE "Library to decode RAW image"
)
ecm_setup_version(${LIBKDCRAW_LIB_VERSION}
VARIABLE_PREFIX KDCRAW
VERSION_HEADER "src/libkdcraw_version.h"
PACKAGE_VERSION_FILE "KF5KDcrawConfigVersion.cmake"
SOVERSION ${LIBKDCRAW_SO_VERSION}
)
############## Targets #########################
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050B00
-DQT_DISABLE_DEPRECATED_BEFORE=0x050F00
-DQT_DEPRECATED_WARNINGS_SINCE=0x060000
-DQT_NO_KEYWORDS
-DQT_NO_FOREACH
......@@ -113,28 +105,4 @@ if (BUILD_TESTING)
add_subdirectory(tests)
endif()
############## CMake Config Files ##############
message("${CMAKECONFIG_INSTALL_DIR}")
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5KDcraw")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/KF5KDcrawConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/KF5KDcrawConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/KF5KDcrawConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KF5KDcrawConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
install(EXPORT KF5KDcrawTargets
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
FILE KF5KDcrawTargets.cmake
NAMESPACE KF5::
)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
......@@ -76,3 +76,12 @@ MARK_AS_ADVANCED(LibRaw_VERSION
LibRaw_DEFINITIONS
LibRaw_r_DEFINITIONS
)
if(LibRaw_FOUND AND NOT TARGET LibRaw::LibRaw)
add_library(LibRaw::LibRaw UNKNOWN IMPORTED)
set_target_properties(LibRaw::LibRaw PROPERTIES
IMPORTED_LOCATION "${LibRaw_LIBRARIES}"
INTERFACE_COMPILE_OPTIONS "${LibRaw_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${LibRaw_INCLUDE_DIR}"
)
endif()
......@@ -4,21 +4,28 @@
# SPDX-License-Identifier: BSD-3-Clause
#
kde_enable_exceptions()
set(KDCRAW_INSTALL_INCLUDEDIR "${KDE_INSTALL_INCLUDEDIR_KF5}/KDCRAW")
set(KDCRAW_CMAKECONFIG_NAME "KF5KDcraw")
ecm_setup_version(${LIBKDCRAW_LIB_VERSION}
VARIABLE_PREFIX KDCRAW
VERSION_HEADER "libkdcraw_version.h"
PACKAGE_VERSION_FILE "${KDCRAW_CMAKECONFIG_NAME}ConfigVersion.cmake"
SOVERSION ${LIBKDCRAW_SO_VERSION}
)
include_directories(SYSTEM ${LibRaw_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
kde_enable_exceptions()
add_definitions(${LibRaw_DEFINITIONS})
add_library(KDcraw SHARED)
set(kdcraw_LIB_SRCS
target_sources(KDcraw PRIVATE
kdcraw.cpp
kdcraw_p.cpp
dcrawinfocontainer.cpp
rawdecodingsettings.cpp
)
ecm_qt_declare_logging_category(kdcraw_LIB_SRCS
ecm_qt_declare_logging_category(KDcraw
HEADER libkdcraw_debug.h
IDENTIFIER LIBKDCRAW_LOG
CATEGORY_NAME "libkdcraw"
......@@ -36,49 +43,43 @@ ecm_generate_headers(kdcraw_CamelCase_HEADERS
REQUIRED_HEADERS kdcraw_HEADERS
)
add_library(KF5KDcraw SHARED ${kdcraw_LIB_SRCS})
add_library(KF5::KDcraw ALIAS KF5KDcraw)
generate_export_header(KF5KDcraw
generate_export_header(KDcraw
BASE_NAME libkdcraw
)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE OFF)
target_include_directories(KF5KDcraw
target_include_directories(KDcraw
INTERFACE
"$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KDCRAW;${KDE_INSTALL_INCLUDEDIR_KF5}/KDCRAW/kdcraw>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${KDCRAW_INSTALL_INCLUDEDIR};${KDCRAW_INSTALL_INCLUDEDIR}/kdcraw>"
)
target_link_libraries(KF5KDcraw
target_link_libraries(KDcraw
PUBLIC
Qt5::Core
Qt5::Gui
PRIVATE
${LibRaw_LIBRARIES}
LibRaw::LibRaw
)
set_target_properties(KF5KDcraw PROPERTIES
set_target_properties(KDcraw PROPERTIES
OUTPUT_NAME KF5KDcraw
VERSION ${KDCRAW_VERSION}
SOVERSION ${KDCRAW_SOVERSION}
EXPORT_NAME KDcraw
)
install(TARGETS KF5KDcraw
EXPORT KF5KDcrawTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}
install(TARGETS KDcraw
EXPORT KDcrawTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}
)
install(FILES
${kdcraw_CamelCase_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KDCRAW/KDCRAW
DESTINATION ${KDCRAW_INSTALL_INCLUDEDIR}/KDCRAW
COMPONENT Devel
)
install(FILES
${kdcraw_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/libkdcraw_export.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KDCRAW/kdcraw
DESTINATION ${KDCRAW_INSTALL_INCLUDEDIR}/kdcraw
COMPONENT Devel
)
......@@ -93,3 +94,27 @@ ecm_qt_install_logging_categories(
FILE libkdcraw.categories
DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}"
)
############## CMake Config Files ##############
message("${CMAKECONFIG_INSTALL_DIR}")
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/${KDCRAW_CMAKECONFIG_NAME}")
configure_package_config_file(
"${CMAKE_SOURCE_DIR}/cmake/templates/${KDCRAW_CMAKECONFIG_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${KDCRAW_CMAKECONFIG_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${KDCRAW_CMAKECONFIG_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${KDCRAW_CMAKECONFIG_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
install(EXPORT KDcrawTargets
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
FILE ${KDCRAW_CMAKECONFIG_NAME}Targets.cmake
NAMESPACE KF5::
)
......@@ -4,10 +4,10 @@
# SPDX-License-Identifier: BSD-3-Clause
#
set(raw2png_SRCS raw2png.cpp)
add_executable(raw2png ${raw2png_SRCS})
target_link_libraries(raw2png KF5KDcraw)
add_executable(raw2png)
target_sources(raw2png PRIVATE raw2png.cpp)
target_link_libraries(raw2png KDcraw)
set(libinfo_SRCS libinfo.cpp)
add_executable(libinfo ${libinfo_SRCS})
target_link_libraries(libinfo KF5KDcraw)
add_executable(libinfo)
target_sources(libinfo PRIVATE libinfo.cpp)
target_link_libraries(libinfo KDcraw)
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