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

0001 # SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0002 # SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005 
0006 #[=======================================================================[.rst:
0007 ECMFindQmlModule
0008 ----------------
0009 
0010 Find QML import modules through a ``find_qmlmodule()`` call.
0011 It looks for the qmldir and uses the qmlplugindump if needed application to find the plugins and sets them up as
0012 runtime dependencies.
0013 This is useful so that when we configure a project we are notified when some
0014 QML imports are not present in the system.
0015 
0016 ::
0017 
0018   ecm_find_qmlmodule(<module_name>
0019     <version> # Optional for Qt6 builds
0020     [REQUIRED] # Since 6.0
0021   )
0022 
0023 Usage example:
0024 
0025 .. code-block:: cmake
0026 
0027   ecm_find_qmlmodule(org.kde.kirigami 2.1)
0028   ecm_find_qmlmodule(org.kde.kirigami 2.1 REQUIRED) # CMake will fail if the required version is not found
0029   ecm_find_qmlmodule(org.kde.kirigami) # Find it without a given version
0030   ecm_find_qmlmodule(org.kde.kirigami REQUIRED) # CMake will fail if it is not found
0031 
0032 Since 5.38.0.
0033 #]=======================================================================]
0034 
0035 set(MODULES_DIR ${CMAKE_CURRENT_LIST_DIR})
0036 
0037 function(ecm_find_qmlmodule MODULE_NAME)
0038     if (QT_MAJOR_VERSION STREQUAL 6)
0039       cmake_parse_arguments(ARG REQUIRED "" "" ${ARGN})
0040         if (ARG_UNPARSED_ARGUMENTS)
0041           list(GET ARG_UNPARSED_ARGUMENTS 0 VERSION) # If we have any unparsed args, that should be the version
0042         endif()
0043         set(ARGN "") # The find_package call below should not recieve arguments in KF6
0044     else()
0045         list(GET ARGN 0 VERSION)
0046         list(REMOVE_AT ARGN 0)
0047     endif()
0048 
0049     set(GENMODULE "${MODULE_NAME}-QMLModule")
0050     configure_file("${MODULES_DIR}/ECMFindQmlModule.cmake.in" "Find${GENMODULE}.cmake" @ONLY)
0051     set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_BINARY_DIR}" ${CMAKE_MODULE_PATH})
0052     find_package(${GENMODULE} ${ARGN})
0053 
0054     if(COMMAND set_package_properties)
0055       if (ARG_REQUIRED)
0056         set(TYPE_STRING TYPE REQUIRED)
0057       else()
0058         set(TYPE_STRING TYPE RUNTIME)
0059       endif()
0060         set_package_properties(${GENMODULE} PROPERTIES
0061             DESCRIPTION "QML module '${MODULE_NAME}' is a runtime dependency."
0062             ${TYPE_STRING})
0063     endif()
0064 endfunction()