Warning, /frameworks/extra-cmake-modules/find-modules/FindKF5.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org>
0002 # SPDX-FileCopyrightText: 2013 Stephen Kelly <steveire@gmail.com>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005 
0006 #[=======================================================================[.rst:
0007 FindKF5
0008 -------
0009 
0010 Find KDE Frameworks 5 with a single find_package() call.
0011 
0012 This will use the package config files provided by the individual frameworks.
0013 For example, if you wish to find KArchive, which presents itself to CMake as
0014 KF5Archive (ie: you would do ``find_package(KF5Archive)`` to find it
0015 directly), you can do
0016 
0017 .. code-block:: cmake
0018 
0019   find_package(KF5 COMPONENTS Archive)
0020 
0021 If all the required components (those given in the COMPONENTS argument, but
0022 not those given in the OPTIONAL_COMPONENTS argument) are found, ``KF5_FOUND``
0023 will be set to true. Otherwise, it will be set to false.
0024 
0025 Since pre-1.0.0.
0026 #]=======================================================================]
0027 
0028 include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
0029 
0030 ecm_find_package_version_check(KF5)
0031 
0032 if (NOT KF5_FIND_COMPONENTS)
0033     set(KF5_NOT_FOUND_MESSAGE "The KF5 package requires at least one component")
0034     set(KF5_FOUND False)
0035     return()
0036 endif()
0037 
0038 set(_quiet_arg)
0039 if (KF5_FIND_QUIETLY)
0040     set(_quiet_arg QUIET)
0041 endif()
0042 set(_exact_arg)
0043 if (KF5_FIND_EXACT)
0044     set(_exact_arg EXACT)
0045 endif()
0046 
0047 include(FindPackageHandleStandardArgs)
0048 include(FeatureSummary)
0049 
0050 set(KF5_VERSION)
0051 foreach(_module ${KF5_FIND_COMPONENTS})
0052     find_package(KF5${_module} ${KF5_FIND_VERSION}
0053         ${_exact_arg} ${_quiet_arg}
0054         CONFIG
0055     )
0056     # CMake >= 3.17 wants to be explicitly told we are fine with name mismatch here
0057     set(_name_mismatched_arg)
0058     if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
0059        set(_name_mismatched_arg NAME_MISMATCHED)
0060     endif()
0061     find_package_handle_standard_args(KF5${_module} CONFIG_MODE ${_name_mismatched_arg})
0062     if (KF5_FIND_REQUIRED AND KF5_FIND_REQUIRED_${_module})
0063         # If the component was required, we tell FeatureSummary so that it
0064         # will be displayed in the correct list. We do not use the REQUIRED
0065         # argument of find_package() to allow all the missing frameworks
0066         # to be listed at once (fphsa will error out at the end of this file
0067         # anyway).
0068         set_package_properties(KF5${_module} PROPERTIES TYPE REQUIRED)
0069     endif()
0070 
0071     # Component-based find modules are expected to set
0072     # <module>_<component>_FOUND and <module>_<component>_VERSION variables,
0073     # but the find_package calls above will have set KF5<component>_*
0074     # variables.
0075     set(KF5_${_module}_FOUND ${KF5${_module}_FOUND})
0076     if(KF5${_module}_FOUND)
0077         set(KF5_${_module}_VERSION ${KF5${_module}_VERSION})
0078 
0079         # make KF5_VERSION the minimum found version
0080         if(NOT KF5_VERSION OR KF5_VERSION VERSION_GREATER KF5${_module}_VERSION)
0081             set(KF5_VERSION ${KF5${_module}_VERSION})
0082         endif()
0083     endif()
0084 endforeach()
0085 
0086 # Annoyingly, find_package_handle_standard_args requires you to provide
0087 # REQUIRED_VARS even when using HANDLE_COMPONENTS, but all we actually
0088 # care about is whether the required components were found. So we provide
0089 # a dummy variable that is just set to something that will be printed
0090 # on success.
0091 set(_dummy_req_var "success")
0092 
0093 find_package_handle_standard_args(KF5
0094     FOUND_VAR
0095         KF5_FOUND
0096     REQUIRED_VARS
0097         _dummy_req_var
0098     VERSION_VAR
0099         KF5_VERSION
0100     HANDLE_COMPONENTS
0101 )
0102