aboutsummaryrefslogtreecommitdiff
path: root/find-modules
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@kde.org>2014-04-25 23:53:13 +0100
committerAlex Merry <alex.merry@kde.org>2014-04-26 10:06:55 +0100
commit12e3e7e2d6685aa29a487914cb45b27b183866ec (patch)
tree412024e6c4fa4778a16c70331eaa73851db90957 /find-modules
parentb3bf34a749d6dbed8b08e75cc3a094f107a00a65 (diff)
downloadextra-cmake-modules-12e3e7e2d6685aa29a487914cb45b27b183866ec.tar.gz
extra-cmake-modules-12e3e7e2d6685aa29a487914cb45b27b183866ec.tar.bz2
Add a FindKF5.cmake module
REVIEW: 117780
Diffstat (limited to 'find-modules')
-rw-r--r--find-modules/FindKF5.cmake120
1 files changed, 120 insertions, 0 deletions
diff --git a/find-modules/FindKF5.cmake b/find-modules/FindKF5.cmake
new file mode 100644
index 00000000..2e1fca87
--- /dev/null
+++ b/find-modules/FindKF5.cmake
@@ -0,0 +1,120 @@
+#.rst:
+# FindKF5
+# -------
+#
+# Find KDE Frameworks 5 with a single find_package() call.
+#
+# This will use the package config files provided by the individual frameworks.
+# For example, if you wish to find KArchive, which presents itself to CMake as
+# KF5Archive (ie: you would do ``find_package(KF5Archive)`` to find it
+# directly), you can do
+#
+# .. code-block:: cmake
+#
+# find_package(KF5 COMPONENTS Archive)
+#
+# If all the required components (those given in the COMPONENTS argument, but
+# not those given in the OPTIONAL_COMPONENTS argument) are found, ``KF5_FOUND``
+# will be set to true. Otherwise, it will be set to false.
+
+#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
+# Copyright 2013 Stephen Kelly <steveire@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.
+#=============================================================================
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "CMake 2.8.12 is required by FindKF5.cmake")
+endif()
+if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
+ message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindKF5.cmake")
+endif()
+
+if (NOT KF5_FIND_COMPONENTS)
+ set(KF5_NOT_FOUND_MESSAGE "The KF5 package requires at least one component")
+ set(KF5_FOUND False)
+ return()
+endif()
+
+set(_quiet_arg)
+if (KF5_FIND_QUIETLY)
+ set(_quiet_arg QUIET)
+endif()
+set(_exact_arg)
+if (KF5_FIND_EXACT)
+ set(_exact_arg EXACT)
+endif()
+
+include(FindPackageHandleStandardArgs)
+include(FeatureSummary)
+
+set(KF5_VERSION)
+foreach(_module ${KF5_FIND_COMPONENTS})
+ find_package(KF5${_module} ${KF5_FIND_VERSION}
+ ${_exact_arg} ${_quiet_arg}
+ CONFIG
+ )
+ find_package_handle_standard_args(KF5${_module} CONFIG_MODE)
+ if (KF5_FIND_REQUIRED AND KF5_FIND_REQUIRED_${_module})
+ # If the component was required, we tell FeatureSummary so that it
+ # will be displayed in the correct list. We do not use the REQUIRED
+ # argument of find_package() to allow all the missing frameworks
+ # to be listed at once (fphsa will error out at the end of this file
+ # anyway).
+ set_package_properties(KF5${_module} PROPERTIES TYPE REQUIRED)
+ endif()
+
+ # Component-based find modules are expected to set
+ # <module>_<component>_FOUND and <module>_<component>_VERSION variables,
+ # but the find_package calls above will have set KF5<component>_*
+ # variables.
+ set(KF5_${_module}_FOUND ${KF5${_module}_FOUND})
+ if(KF5${_module}_FOUND)
+ set(KF5_${_module}_VERSION ${KF5${_module}_VERSION})
+
+ # make KF5_VERSION the minimum found version
+ if(NOT KF5_VERSION OR KF5_VERSION VERSION_GREATER KF5${_module}_VERSION)
+ set(KF5_VERSION ${KF5${_module}_VERSION})
+ endif()
+ endif()
+endforeach()
+
+# Annoyingly, find_package_handle_standard_args requires you to provide
+# REQUIRED_VARS even when using HANDLE_COMPONENTS, but all we actually
+# care about is whether the required components were found. So we provide
+# a dummy variable that is just set to something that will be printed
+# on success.
+set(_dummy_req_var "success")
+
+find_package_handle_standard_args(KF5
+ FOUND_VAR
+ KF5_FOUND
+ REQUIRED_VARS
+ _dummy_req_var
+ VERSION_VAR
+ KF5_VERSION
+ HANDLE_COMPONENTS
+)
+