diff --git a/attic/modules/FindExiv2.cmake b/attic/modules/FindExiv2.cmake deleted file mode 100644 --- a/attic/modules/FindExiv2.cmake +++ /dev/null @@ -1,80 +0,0 @@ -# - Try to find the Exiv2 library -# -# EXIV2_MIN_VERSION - You can set this variable to the minimum version you need -# before doing FIND_PACKAGE(Exiv2). The default is 0.12. -# -# Once done this will define -# -# EXIV2_FOUND - system has libexiv2 -# EXIV2_INCLUDE_DIR - the libexiv2 include directory -# EXIV2_LIBRARIES - Link these to use libexiv2 -# EXIV2_DEFINITIONS - Compiler switches required for using libexiv2 -# -# The minimum required version of Exiv2 can be specified using the -# standard syntax, e.g. find_package(Exiv2 0.17) -# -# For compatibility, also the variable EXIV2_MIN_VERSION can be set to the minimum version -# you need before doing FIND_PACKAGE(Exiv2). The default is 0.12. - -# Copyright (c) 2010, Alexander Neundorf, -# Copyright (c) 2008, Gilles Caulier, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -# Support EXIV2_MIN_VERSION for compatibility: -if(NOT Exiv2_FIND_VERSION) - set(Exiv2_FIND_VERSION "${EXIV2_MIN_VERSION}") -endif() - -# the minimum version of exiv2 we require -if(NOT Exiv2_FIND_VERSION) - set(Exiv2_FIND_VERSION "0.12") -endif() - - -if (NOT WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - find_package(PkgConfig) - pkg_check_modules(PC_EXIV2 QUIET exiv2) - set(EXIV2_DEFINITIONS ${PC_EXIV2_CFLAGS_OTHER}) -endif (NOT WIN32) - - -find_path(EXIV2_INCLUDE_DIR NAMES exiv2/exif.hpp - HINTS - ${PC_EXIV2_INCLUDEDIR} - ${PC_EXIV2_INCLUDE_DIRS} - ) - -find_library(EXIV2_LIBRARY NAMES exiv2 libexiv2 - HINTS - ${PC_EXIV2_LIBDIR} - ${PC_EXIV2_LIBRARY_DIRS} - ) - - -# Get the version number from exiv2/version.hpp and store it in the cache: -if(EXIV2_INCLUDE_DIR AND NOT EXIV2_VERSION) - file(READ ${EXIV2_INCLUDE_DIR}/exiv2/version.hpp EXIV2_VERSION_CONTENT) - string(REGEX MATCH "#define EXIV2_MAJOR_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}") - set(EXIV2_VERSION_MAJOR "${CMAKE_MATCH_1}") - - string(REGEX MATCH "#define EXIV2_MINOR_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}") - set(EXIV2_VERSION_MINOR "${CMAKE_MATCH_1}") - - string(REGEX MATCH "#define EXIV2_PATCH_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}") - set(EXIV2_VERSION_PATCH "${CMAKE_MATCH_1}") - - set(EXIV2_VERSION "${EXIV2_VERSION_MAJOR}.${EXIV2_VERSION_MINOR}.${EXIV2_VERSION_PATCH}" CACHE STRING "Version number of Exiv2" FORCE) -endif() - -set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}") - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Exiv2 REQUIRED_VARS EXIV2_LIBRARY EXIV2_INCLUDE_DIR - VERSION_VAR EXIV2_VERSION) - -mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARY) - diff --git a/cmake/FindQHelpGenerator.cmake b/cmake/FindQHelpGenerator.cmake new file mode 100644 --- /dev/null +++ b/cmake/FindQHelpGenerator.cmake @@ -0,0 +1,94 @@ +#.rst: +# FindQHelpGenerator +# ------------------ +# +# Try to find the Qt help generator. +# Based on FindQCollectionGenerator.cmake +# +# This will define the following variables: +# +# ``QHelpGenerator_FOUND`` +# True if (the requested version of) Sphinx is available +# ``QHelpGenerator_VERSION`` +# The version of the Qt help generator. Note that this not the +# same as the version of Qt it is provided by. +# ``QHelpGenerator_QT_VERSION`` +# The version of Qt that the Qt help generator is from. +# ``QHelpGenerator_EXECUTABLE`` +# The path to the Qt help generator executable. +# +# If ``QHelpGenerator_FOUND`` is TRUE, it will also define the following +# imported target: +# +# ``QHelpGenerator::Generator`` +# The Qt help generator. +# +# In general we recommend using the imported target, as it is easier to use. +# +# Since 5.53.0. + +#============================================================================= +# Copyright 2015 Alex Merry +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +find_program(QHelpGenerator_EXECUTABLE + NAMES + qhelpgenerator-qt5 + qhelpgenerator + DOC "Qt help generator" +) + +if (QHelpGenerator_EXECUTABLE) + if(NOT TARGET QHelpGenerator::Generator) + add_executable(QHelpGenerator::Generator IMPORTED) + set_target_properties(QHelpGenerator::Generator PROPERTIES + IMPORTED_LOCATION "${QHelpGenerator_EXECUTABLE}" + ) + endif() + + execute_process( + COMMAND "${QHelpGenerator_EXECUTABLE}" -v + OUTPUT_VARIABLE _QHelpGenerator_version_raw + ERROR_VARIABLE _QHelpGenerator_version_raw + ) + if (_QHelpGenerator_version_raw MATCHES "^Qt Help Generator version ([0-9]+(\\.[0-9]+)*) \\(Qt ([0-9]+(\\.[0-9]+)*)\\)") + set(QHelpGenerator_VERSION "${CMAKE_MATCH_1}") + set(QHelpGenerator_QT_VERSION "${CMAKE_MATCH_3}") + endif() + unset(_QHelpGenerator_version_raw) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QHelpGenerator + FOUND_VAR + QHelpGenerator_FOUND + REQUIRED_VARS + QHelpGenerator_EXECUTABLE + VERSION_VAR + QHelpGenerator_VERSION +) + +mark_as_advanced(QHelpGenerator_EXECUTABLE) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -27,6 +27,7 @@ #============================================================================= include(CMakeDependentOption) +include("${CMAKE_SOURCE_DIR}/modules/ECMQueryQmake.cmake") find_package(Sphinx 1.2 MODULE) set_package_properties( @@ -38,15 +39,39 @@ PURPOSE "Required to build documentation for Extra CMake Modules." ) -find_package(QCollectionGenerator MODULE) -set_package_properties( - QCollectionGenerator - PROPERTIES - URL "http://www.qt.io/" - DESCRIPTION "Qt help collection generator." - TYPE OPTIONAL - PURPOSE "Required to build Extra CMake Modules documentation in Qt Help format." -) +# QCollectionGenerator and QHelpGenerator were merged in Qt 5.12 +query_qmake(QT_VERSION QT_VERSION) + +if(QT_VERSION VERSION_LESS 5.12.0) + find_package(QCollectionGenerator MODULE) + set_package_properties( + QCollectionGenerator + PROPERTIES + URL "http://www.qt.io/" + DESCRIPTION "Qt help collection generator" + TYPE OPTIONAL + PURPOSE "Required to build Extra CMake Modules documentation in Qt Help format." + ) + if(QCollectionGenerator_FOUND) + set(_ecm_qtdoc_generator QCollectionGenerator::Generator) + endif() +else() + find_package(QHelpGenerator MODULE) + set_package_properties( + QHelpGenerator + PROPERTIES + URL "http://www.qt.io/" + DESCRIPTION "Qt help generator" + TYPE OPTIONAL + PURPOSE "Required to build Extra CMake Modules documentation in Qt Help format." + ) + if(QHelpGenerator_FOUND) + set(_ecm_qtdoc_generator QHelpGenerator::Generator) + endif() +endif() +if(DEFINED _ecm_qtdoc_generator) + set(QT_HELP_GENERATOR_FOUND TRUE) +endif() cmake_dependent_option( BUILD_HTML_DOCS "Build html help with Sphinx" ON @@ -62,7 +87,7 @@ cmake_dependent_option( BUILD_QTHELP_DOCS "Build Qt help with Sphinx" OFF - "Sphinx_FOUND;QCollectionGenerator_FOUND" OFF + "Sphinx_FOUND;QT_HELP_GENERATOR_FOUND" OFF ) add_feature_info(BUILD_QTHELP_DOCS BUILD_QTHELP_DOCS "Generate QtHelp documentation for installed modules.") @@ -78,7 +103,7 @@ list(APPEND doc_formats qthelp) set(qthelp_extra_commands COMMAND - QCollectionGenerator::Generator + "${_ecm_qtdoc_generator}" ${CMAKE_CURRENT_BINARY_DIR}/qthelp/ExtraCMakeModules.qhcp ) endif() diff --git a/docs/find-module/FindExiv2.rst b/docs/find-module/FindExiv2.rst new file mode 100644 --- /dev/null +++ b/docs/find-module/FindExiv2.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../find-modules/FindExiv2.cmake diff --git a/find-modules/FindExiv2.cmake b/find-modules/FindExiv2.cmake new file mode 100644 --- /dev/null +++ b/find-modules/FindExiv2.cmake @@ -0,0 +1,120 @@ +#.rst: +# FindExiv2 +# --------- +# +# Try to find the Exiv2 library. +# +# This will define the following variables: +# +# ``Exiv2_FOUND`` +# System has Exiv2. +# +# ``Exiv2_VERSION`` +# The version of Exiv2. +# +# ``Exiv2_INCLUDE_DIRS`` +# This should be passed to target_include_directories() if +# the target is not used for linking. +# +# ``Exiv2_LIBRARIES`` +# The Exiv2 library. +# This can be passed to target_link_libraries() instead of +# the ``Exiv2::Exiv2`` target +# +# If ``Exiv2_FOUND`` is TRUE, the following imported target +# will be available: +# +# ``Exiv2::Exiv2`` +# The Exiv2 library +# +# Since 5.53.0. +# TODO KF6: Rename to FindLibExiv2.cmake +# +#============================================================================= +# Copyright (c) 2018, Christophe Giboudeaux, +# Copyright (c) 2010, Alexander Neundorf, +# Copyright (c) 2008, Gilles Caulier, +# +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_EXIV2 QUIET exiv2) + +find_path(Exiv2_INCLUDE_DIRS NAMES exiv2/exif.hpp + HINTS ${PC_EXIV2_INCLUDEDIR} +) + +find_library(Exiv2_LIBRARIES NAMES exiv2 libexiv2 + HINTS ${PC_EXIV2_LIBRARY_DIRS} +) + +set(Exiv2_VERSION ${PC_EXIV2_VERSION}) + +if(NOT Exiv2_VERSION AND DEFINED Exiv2_INCLUDE_DIRS) + # With exiv >= 0.27, the version #defines are in exv_conf.h instead of version.hpp + foreach(_exiv2_version_file "version.hpp" "exv_conf.h") + if(EXISTS "${Exiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}") + file(READ "${Exiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}" _exiv_version_file_content) + string(REGEX MATCH "#define EXIV2_MAJOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MAJOR_VERSION_MATCH ${_exiv_version_file_content}) + string(REGEX MATCH "#define EXIV2_MINOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MINOR_VERSION_MATCH ${_exiv_version_file_content}) + string(REGEX MATCH "#define EXIV2_PATCH_VERSION[ ]+\\([0-9]+\\)" EXIV2_PATCH_VERSION_MATCH ${_exiv_version_file_content}) + if(EXIV2_MAJOR_VERSION_MATCH) + string(REGEX REPLACE ".*_MAJOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MAJOR_VERSION ${EXIV2_MAJOR_VERSION_MATCH}) + string(REGEX REPLACE ".*_MINOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MINOR_VERSION ${EXIV2_MINOR_VERSION_MATCH}) + string(REGEX REPLACE ".*_PATCH_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_PATCH_VERSION ${EXIV2_PATCH_VERSION_MATCH}) + endif() + endif() + endforeach() + + set(Exiv2_VERSION "${EXIV2_MAJOR_VERSION}.${EXIV2_MINOR_VERSION}.${EXIV2_PATCH_VERSION}") +endif() + +# Deprecated, for backward compatibility +set(EXIV2_INCLUDE_DIR "${Exiv2_INCLUDE_DIRS}") +set(EXIV2_LIBRARIES "${Exiv2_LIBRARIES}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Exiv2 + FOUND_VAR Exiv2_FOUND + REQUIRED_VARS Exiv2_LIBRARIES Exiv2_INCLUDE_DIRS + VERSION_VAR Exiv2_VERSION +) + +mark_as_advanced(Exiv2_INCLUDE_DIRS Exiv2_LIBRARIES) + +if(Exiv2_FOUND AND NOT TARGET Exiv2::Exiv2) + add_library(Exiv2::Exiv2 UNKNOWN IMPORTED) + set_target_properties(Exiv2::Exiv2 PROPERTIES + IMPORTED_LOCATION "${Exiv2_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${Exiv2_INCLUDE_DIRS}" + ) +endif() + +include(FeatureSummary) +set_package_properties(Exiv2 PROPERTIES + URL "http://www.exiv2.org" + DESCRIPTION "Image metadata support" +) diff --git a/modules/ECMQueryQmake.cmake b/modules/ECMQueryQmake.cmake --- a/modules/ECMQueryQmake.cmake +++ b/modules/ECMQueryQmake.cmake @@ -1,13 +1,15 @@ find_package(Qt5Core QUIET) -if (Qt5Core_FOUND) - set(_qmake_executable_default "qmake-qt5") -endif () if (TARGET Qt5::qmake) get_target_property(_qmake_executable_default Qt5::qmake LOCATION) +else() + find_program(_qmake_executable_default NAMES qmake-qt5 qmake) +endif() + +if(EXISTS ${_qmake_executable_default}) + set(QMAKE_EXECUTABLE ${_qmake_executable_default} + CACHE FILEPATH "Location of the Qt5 qmake executable") endif() -set(QMAKE_EXECUTABLE ${_qmake_executable_default} - CACHE FILEPATH "Location of the Qt5 qmake executable") # Helper method # This is not public API (yet)!