1#=============================================================================
2# Copyright 2005-2011 Kitware, Inc.
3# Copyright (C) 2020 The Qt Company Ltd.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# * Redistributions of source code must retain the above copyright
11#   notice, this list of conditions and the following disclaimer.
12#
13# * Redistributions in binary form must reproduce the above copyright
14#   notice, this list of conditions and the following disclaimer in the
15#   documentation and/or other materials provided with the distribution.
16#
17# * Neither the name of Kitware, Inc. nor the names of its
18#   contributors may be used to endorse or promote products derived
19#   from this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32#=============================================================================
33
34######################################
35#
36#       Macros for building Qt files
37#
38######################################
39
40include(CMakeParseArguments)
41
42function(_qt5_warn_deprecated command_name)
43    if(NOT DEFINED _QT5_INTERNAL_SCOPE)
44        message(AUTHOR_WARNING
45            "${command_name} is not part of the official API, and might be removed in Qt 6.")
46    endif()
47endfunction()
48
49# macro used to create the names of output files preserving relative dirs
50macro(qt5_make_output_file infile prefix ext outfile )
51    _qt5_warn_deprecated("qt5_make_output_file")
52
53    string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
54    string(LENGTH ${infile} _infileLength)
55    set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
56    if(_infileLength GREATER _binlength)
57        string(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
58        if(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
59            file(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
60        else()
61            file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
62        endif()
63    else()
64        file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
65    endif()
66    if(CMAKE_HOST_WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
67        set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
68    endif()
69    set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
70    string(REPLACE ".." "__" _outfile ${_outfile})
71    get_filename_component(outpath ${_outfile} PATH)
72    if(CMAKE_VERSION VERSION_LESS "3.14")
73        get_filename_component(_outfile_ext ${_outfile} EXT)
74        get_filename_component(_outfile_ext ${_outfile_ext} NAME_WE)
75        get_filename_component(_outfile ${_outfile} NAME_WE)
76        string(APPEND _outfile ${_outfile_ext})
77    else()
78        get_filename_component(_outfile ${_outfile} NAME_WLE)
79    endif()
80    file(MAKE_DIRECTORY ${outpath})
81    set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
82endmacro()
83
84
85macro(qt5_get_moc_flags _moc_flags)
86    _qt5_warn_deprecated("qt5_get_moc_flags")
87
88    set(${_moc_flags})
89    get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
90
91    if(CMAKE_INCLUDE_CURRENT_DIR)
92        list(APPEND _inc_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
93    endif()
94
95    foreach(_current ${_inc_DIRS})
96        if("${_current}" MATCHES "\\.framework/?$")
97            string(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
98            set(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
99        else()
100            set(${_moc_flags} ${${_moc_flags}} "-I${_current}")
101        endif()
102    endforeach()
103
104    get_directory_property(_defines COMPILE_DEFINITIONS)
105    foreach(_current ${_defines})
106        set(${_moc_flags} ${${_moc_flags}} "-D${_current}")
107    endforeach()
108
109    if(WIN32)
110        set(${_moc_flags} ${${_moc_flags}} -DWIN32)
111    endif()
112    if (MSVC)
113        set(${_moc_flags} ${${_moc_flags}} --compiler-flavor=msvc)
114    endif()
115endmacro()
116
117
118# helper macro to set up a moc rule
119function(qt5_create_moc_command infile outfile moc_flags moc_options moc_target moc_depends)
120    _qt5_warn_deprecated("qt5_create_moc_command")
121
122    # Pass the parameters in a file.  Set the working directory to
123    # be that containing the parameters file and reference it by
124    # just the file name.  This is necessary because the moc tool on
125    # MinGW builds does not seem to handle spaces in the path to the
126    # file given with the @ syntax.
127    get_filename_component(_moc_outfile_name "${outfile}" NAME)
128    get_filename_component(_moc_outfile_dir "${outfile}" PATH)
129    if(_moc_outfile_dir)
130        set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
131    endif()
132    set (_moc_parameters_file ${outfile}_parameters)
133    set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
134    string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
135
136    if(moc_target)
137        set(_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>)
138        set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
139        set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
140
141        set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},\n-I>\n>")
142        set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},\n-D>\n>")
143
144        file (GENERATE
145            OUTPUT ${_moc_parameters_file}
146            CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
147        )
148
149        set(targetincludes)
150        set(targetdefines)
151    else()
152        file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
153    endif()
154
155    set(_moc_extra_parameters_file @${_moc_parameters_file})
156    add_custom_command(OUTPUT ${outfile}
157                       COMMAND ${Qt5Core_MOC_EXECUTABLE} ${_moc_extra_parameters_file}
158                       DEPENDS ${infile} ${moc_depends}
159                       ${_moc_working_dir}
160                       VERBATIM)
161    set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON)
162    set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
163    set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
164endfunction()
165
166
167function(qt5_generate_moc infile outfile )
168    set(_QT5_INTERNAL_SCOPE ON)
169
170    # get include dirs and flags
171    qt5_get_moc_flags(moc_flags)
172    get_filename_component(abs_infile ${infile} ABSOLUTE)
173    set(_outfile "${outfile}")
174    if(NOT IS_ABSOLUTE "${outfile}")
175        set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
176    endif()
177    if ("x${ARGV2}" STREQUAL "xTARGET")
178        set(moc_target ${ARGV3})
179    endif()
180    qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
181endfunction()
182
183if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
184    function(qt_generate_moc)
185        if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
186            qt5_generate_moc(${ARGV})
187        elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
188            qt6_generate_moc(${ARGV})
189        endif()
190    endfunction()
191endif()
192
193
194# qt5_wrap_cpp(outfiles inputfile ... )
195
196function(qt5_wrap_cpp outfiles)
197    set(_QT5_INTERNAL_SCOPE ON)
198
199    # get include dirs
200    qt5_get_moc_flags(moc_flags)
201
202    set(options)
203    set(oneValueArgs TARGET)
204    set(multiValueArgs OPTIONS DEPENDS)
205
206    cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
207
208    set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
209    set(moc_options ${_WRAP_CPP_OPTIONS})
210    set(moc_target ${_WRAP_CPP_TARGET})
211    set(moc_depends ${_WRAP_CPP_DEPENDS})
212
213    foreach(it ${moc_files})
214        get_filename_component(it ${it} ABSOLUTE)
215        qt5_make_output_file(${it} moc_ cpp outfile)
216        qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}")
217        list(APPEND ${outfiles} ${outfile})
218    endforeach()
219    set(${outfiles} ${${outfiles}} PARENT_SCOPE)
220endfunction()
221
222# This will override the CMake upstream command, because that one is for Qt 3.
223if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
224    function(qt_wrap_cpp outfiles)
225        if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
226            qt5_wrap_cpp("${outfiles}" ${ARGN})
227        elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
228            qt6_wrap_cpp("${outfiles}" ${ARGN})
229        endif()
230        set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
231    endfunction()
232endif()
233
234
235# _qt5_parse_qrc_file(infile _out_depends _rc_depends)
236# internal
237
238function(_qt5_parse_qrc_file infile _out_depends _rc_depends)
239    get_filename_component(rc_path ${infile} PATH)
240
241    if(EXISTS "${infile}")
242        #  parse file for dependencies
243        #  all files are absolute paths or relative to the location of the qrc file
244        file(READ "${infile}" RC_FILE_CONTENTS)
245        string(REGEX MATCHALL "<file[^<]+" RC_FILES "${RC_FILE_CONTENTS}")
246        foreach(RC_FILE ${RC_FILES})
247            string(REGEX REPLACE "^<file[^>]*>" "" RC_FILE "${RC_FILE}")
248            if(NOT IS_ABSOLUTE "${RC_FILE}")
249                set(RC_FILE "${rc_path}/${RC_FILE}")
250            endif()
251            set(RC_DEPENDS ${RC_DEPENDS} "${RC_FILE}")
252        endforeach()
253        # Since this cmake macro is doing the dependency scanning for these files,
254        # let's make a configured file and add it as a dependency so cmake is run
255        # again when dependencies need to be recomputed.
256        qt5_make_output_file("${infile}" "" "qrc.depends" out_depends)
257        configure_file("${infile}" "${out_depends}" COPYONLY)
258    else()
259        # The .qrc file does not exist (yet). Let's add a dependency and hope
260        # that it will be generated later
261        set(out_depends)
262    endif()
263
264    set(${_out_depends} ${out_depends} PARENT_SCOPE)
265    set(${_rc_depends} ${RC_DEPENDS} PARENT_SCOPE)
266endfunction()
267
268
269# qt5_add_binary_resources(target inputfiles ... )
270
271function(qt5_add_binary_resources target)
272    set(_QT5_INTERNAL_SCOPE ON)
273
274    set(options)
275    set(oneValueArgs DESTINATION)
276    set(multiValueArgs OPTIONS)
277
278    cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
279
280    set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
281    set(rcc_options ${_RCC_OPTIONS})
282    set(rcc_destination ${_RCC_DESTINATION})
283
284    if(NOT rcc_destination)
285        set(rcc_destination ${CMAKE_CURRENT_BINARY_DIR}/${target}.rcc)
286    endif()
287
288    foreach(it ${rcc_files})
289        get_filename_component(infile ${it} ABSOLUTE)
290
291        _qt5_parse_qrc_file(${infile} _out_depends _rc_depends)
292        set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
293        set(infiles ${infiles} ${infile})
294        set(out_depends ${out_depends} ${_out_depends})
295        set(rc_depends ${rc_depends} ${_rc_depends})
296    endforeach()
297
298    add_custom_command(OUTPUT ${rcc_destination}
299                       COMMAND ${Qt5Core_RCC_EXECUTABLE}
300                       ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles}
301                       DEPENDS ${rc_depends} ${out_depends} ${infiles} VERBATIM)
302    add_custom_target(${target} ALL DEPENDS ${rcc_destination})
303endfunction()
304
305if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
306    function(qt_add_binary_resources)
307        if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
308            qt5_add_binary_resources(${ARGV})
309        elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
310            qt6_add_binary_resources(${ARGV})
311        endif()
312    endfunction()
313endif()
314
315
316# qt5_add_resources(outfiles inputfile ... )
317
318function(qt5_add_resources outfiles)
319    set(_QT5_INTERNAL_SCOPE ON)
320
321    set(options)
322    set(oneValueArgs)
323    set(multiValueArgs OPTIONS)
324
325    cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
326
327    set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
328    set(rcc_options ${_RCC_OPTIONS})
329
330    if("${rcc_options}" MATCHES "-binary")
331        message(WARNING "Use qt5_add_binary_resources for binary option")
332    endif()
333
334    foreach(it ${rcc_files})
335        get_filename_component(outfilename ${it} NAME_WE)
336        get_filename_component(infile ${it} ABSOLUTE)
337        set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp)
338
339        _qt5_parse_qrc_file(${infile} _out_depends _rc_depends)
340        set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
341
342        add_custom_command(OUTPUT ${outfile}
343                           COMMAND ${Qt5Core_RCC_EXECUTABLE}
344                           ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile}
345                           MAIN_DEPENDENCY ${infile}
346                           DEPENDS ${_rc_depends} "${_out_depends}" VERBATIM)
347        set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
348        set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
349        list(APPEND ${outfiles} ${outfile})
350    endforeach()
351    set(${outfiles} ${${outfiles}} PARENT_SCOPE)
352endfunction()
353
354if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
355    function(qt_add_resources outfiles)
356        if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
357            qt5_add_resources("${outfiles}" ${ARGN})
358        elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
359            qt6_add_resources("${outfiles}" ${ARGN})
360        endif()
361        set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
362    endfunction()
363endif()
364
365
366# qt5_add_big_resources(outfiles inputfile ... )
367
368function(qt5_add_big_resources outfiles)
369    set(_QT5_INTERNAL_SCOPE ON)
370
371    if (CMAKE_VERSION VERSION_LESS 3.9)
372        message(FATAL_ERROR, "qt5_add_big_resources requires CMake 3.9 or newer")
373    endif()
374
375    set(options)
376    set(oneValueArgs)
377    set(multiValueArgs OPTIONS)
378
379    cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
380
381    set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
382    set(rcc_options ${_RCC_OPTIONS})
383
384    if("${rcc_options}" MATCHES "-binary")
385        message(WARNING "Use qt5_add_binary_resources for binary option")
386    endif()
387
388    foreach(it ${rcc_files})
389        get_filename_component(outfilename ${it} NAME_WE)
390        get_filename_component(infile ${it} ABSOLUTE)
391        set(tmpoutfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}tmp.cpp)
392        set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.o)
393
394        _qt5_parse_qrc_file(${infile} _out_depends _rc_depends)
395        set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON)
396        add_custom_command(OUTPUT ${tmpoutfile}
397                           COMMAND ${Qt5Core_RCC_EXECUTABLE} ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
398                           DEPENDS ${infile} ${_rc_depends} "${out_depends}" VERBATIM)
399        add_custom_target(big_resources_${outfilename} ALL DEPENDS ${tmpoutfile})
400        add_library(rcc_object_${outfilename} OBJECT ${tmpoutfile})
401        set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOMOC OFF)
402        set_target_properties(rcc_object_${outfilename} PROPERTIES AUTOUIC OFF)
403        add_dependencies(rcc_object_${outfilename} big_resources_${outfilename})
404        # The modification of TARGET_OBJECTS needs the following change in cmake
405        # https://gitlab.kitware.com/cmake/cmake/commit/93c89bc75ceee599ba7c08b8fe1ac5104942054f
406        add_custom_command(OUTPUT ${outfile}
407                           COMMAND ${Qt5Core_RCC_EXECUTABLE}
408                           ARGS ${rcc_options} --name ${outfilename} --pass 2 --temp $<TARGET_OBJECTS:rcc_object_${outfilename}> --output ${outfile} ${infile}
409                           DEPENDS rcc_object_${outfilename} $<TARGET_OBJECTS:rcc_object_${outfilename}>
410                           VERBATIM)
411       list(APPEND ${outfiles} ${outfile})
412    endforeach()
413    set(${outfiles} ${${outfiles}} PARENT_SCOPE)
414endfunction()
415
416if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
417    function(qt_add_big_resources outfiles)
418        if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
419            qt5_add_big_resources(${outfiles} ${ARGN})
420        elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
421            qt6_add_big_resources(${outfiles} ${ARGN})
422        endif()
423        set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
424    endfunction()
425endif()
426
427
428set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
429
430macro(qt5_use_modules _target _link_type)
431    _qt5_warn_deprecated("qt5_use_modules")
432
433    if (NOT TARGET ${_target})
434        message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.")
435    endif()
436    if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" )
437        set(_qt5_modules ${ARGN})
438        set(_qt5_link_type ${_link_type})
439    else()
440        set(_qt5_modules ${_link_type} ${ARGN})
441    endif()
442
443    if ("${_qt5_modules}" STREQUAL "")
444        message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.")
445    endif()
446
447    foreach(_module ${_qt5_modules})
448        if (NOT Qt5${_module}_FOUND)
449            find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH)
450            if (NOT Qt5${_module}_FOUND)
451                message(FATAL_ERROR "Cannot use \"${_module}\" module which has not yet been found.")
452            endif()
453        endif()
454        target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES})
455        set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS})
456        set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS})
457        set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
458        set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
459        set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
460        if (Qt5_POSITION_INDEPENDENT_CODE
461            AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
462                OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
463            set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
464        endif()
465    endforeach()
466endmacro()
467
468function(qt5_import_plugins TARGET_NAME)
469    set(_doing "")
470    foreach(_arg ${ARGN})
471        if(_arg STREQUAL "INCLUDE")
472            set(_doing "INCLUDE")
473        elseif(_arg STREQUAL "EXCLUDE")
474            set(_doing "EXCLUDE")
475        elseif(_arg STREQUAL "INCLUDE_BY_TYPE")
476            set(_doing "INCLUDE_BY_TYPE")
477        elseif(_arg STREQUAL "EXCLUDE_BY_TYPE")
478            set(_doing "EXCLUDE_BY_TYPE")
479        else()
480            if(_doing STREQUAL "INCLUDE")
481                set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_PLUGINS "${_arg}")
482            elseif(_doing STREQUAL "EXCLUDE")
483                set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_NO_PLUGINS "${_arg}")
484            elseif(_doing STREQUAL "INCLUDE_BY_TYPE")
485                string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
486                set(_doing "INCLUDE_BY_TYPE_PLUGINS")
487            elseif(_doing STREQUAL "INCLUDE_BY_TYPE_PLUGINS")
488                set_property(TARGET ${TARGET_NAME} APPEND PROPERTY "QT_PLUGINS_${_plugin_type}" "${_arg}")
489            elseif(_doing STREQUAL "EXCLUDE_BY_TYPE")
490                string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
491                set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -)
492            else()
493                message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"")
494            endif()
495        endif()
496    endforeach()
497endfunction()
498
499if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
500    function(qt_import_plugins)
501        if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
502            qt5_import_plugins(${ARGV})
503        elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
504            qt6_import_plugins(${ARGV})
505        endif()
506    endfunction()
507endif()
508