[Pkg-owncloud-commits] [qtkeychain] 52/63: Use extra-cmake-modules to generate config files
Sandro Knauß
hefee at debian.org
Sat Jun 10 14:39:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
hefee pushed a commit to branch master
in repository qtkeychain.
commit a349d9e69ccc4dba6b6478e096d3b854a2370a45
Author: Hannah von Reth <hannah.vonreth at kdab.com>
Date: Tue Dec 6 11:46:39 2016 +0100
Use extra-cmake-modules to generate config files
---
CMakeLists.txt | 18 ++-
QtKeychainBuildTreeSettings.cmake.in | 4 -
QtKeychainConfig.cmake.in | 19 +--
QtKeychainConfigVersion.cmake.in | 11 --
cmake/Modules/ECMPackageConfigHelpers.cmake | 223 ++++++++++++++++++++++++++++
cmake/Modules/ECMQueryQmake.cmake | 32 ++++
cmake/Modules/ECMSetupVersion.cmake | 223 ++++++++++++++++++++++++++++
7 files changed, 493 insertions(+), 37 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf53a39..c8da552 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,8 @@ set(QTKEYCHAIN_SOVERSION 1)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules")
include(GNUInstallDirs)
include(GenerateExportHeader)
+include(ECMPackageConfigHelpers)
+include(ECMSetupVersion)
option(BUILD_WITH_QT4 "Build qtkeychain with Qt4 no matter if Qt5 was found" OFF)
option(BUILD_TRANSLATIONS "Build translations" ON)
@@ -195,7 +197,7 @@ else()
endif()
target_link_libraries(${QTKEYCHAIN_TARGET_NAME} PUBLIC ${qtkeychain_LIBRARIES})
-
+target_include_directories(${QTKEYCHAIN_TARGET_NAME} PUBLIC $<INSTALL_INTERFACE:include/>)
generate_export_header(${QTKEYCHAIN_TARGET_NAME}
EXPORT_FILE_NAME qkeychain_export.h
@@ -229,12 +231,14 @@ target_link_libraries( testclient ${QTKEYCHAIN_TARGET_NAME})
### CMake config file
###
-configure_file(QtKeychainBuildTreeSettings.cmake.in
- "${PROJECT_BINARY_DIR}/Qt${QTKEYCHAIN_VERSION_INFIX}KeychainBuildTreeSettings.cmake" @ONLY)
-configure_file(QtKeychainConfig.cmake.in
- "${PROJECT_BINARY_DIR}/Qt${QTKEYCHAIN_VERSION_INFIX}KeychainConfig.cmake" @ONLY)
-configure_file(QtKeychainConfigVersion.cmake.in
- "${PROJECT_BINARY_DIR}/Qt${QTKEYCHAIN_VERSION_INFIX}KeychainConfigVersion.cmake" @ONLY)
+ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/QtKeychainConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/Qt${QTKEYCHAIN_VERSION_INFIX}KeychainConfig.cmake"
+ INSTALL_DESTINATION Qt${QTKEYCHAIN_VERSION_INFIX}Keychain)
+
+ecm_setup_version("${QTKEYCHAIN_VERSION}" VARIABLE_PREFIX SNORE
+ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Qt${QTKEYCHAIN_VERSION_INFIX}KeychainConfigVersion.cmake"
+ SOVERSION ${QTKEYCHAIN_VERSION})
+
install(EXPORT Qt${QTKEYCHAIN_VERSION_INFIX}KeychainLibraryDepends
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Qt${QTKEYCHAIN_VERSION_INFIX}Keychain"
diff --git a/QtKeychainBuildTreeSettings.cmake.in b/QtKeychainBuildTreeSettings.cmake.in
deleted file mode 100644
index 3f9e9f6..0000000
--- a/QtKeychainBuildTreeSettings.cmake.in
+++ /dev/null
@@ -1,4 +0,0 @@
-set(QTKEYCHAIN_INCLUDE_DIRS
- "@PROJECT_SOURCE_DIR@"
- "@PROJECT_BINARY_DIR@"
-)
diff --git a/QtKeychainConfig.cmake.in b/QtKeychainConfig.cmake.in
index d6ac4da..3196bff 100644
--- a/QtKeychainConfig.cmake.in
+++ b/QtKeychainConfig.cmake.in
@@ -3,16 +3,10 @@
# QTKEYCHAIN_INCLUDE_DIRS - include directories for QtKeychain
# QTKEYCHAIN_LIBRARIES - libraries to link against
-# Compute paths
-get_filename_component(QTKEYCHAIN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-if(EXISTS "${QTKEYCHAIN_CMAKE_DIR}/CMakeCache.txt")
- # In build tree
- include("${QTKEYCHAIN_CMAKE_DIR}/Qt at QTKEYCHAIN_VERSION_INFIX@KeychainBuildTreeSettings.cmake")
-else()
- set(QTKEYCHAIN_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
-endif()
+ at PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/Qt at QTKEYCHAIN_VERSION_INFIX@KeychainLibraryDepends.cmake")
-include(CMakeFindDependencyMacro)
if("@QTKEYCHAIN_VERSION_INFIX@" STREQUAL "5")
find_dependency(Qt5Core)
@@ -24,10 +18,5 @@ else()
find_dependency(Qt4 COMPONENTS QtCore)
endif()
-# Our library dependencies (contains definitions for IMPORTED targets)
-include("${QTKEYCHAIN_CMAKE_DIR}/Qt at QTKEYCHAIN_VERSION_INFIX@KeychainLibraryDepends.cmake")
-
-# These are IMPORTED targets created by FooBarLibraryDepends.cmake
set(QTKEYCHAIN_LIBRARIES "@QTKEYCHAIN_TARGET_NAME@")
-
-set(QTKEYCHAIN_FOUND TRUE)
+get_target_property(QTKEYCHAIN_INCLUDE_DIRS "@QTKEYCHAIN_TARGET_NAME@" INTERFACE_INCLUDE_DIRECTORIES)
diff --git a/QtKeychainConfigVersion.cmake.in b/QtKeychainConfigVersion.cmake.in
deleted file mode 100644
index fba821a..0000000
--- a/QtKeychainConfigVersion.cmake.in
+++ /dev/null
@@ -1,11 +0,0 @@
-set(PACKAGE_VERSION "@QTKEYCHAIN_VERSION@")
-
-# Check whether the requested PACKAGE_FIND_VERSION is compatible
-if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
- set(PACKAGE_VERSION_COMPATIBLE FALSE)
-else()
- set(PACKAGE_VERSION_COMPATIBLE TRUE)
- if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
- set(PACKAGE_VERSION_EXACT TRUE)
- endif()
-endif()
diff --git a/cmake/Modules/ECMPackageConfigHelpers.cmake b/cmake/Modules/ECMPackageConfigHelpers.cmake
new file mode 100644
index 0000000..a118fea
--- /dev/null
+++ b/cmake/Modules/ECMPackageConfigHelpers.cmake
@@ -0,0 +1,223 @@
+#.rst:
+# ECMPackageConfigHelpers
+# -----------------------
+#
+# Helper macros for generating CMake package config files.
+#
+# ``write_basic_package_version_file()`` is the same as the one provided by the
+# `CMakePackageConfigHelpers
+# <http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:CMakePackageConfigHelpers>`_
+# module in CMake; see that module's documentation for
+# more information.
+#
+# ::
+#
+# ecm_configure_package_config_file(<input> <output>
+# INSTALL_DESTINATION <path>
+# [PATH_VARS <var1> [<var2> [...]]
+# [NO_SET_AND_CHECK_MACRO]
+# [NO_CHECK_REQUIRED_COMPONENTS_MACRO])
+#
+#
+# This behaves in the same way as configure_package_config_file() from CMake
+# 2.8.12, except that it adds an extra helper macro: find_dependency(). It is
+# highly recommended that you read the `documentation for
+# CMakePackageConfigHelpers
+# <http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:CMakePackageConfigHelpers>`_
+# for more information, particularly with regard to the PATH_VARS argument.
+#
+# Note that there is no argument that will disable the find_dependency() macro;
+# if you do not require this macro, you should use
+# ``configure_package_config_file`` from the CMakePackageConfigHelpers module.
+#
+# CMake 3.0 includes a CMakeFindDependencyMacro module that provides the
+# find_dependency() macro (which you can ``include()`` in your package config
+# file), so this file is only useful for projects wishing to provide config
+# files that will work with CMake 2.8.12.
+#
+# Additional Config File Macros
+# =============================
+#
+# ::
+#
+# find_dependency(<dep> [<version> [EXACT]])
+#
+# find_dependency() should be used instead of find_package() to find package
+# dependencies. It forwards the correct parameters for EXACT, QUIET and
+# REQUIRED which were passed to the original find_package() call. It also sets
+# an informative diagnostic message if the dependency could not be found.
+#
+# Since pre-1.0.0.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry at kdemail.net>
+# Copyright 2013 Stephen Kelly <steveire at gmail.com>
+#
+# 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.
+
+include(${CMAKE_ROOT}/Modules/CMakePackageConfigHelpers.cmake)
+
+set(_ecm_package_config_helpers_included TRUE)
+
+if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.13)
+ message(AUTHOR_WARNING "Your project already requires a version of CMake that includes the find_dependency macro via the CMakeFindDependencyMacro module. You should use CMakePackageConfigHelpers instead of ECMPackageConfigHelpers.")
+endif()
+
+function(ECM_CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
+ set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+ set(oneValueArgs INSTALL_DESTINATION )
+ set(multiValueArgs PATH_VARS )
+
+ cmake_parse_arguments(CCF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(CCF_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to CONFIGURE_PACKAGE_CONFIG_FILE(): \"${CCF_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ if(NOT CCF_INSTALL_DESTINATION)
+ message(FATAL_ERROR "No INSTALL_DESTINATION given to CONFIGURE_PACKAGE_CONFIG_FILE()")
+ endif()
+
+ if(IS_ABSOLUTE "${CCF_INSTALL_DESTINATION}")
+ set(absInstallDir "${CCF_INSTALL_DESTINATION}")
+ else()
+ set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}")
+ endif()
+
+ file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" )
+
+ foreach(var ${CCF_PATH_VARS})
+ if(NOT DEFINED ${var})
+ message(FATAL_ERROR "Variable ${var} does not exist")
+ else()
+ if(IS_ABSOLUTE "${${var}}")
+ string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}"
+ PACKAGE_${var} "${${var}}")
+ else()
+ set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}")
+ endif()
+ endif()
+ endforeach()
+
+ get_filename_component(inputFileName "${_inputFile}" NAME)
+
+ set(PACKAGE_INIT "
+####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() (ECM variant) #######
+####### Any changes to this file will be overwritten by the next CMake run #######
+####### The input file was ${inputFileName} #######
+
+get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE)
+")
+
+ if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+")
+ # Handle "/usr move" symlinks created by some Linux distros.
+ set(PACKAGE_INIT "${PACKAGE_INIT}
+# Use original install prefix when loaded through a \"/usr move\"
+# cross-prefix symbolic link such as /lib -> /usr/lib.
+get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH)
+get_filename_component(_realOrig \"${absInstallDir}\" REALPATH)
+if(_realCurr STREQUAL _realOrig)
+ set(PACKAGE_PREFIX_DIR \"${CMAKE_INSTALL_PREFIX}\")
+endif()
+unset(_realOrig)
+unset(_realCurr)
+")
+ endif()
+
+ if(NOT CCF_NO_SET_AND_CHECK_MACRO)
+ set(PACKAGE_INIT "${PACKAGE_INIT}
+macro(set_and_check _var _file)
+ set(\${_var} \"\${_file}\")
+ if(NOT EXISTS \"\${_file}\")
+ message(FATAL_ERROR \"File or directory \${_file} referenced by variable \${_var} does not exist !\")
+ endif()
+endmacro()
+
+include(CMakeFindDependencyMacro OPTIONAL RESULT_VARIABLE _CMakeFindDependencyMacro_FOUND)
+
+if (NOT _CMakeFindDependencyMacro_FOUND)
+ macro(find_dependency dep)
+ if (NOT \${dep}_FOUND)
+
+ set(ecm_fd_version)
+ if (\${ARGC} GREATER 1)
+ set(ecm_fd_version \${ARGV1})
+ endif()
+ set(ecm_fd_exact_arg)
+ if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
+ set(ecm_fd_exact_arg EXACT)
+ endif()
+ set(ecm_fd_quiet_arg)
+ if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
+ set(ecm_fd_quiet_arg QUIET)
+ endif()
+ set(ecm_fd_required_arg)
+ if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ set(ecm_fd_required_arg REQUIRED)
+ endif()
+
+ find_package(\${dep} \${ecm_fd_version}
+ \${ecm_fd_exact_arg}
+ \${ecm_fd_quiet_arg}
+ \${ecm_fd_required_arg}
+ )
+
+ if (NOT \${dep}_FOUND)
+ set(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE \"\${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency \${dep} could not be found.\")
+ set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
+ return()
+ endif()
+
+ set(ecm_fd_version)
+ set(ecm_fd_required_arg)
+ set(ecm_fd_quiet_arg)
+ set(ecm_fd_exact_arg)
+ endif()
+ endmacro()
+endif()
+
+")
+ endif()
+
+
+ if(NOT CCF_NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+ set(PACKAGE_INIT "${PACKAGE_INIT}
+macro(check_required_components _NAME)
+ foreach(comp \${\${_NAME}_FIND_COMPONENTS})
+ if(NOT \${_NAME}_\${comp}_FOUND)
+ if(\${_NAME}_FIND_REQUIRED_\${comp})
+ set(\${_NAME}_FOUND FALSE)
+ endif()
+ endif()
+ endforeach()
+endmacro()
+")
+ endif()
+
+ set(PACKAGE_INIT "${PACKAGE_INIT}
+####################################################################################")
+
+ configure_file("${_inputFile}" "${_outputFile}" @ONLY)
+
+endfunction()
diff --git a/cmake/Modules/ECMQueryQmake.cmake b/cmake/Modules/ECMQueryQmake.cmake
new file mode 100644
index 0000000..fa0949d
--- /dev/null
+++ b/cmake/Modules/ECMQueryQmake.cmake
@@ -0,0 +1,32 @@
+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)
+endif()
+set(QMAKE_EXECUTABLE ${_qmake_executable_default}
+ CACHE FILEPATH "Location of the Qt5 qmake executable")
+
+# This is not public API (yet)!
+function(query_qmake result_variable qt_variable)
+ if(NOT QMAKE_EXECUTABLE)
+ set(${result_variable} "" PARENT_SCOPE)
+ message(WARNING "Should specify a qmake Qt5 binary. Can't check ${qt_variable}")
+ return()
+ endif()
+ execute_process(
+ COMMAND ${QMAKE_EXECUTABLE} -query "${qt_variable}"
+ RESULT_VARIABLE return_code
+ OUTPUT_VARIABLE output
+ )
+ if(return_code EQUAL 0)
+ string(STRIP "${output}" output)
+ file(TO_CMAKE_PATH "${output}" output_path)
+ set(${result_variable} "${output_path}" PARENT_SCOPE)
+ else()
+ message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query \"${qt_variable}\"")
+ message(FATAL_ERROR "QMake call failed: ${return_code}")
+ endif()
+endfunction()
diff --git a/cmake/Modules/ECMSetupVersion.cmake b/cmake/Modules/ECMSetupVersion.cmake
new file mode 100644
index 0000000..f5a3cce
--- /dev/null
+++ b/cmake/Modules/ECMSetupVersion.cmake
@@ -0,0 +1,223 @@
+#.rst:
+# ECMSetupVersion
+# ---------------
+#
+# Handle library version information.
+#
+# ::
+#
+# ecm_setup_version(<version>
+# VARIABLE_PREFIX <prefix>
+# [SOVERSION <soversion>]
+# [VERSION_HEADER <filename>]
+# [PACKAGE_VERSION_FILE <filename> [COMPATIBILITY <compat>]] )
+#
+# This parses a version string and sets up a standard set of version variables.
+# It can optionally also create a C version header file and a CMake package
+# version file to install along with the library.
+#
+# If the ``<version>`` argument is of the form ``<major>.<minor>.<patch>``
+# (or ``<major>.<minor>.<patch>.<tweak>``), The following CMake variables are
+# set::
+#
+# <prefix>_VERSION_MAJOR - <major>
+# <prefix>_VERSION_MINOR - <minor>
+# <prefix>_VERSION_PATCH - <patch>
+# <prefix>_VERSION - <version>
+# <prefix>_VERSION_STRING - <version> (for compatibility: use <prefix>_VERSION instead)
+# <prefix>_SOVERSION - <soversion>, or <major> if SOVERSION was not given
+#
+# If CMake policy CMP0048 is not NEW, the following CMake variables will also
+# be set:
+#
+# PROJECT_VERSION_MAJOR - <major>
+# PROJECT_VERSION_MINOR - <minor>
+# PROJECT_VERSION_PATCH - <patch>
+# PROJECT_VERSION - <version>
+# PROJECT_VERSION_STRING - <version> (for compatibility: use PROJECT_VERSION instead)
+#
+# If the VERSION_HEADER option is used, a simple C header is generated with the
+# given filename. If filename is a relative path, it is interpreted as relative
+# to CMAKE_CURRENT_BINARY_DIR. The generated header contains the following
+# macros::
+#
+# <prefix>_VERSION_MAJOR - <major> as an integer
+# <prefix>_VERSION_MINOR - <minor> as an integer
+# <prefix>_VERSION_PATCH - <patch> as an integer
+# <prefix>_VERSION_STRING - <version> as a C string
+# <prefix>_VERSION - the version as an integer
+#
+# ``<prefix>_VERSION`` has ``<patch>`` in the bottom 8 bits, ``<minor>`` in the
+# next 8 bits and ``<major>`` in the remaining bits. Note that ``<patch>`` and
+# ``<minor>`` must be less than 256.
+#
+# If the PACKAGE_VERSION_FILE option is used, a simple CMake package version
+# file is created using the write_basic_package_version_file() macro provided by
+# CMake. It should be installed in the same location as the Config.cmake file of
+# the library so that it can be found by find_package(). If the filename is a
+# relative path, it is interpreted as relative to CMAKE_CURRENT_BINARY_DIR. The
+# optional COMPATIBILITY option is forwarded to
+# write_basic_package_version_file(), and defaults to AnyNewerVersion.
+#
+# If CMake policy CMP0048 is NEW, an alternative form of the command is
+# available::
+#
+# ecm_setup_version(PROJECT
+# [VARIABLE_PREFIX <prefix>]
+# [SOVERSION <soversion>]
+# [VERSION_HEADER <filename>]
+# [PACKAGE_VERSION_FILE <filename>] )
+#
+# This will use the version information set by the project() command.
+# VARIABLE_PREFIX defaults to the project name. Note that PROJECT must be the
+# first argument. In all other respects, it behaves like the other form of the
+# command.
+#
+# Since pre-1.0.0.
+#
+# COMPATIBLITY option available since 1.6.0.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry at kde.org>
+# Copyright 2012 Alexander Neundorf <neundorf at kde.org>
+#
+# 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.
+
+include(CMakePackageConfigHelpers)
+
+# save the location of the header template while CMAKE_CURRENT_LIST_DIR
+# has the value we want
+set(_ECM_SETUP_VERSION_HEADER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/ECMVersionHeader.h.in")
+
+function(ecm_setup_version _version)
+ set(options )
+ set(oneValueArgs VARIABLE_PREFIX SOVERSION VERSION_HEADER PACKAGE_VERSION_FILE COMPATIBILITY)
+ set(multiValueArgs )
+
+ cmake_parse_arguments(ESV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(ESV_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to ECM_SETUP_VERSION(): \"${ESV_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ set(project_manages_version FALSE)
+ set(use_project_version FALSE)
+ # CMP0048 only exists in CMake 3.0.0 and later
+ if(CMAKE_VERSION VERSION_LESS 3.0.0)
+ set(project_version_policy "OLD")
+ else()
+ cmake_policy(GET CMP0048 project_version_policy)
+ endif()
+ if(project_version_policy STREQUAL "NEW")
+ set(project_manages_version TRUE)
+ if(_version STREQUAL "PROJECT")
+ set(use_project_version TRUE)
+ endif()
+ elseif(_version STREQUAL "PROJECT")
+ message(FATAL_ERROR "ecm_setup_version given PROJECT argument, but CMP0048 is not NEW")
+ endif()
+
+ set(should_set_prefixed_vars TRUE)
+ if(NOT ESV_VARIABLE_PREFIX)
+ if(use_project_version)
+ set(ESV_VARIABLE_PREFIX "${PROJECT_NAME}")
+ set(should_set_prefixed_vars FALSE)
+ else()
+ message(FATAL_ERROR "Required argument PREFIX missing in ECM_SETUP_VERSION() call")
+ endif()
+ endif()
+
+ if(use_project_version)
+ set(_version "${PROJECT_VERSION}")
+ set(_major "${PROJECT_VERSION_MAJOR}")
+ set(_minor "${PROJECT_VERSION_MINOR}")
+ set(_patch "${PROJECT_VERSION_PATCH}")
+ else()
+ string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major "${_version}")
+ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor "${_version}")
+ string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch "${_version}")
+ endif()
+
+ if(NOT ESV_SOVERSION)
+ set(ESV_SOVERSION ${_major})
+ endif()
+
+ if(should_set_prefixed_vars)
+ set(${ESV_VARIABLE_PREFIX}_VERSION "${_version}")
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MAJOR ${_major})
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MINOR ${_minor})
+ set(${ESV_VARIABLE_PREFIX}_VERSION_PATCH ${_patch})
+ endif()
+
+ set(${ESV_VARIABLE_PREFIX}_SOVERSION ${ESV_SOVERSION})
+
+ if(NOT project_manages_version)
+ set(PROJECT_VERSION "${_version}")
+ set(PROJECT_VERSION_MAJOR "${_major}")
+ set(PROJECT_VERSION_MINOR "${_minor}")
+ set(PROJECT_VERSION_PATCH "${_patch}")
+ endif()
+
+ # compat
+ set(PROJECT_VERSION_STRING "${PROJECT_VERSION}")
+ set(${ESV_VARIABLE_PREFIX}_VERSION_STRING "${${ESV_VARIABLE_PREFIX}_VERSION}")
+
+ if(ESV_VERSION_HEADER)
+ set(HEADER_PREFIX "${ESV_VARIABLE_PREFIX}")
+ set(HEADER_VERSION "${_version}")
+ set(HEADER_VERSION_MAJOR "${_major}")
+ set(HEADER_VERSION_MINOR "${_minor}")
+ set(HEADER_VERSION_PATCH "${_patch}")
+ configure_file("${_ECM_SETUP_VERSION_HEADER_TEMPLATE}" "${ESV_VERSION_HEADER}")
+ endif()
+
+ if(ESV_PACKAGE_VERSION_FILE)
+ if(NOT ESV_COMPATIBILITY)
+ set(ESV_COMPATIBILITY AnyNewerVersion)
+ endif()
+ write_basic_package_version_file("${ESV_PACKAGE_VERSION_FILE}" VERSION ${_version} COMPATIBILITY ${ESV_COMPATIBILITY})
+ endif()
+
+ if(should_set_prefixed_vars)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MAJOR "${${ESV_VARIABLE_PREFIX}_VERSION_MAJOR}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MINOR "${${ESV_VARIABLE_PREFIX}_VERSION_MINOR}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_PATCH "${${ESV_VARIABLE_PREFIX}_VERSION_PATCH}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION "${${ESV_VARIABLE_PREFIX}_VERSION}" PARENT_SCOPE)
+ endif()
+
+ # always set the soversion
+ set(${ESV_VARIABLE_PREFIX}_SOVERSION "${${ESV_VARIABLE_PREFIX}_SOVERSION}" PARENT_SCOPE)
+
+ if(NOT project_manages_version)
+ set(PROJECT_VERSION "${PROJECT_VERSION}" PARENT_SCOPE)
+ set(PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}" PARENT_SCOPE)
+ set(PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}" PARENT_SCOPE)
+ set(PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}" PARENT_SCOPE)
+ endif()
+
+ # always set the compatibility variables
+ set(PROJECT_VERSION_STRING "${PROJECT_VERSION_STRING}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_STRING "${${ESV_VARIABLE_PREFIX}_VERSION}" PARENT_SCOPE)
+
+endfunction()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/qtkeychain.git
More information about the Pkg-owncloud-commits
mailing list