2011-11-01 13:59:23 +00:00
# Copyright 2005-2011 Kitware, Inc.
2022-07-05 11:26:52 +00:00
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: (LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0) AND BSD-3-Clause
2011-11-01 13:59:23 +00:00
######################################
#
# Macros for building Qt files
#
######################################
2011-12-05 01:06:21 +00:00
include ( CMakeParseArguments )
2011-11-01 13:59:23 +00:00
2020-10-30 15:46:40 +00:00
set ( __qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}" )
2011-11-01 13:59:23 +00:00
# macro used to create the names of output files preserving relative dirs
2020-10-14 11:20:55 +00:00
macro ( _qt_internal_make_output_file infile prefix ext outfile )
2011-12-19 21:17:02 +00:00
string ( LENGTH ${ CMAKE_CURRENT_BINARY_DIR } _binlength )
string ( LENGTH ${ infile } _infileLength )
set ( _checkinfile ${ CMAKE_CURRENT_SOURCE_DIR } )
if ( _infileLength GREATER _binlength )
string ( SUBSTRING "${infile}" 0 ${ _binlength } _checkinfile )
if ( _checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" )
file ( RELATIVE_PATH rel ${ CMAKE_CURRENT_BINARY_DIR } ${ infile } )
else ( )
file ( RELATIVE_PATH rel ${ CMAKE_CURRENT_SOURCE_DIR } ${ infile } )
endif ( )
else ( )
file ( RELATIVE_PATH rel ${ CMAKE_CURRENT_SOURCE_DIR } ${ infile } )
endif ( )
2015-12-21 16:56:55 +00:00
if ( WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$" ) # absolute path
set ( rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}" )
2011-12-19 21:17:02 +00:00
endif ( )
set ( _outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}" )
string ( REPLACE ".." "__" _outfile ${ _outfile } )
get_filename_component ( outpath ${ _outfile } PATH )
2020-02-13 08:14:09 +00:00
if ( CMAKE_VERSION VERSION_LESS "3.14" )
get_filename_component ( _outfile_ext ${ _outfile } EXT )
get_filename_component ( _outfile_ext ${ _outfile_ext } NAME_WE )
get_filename_component ( _outfile ${ _outfile } NAME_WE )
string ( APPEND _outfile ${ _outfile_ext } )
else ( )
get_filename_component ( _outfile ${ _outfile } NAME_WLE )
endif ( )
2011-12-19 21:17:02 +00:00
file ( MAKE_DIRECTORY ${ outpath } )
set ( ${ outfile } ${ outpath } / ${ prefix } ${ _outfile } . ${ ext } )
endmacro ( )
2020-10-14 11:20:55 +00:00
macro ( _qt_internal_get_moc_flags _moc_flags )
2011-12-19 21:17:02 +00:00
set ( ${ _moc_flags } )
get_directory_property ( _inc_DIRS INCLUDE_DIRECTORIES )
2012-10-02 10:04:00 +00:00
if ( CMAKE_INCLUDE_CURRENT_DIR )
list ( APPEND _inc_DIRS ${ CMAKE_CURRENT_SOURCE_DIR } ${ CMAKE_CURRENT_BINARY_DIR } )
endif ( )
2011-12-19 21:17:02 +00:00
foreach ( _current ${ _inc_DIRS } )
if ( "${_current}" MATCHES "\\.framework/?$" )
string ( REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}" )
set ( ${ _moc_flags } ${ ${_moc_flags } } "-F${framework_path}" )
else ( )
set ( ${ _moc_flags } ${ ${_moc_flags } } "-I${_current}" )
endif ( )
endforeach ( )
get_directory_property ( _defines COMPILE_DEFINITIONS )
foreach ( _current ${ _defines } )
set ( ${ _moc_flags } ${ ${_moc_flags } } "-D${_current}" )
endforeach ( )
2012-02-23 00:05:46 +00:00
if ( WIN32 )
2011-12-19 21:17:02 +00:00
set ( ${ _moc_flags } ${ ${_moc_flags } } -DWIN32 )
endif ( )
2016-04-14 00:25:37 +00:00
if ( MSVC )
2017-02-01 19:05:35 +00:00
set ( ${ _moc_flags } ${ ${_moc_flags } } --compiler-flavor=msvc )
2016-04-14 00:25:37 +00:00
endif ( )
2011-12-19 21:17:02 +00:00
endmacro ( )
2011-11-01 13:59:23 +00:00
# helper macro to set up a moc rule
2021-09-17 13:03:55 +00:00
function ( _qt_internal_create_moc_command infile outfile moc_flags moc_options
m o c _ t a r g e t m o c _ d e p e n d s o u t _ j s o n _ f i l e )
2013-06-19 15:56:04 +00:00
# Pass the parameters in a file. Set the working directory to
# be that containing the parameters file and reference it by
# just the file name. This is necessary because the moc tool on
# MinGW builds does not seem to handle spaces in the path to the
# file given with the @ syntax.
get_filename_component ( _moc_outfile_name "${outfile}" NAME )
get_filename_component ( _moc_outfile_dir "${outfile}" PATH )
if ( _moc_outfile_dir )
set ( _moc_working_dir WORKING_DIRECTORY ${ _moc_outfile_dir } )
endif ( )
set ( _moc_parameters_file ${ outfile } _parameters )
set ( _moc_parameters ${ moc_flags } ${ moc_options } -o "${outfile}" "${infile}" )
2021-09-17 13:03:55 +00:00
if ( out_json_file )
list ( APPEND _moc_parameters --output-json )
set ( extra_output_files "${outfile}.json" )
set ( ${ out_json_file } "${extra_output_files}" PARENT_SCOPE )
endif ( )
2013-06-19 15:56:04 +00:00
string ( REPLACE ";" "\n" _moc_parameters "${_moc_parameters}" )
if ( moc_target )
2013-12-13 14:17:03 +00:00
set ( _moc_parameters_file ${ _moc_parameters_file } $< $<BOOL:$<CONFIGURATION > >:_ $< CONFIGURATION > > )
2013-06-19 15:56:04 +00:00
set ( targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>" )
set ( targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>" )
2022-04-27 14:45:20 +00:00
set ( targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:$<REMOVE_DUPLICATES:${targetincludes}>,\n-I>\n>" )
set ( targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:$<REMOVE_DUPLICATES:${targetdefines}>,\n-D>\n>" )
2013-06-19 15:56:04 +00:00
file ( GENERATE
O U T P U T $ { _ m o c _ p a r a m e t e r s _ f i l e }
C O N T E N T " $ { t a r g e t d e f i n e s } $ { t a r g e t i n c l u d e s } $ { _ m o c _ p a r a m e t e r s } \ n "
)
set ( targetincludes )
set ( targetdefines )
2011-12-19 21:17:02 +00:00
else ( )
2013-06-19 15:56:04 +00:00
file ( WRITE ${ _moc_parameters_file } "${_moc_parameters}\n" )
2011-12-19 21:17:02 +00:00
endif ( )
2013-06-19 15:56:04 +00:00
set ( _moc_extra_parameters_file @ ${ _moc_parameters_file } )
2021-09-17 13:03:55 +00:00
add_custom_command ( OUTPUT ${ outfile } ${ extra_output_files }
2019-02-12 09:02:15 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c $ { _ m o c _ e x t r a _ p a r a m e t e r s _ f i l e }
2015-01-19 06:18:39 +00:00
D E P E N D S $ { i n f i l e } $ { m o c _ d e p e n d s }
2013-06-19 15:56:04 +00:00
$ { _ m o c _ w o r k i n g _ d i r }
V E R B A T I M )
2017-09-29 20:17:10 +00:00
set_source_files_properties ( ${ infile } PROPERTIES SKIP_AUTOMOC ON )
set_source_files_properties ( ${ outfile } PROPERTIES SKIP_AUTOMOC ON )
set_source_files_properties ( ${ outfile } PROPERTIES SKIP_AUTOUIC ON )
2015-12-21 16:56:55 +00:00
endfunction ( )
2011-12-19 21:17:02 +00:00
2019-09-19 06:45:21 +00:00
function ( qt6_generate_moc infile outfile )
2011-12-19 21:17:02 +00:00
# get include dirs and flags
2020-10-14 11:20:55 +00:00
_qt_internal_get_moc_flags ( moc_flags )
2011-12-19 21:17:02 +00:00
get_filename_component ( abs_infile ${ infile } ABSOLUTE )
set ( _outfile "${outfile}" )
if ( NOT IS_ABSOLUTE "${outfile}" )
set ( _outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}" )
endif ( )
2013-06-19 15:56:04 +00:00
if ( "x${ARGV2}" STREQUAL "xTARGET" )
set ( moc_target ${ ARGV3 } )
endif ( )
2021-09-17 13:03:55 +00:00
_qt_internal_create_moc_command ( ${ abs_infile } ${ _outfile } "${moc_flags}" "" "${moc_target}"
" " # moc_depends
" " # out_json_file
)
2011-12-19 21:30:50 +00:00
endfunction ( )
2011-12-19 21:17:02 +00:00
2019-12-05 12:52:33 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_generate_moc )
2019-12-05 12:52:33 +00:00
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 5 )
qt5_generate_moc ( ${ ARGV } )
elseif ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
qt6_generate_moc ( ${ ARGV } )
endif ( )
2021-08-31 05:56:00 +00:00
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2011-12-19 21:17:02 +00:00
2019-08-23 09:39:30 +00:00
# qt6_wrap_cpp(outfiles inputfile ... )
2011-12-19 21:17:02 +00:00
2019-09-19 06:45:21 +00:00
function ( qt6_wrap_cpp outfiles )
2011-12-19 21:17:02 +00:00
# get include dirs
2020-10-14 11:20:55 +00:00
_qt_internal_get_moc_flags ( moc_flags )
2011-12-19 21:17:02 +00:00
set ( options )
2021-09-17 13:03:55 +00:00
set ( oneValueArgs
T A R G E T
_ _ Q T _ I N T E R N A L _ O U T P U T _ M O C _ J S O N _ F I L E S
)
2015-01-19 06:18:39 +00:00
set ( multiValueArgs OPTIONS DEPENDS )
2011-12-19 21:17:02 +00:00
cmake_parse_arguments ( _WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
set ( moc_files ${ _WRAP_CPP_UNPARSED_ARGUMENTS } )
set ( moc_options ${ _WRAP_CPP_OPTIONS } )
2013-06-19 15:56:04 +00:00
set ( moc_target ${ _WRAP_CPP_TARGET } )
2015-01-19 06:18:39 +00:00
set ( moc_depends ${ _WRAP_CPP_DEPENDS } )
2013-06-19 15:56:04 +00:00
2021-09-17 13:03:55 +00:00
set ( metatypes_json_list "" )
2011-12-19 21:17:02 +00:00
foreach ( it ${ moc_files } )
get_filename_component ( it ${ it } ABSOLUTE )
2020-10-14 11:20:55 +00:00
_qt_internal_make_output_file ( ${ it } moc_ cpp outfile )
2021-09-17 13:03:55 +00:00
set ( out_json_file_var "" )
if ( _WRAP_CPP___QT_INTERNAL_OUTPUT_MOC_JSON_FILES )
set ( out_json_file_var "out_json_file" )
endif ( )
2020-10-14 11:20:55 +00:00
_qt_internal_create_moc_command (
2021-09-17 13:03:55 +00:00
$ { i t } $ { o u t f i l e } " $ { m o c _ f l a g s } " " $ { m o c _ o p t i o n s } " " $ { m o c _ t a r g e t } " " $ { m o c _ d e p e n d s } "
" $ { o u t _ j s o n _ f i l e _ v a r } " )
2011-12-19 21:27:48 +00:00
list ( APPEND ${ outfiles } ${ outfile } )
2021-09-17 13:03:55 +00:00
if ( _WRAP_CPP___QT_INTERNAL_OUTPUT_MOC_JSON_FILES )
list ( APPEND metatypes_json_list "${${out_json_file_var}}" )
endif ( )
2011-12-19 21:17:02 +00:00
endforeach ( )
2011-12-19 21:30:50 +00:00
set ( ${ outfiles } ${ ${outfiles } } PARENT_SCOPE )
2021-09-17 13:03:55 +00:00
if ( metatypes_json_list )
set ( ${ _WRAP_CPP___QT_INTERNAL_OUTPUT_MOC_JSON_FILES }
" $ { m e t a t y p e s _ j s o n _ l i s t } " P A R E N T _ S C O P E )
endif ( )
2011-12-19 21:30:50 +00:00
endfunction ( )
2011-12-19 21:17:02 +00:00
2019-12-05 12:52:33 +00:00
# This will override the CMake upstream command, because that one is for Qt 3.
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_wrap_cpp outfiles )
2019-12-05 12:52:33 +00:00
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 5 )
2021-08-31 05:56:00 +00:00
qt5_wrap_cpp ( "${outfiles}" ${ ARGN } )
2019-12-05 12:52:33 +00:00
elseif ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
2021-08-31 05:56:00 +00:00
qt6_wrap_cpp ( "${outfiles}" ${ ARGN } )
2019-12-05 12:52:33 +00:00
endif ( )
2021-08-31 05:56:00 +00:00
set ( "${outfiles}" "${${outfiles}}" PARENT_SCOPE )
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2011-12-19 21:17:02 +00:00
2014-11-13 10:01:31 +00:00
2019-08-23 09:39:30 +00:00
# _qt6_parse_qrc_file(infile _out_depends _rc_depends)
2014-11-13 10:01:31 +00:00
# internal
2019-09-19 06:45:21 +00:00
function ( _qt6_parse_qrc_file infile _out_depends _rc_depends )
2014-11-13 10:01:31 +00:00
get_filename_component ( rc_path ${ infile } PATH )
if ( EXISTS "${infile}" )
# parse file for dependencies
# all files are absolute paths or relative to the location of the qrc file
file ( READ "${infile}" RC_FILE_CONTENTS )
string ( REGEX MATCHALL "<file[^<]+" RC_FILES "${RC_FILE_CONTENTS}" )
foreach ( RC_FILE ${ RC_FILES } )
string ( REGEX REPLACE "^<file[^>]*>" "" RC_FILE "${RC_FILE}" )
if ( NOT IS_ABSOLUTE "${RC_FILE}" )
set ( RC_FILE "${rc_path}/${RC_FILE}" )
endif ( )
set ( RC_DEPENDS ${ RC_DEPENDS } "${RC_FILE}" )
endforeach ( )
# Since this cmake macro is doing the dependency scanning for these files,
# let's make a configured file and add it as a dependency so cmake is run
# again when dependencies need to be recomputed.
2020-10-14 11:20:55 +00:00
_qt_internal_make_output_file ( "${infile}" "" "qrc.depends" out_depends )
2014-11-13 10:01:31 +00:00
configure_file ( "${infile}" "${out_depends}" COPYONLY )
else ( )
# The .qrc file does not exist (yet). Let's add a dependency and hope
# that it will be generated later
set ( out_depends )
endif ( )
set ( ${ _out_depends } ${ out_depends } PARENT_SCOPE )
set ( ${ _rc_depends } ${ RC_DEPENDS } PARENT_SCOPE )
endfunction ( )
2019-08-23 09:39:30 +00:00
# qt6_add_binary_resources(target inputfiles ... )
2014-11-13 10:01:31 +00:00
2019-09-19 06:45:21 +00:00
function ( qt6_add_binary_resources target )
2014-11-13 10:01:31 +00:00
set ( options )
set ( oneValueArgs DESTINATION )
set ( multiValueArgs OPTIONS )
cmake_parse_arguments ( _RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
set ( rcc_files ${ _RCC_UNPARSED_ARGUMENTS } )
set ( rcc_options ${ _RCC_OPTIONS } )
set ( rcc_destination ${ _RCC_DESTINATION } )
2022-03-01 11:28:26 +00:00
if ( NOT QT_FEATURE_zstd )
list ( APPEND rcc_options "--no-zstd" )
endif ( )
2014-11-13 10:01:31 +00:00
if ( NOT rcc_destination )
set ( rcc_destination ${ CMAKE_CURRENT_BINARY_DIR } / ${ target } .rcc )
endif ( )
foreach ( it ${ rcc_files } )
get_filename_component ( infile ${ it } ABSOLUTE )
2019-09-19 06:45:21 +00:00
_qt6_parse_qrc_file ( ${ infile } _out_depends _rc_depends )
2017-09-29 20:17:10 +00:00
set_source_files_properties ( ${ infile } PROPERTIES SKIP_AUTORCC ON )
2014-11-13 10:01:31 +00:00
set ( infiles ${ infiles } ${ infile } )
set ( out_depends ${ out_depends } ${ _out_depends } )
set ( rc_depends ${ rc_depends } ${ _rc_depends } )
endforeach ( )
add_custom_command ( OUTPUT ${ rcc_destination }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
2019-02-12 09:02:15 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
2014-11-13 10:01:31 +00:00
A R G S $ { r c c _ o p t i o n s } - - b i n a r y - - n a m e $ { t a r g e t } - - o u t p u t $ { r c c _ d e s t i n a t i o n } $ { i n f i l e s }
2020-01-31 13:44:52 +00:00
D E P E N D S
$ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
$ { r c _ d e p e n d s }
$ { o u t _ d e p e n d s }
$ { i n f i l e s }
V E R B A T I M )
2014-11-13 10:01:31 +00:00
add_custom_target ( ${ target } ALL DEPENDS ${ rcc_destination } )
endfunction ( )
2019-12-05 12:52:33 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_add_binary_resources )
2019-12-05 12:52:33 +00:00
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 5 )
qt5_add_binary_resources ( ${ ARGV } )
elseif ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
qt6_add_binary_resources ( ${ ARGV } )
endif ( )
2021-08-31 05:56:00 +00:00
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2014-11-13 10:01:31 +00:00
2019-08-23 09:39:30 +00:00
# qt6_add_resources(target resourcename ...
2019-08-19 14:19:08 +00:00
# or
2019-08-23 09:39:30 +00:00
# qt6_add_resources(outfiles inputfile ... )
2011-12-19 21:17:02 +00:00
2019-09-19 06:45:21 +00:00
function ( qt6_add_resources outfiles )
2019-08-19 14:19:08 +00:00
if ( TARGET ${ outfiles } )
2019-09-16 07:49:40 +00:00
cmake_parse_arguments ( arg "" "OUTPUT_TARGETS" "" ${ ARGN } )
2020-10-01 08:58:02 +00:00
_qt_internal_process_resource ( ${ ARGV } )
2019-09-16 07:49:40 +00:00
if ( arg_OUTPUT_TARGETS )
set ( ${ arg_OUTPUT_TARGETS } ${ ${arg_OUTPUT_TARGETS } } PARENT_SCOPE )
endif ( )
2019-08-19 14:19:08 +00:00
else ( )
set ( options )
set ( oneValueArgs )
set ( multiValueArgs OPTIONS )
2011-12-19 21:17:02 +00:00
2019-08-19 14:19:08 +00:00
cmake_parse_arguments ( _RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
2011-12-19 21:17:02 +00:00
2019-08-19 14:19:08 +00:00
set ( rcc_files ${ _RCC_UNPARSED_ARGUMENTS } )
set ( rcc_options ${ _RCC_OPTIONS } )
2011-12-19 21:17:02 +00:00
2019-08-19 14:19:08 +00:00
if ( "${rcc_options}" MATCHES "-binary" )
2019-08-23 09:39:30 +00:00
message ( WARNING "Use qt6_add_binary_resources for binary option" )
2019-08-19 14:19:08 +00:00
endif ( )
2011-12-19 21:17:02 +00:00
2022-03-01 11:28:26 +00:00
if ( NOT QT_FEATURE_zstd )
list ( APPEND rcc_options "--no-zstd" )
endif ( )
2019-08-19 14:19:08 +00:00
foreach ( it ${ rcc_files } )
get_filename_component ( outfilename ${ it } NAME_WE )
get_filename_component ( infile ${ it } ABSOLUTE )
set ( outfile ${ CMAKE_CURRENT_BINARY_DIR } /qrc_ ${ outfilename } .cpp )
2019-09-19 06:45:21 +00:00
_qt6_parse_qrc_file ( ${ infile } _out_depends _rc_depends )
2019-08-19 14:19:08 +00:00
set_source_files_properties ( ${ infile } PROPERTIES SKIP_AUTORCC ON )
add_custom_command ( OUTPUT ${ outfile }
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
A R G S $ { r c c _ o p t i o n s } - - n a m e $ { o u t f i l e n a m e } - - o u t p u t $ { o u t f i l e } $ { i n f i l e }
M A I N _ D E P E N D E N C Y $ { i n f i l e }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { _ r c _ d e p e n d s } " $ { _ o u t _ d e p e n d s } " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
V E R B A T I M )
2022-03-24 01:40:40 +00:00
set_source_files_properties ( ${ outfile } PROPERTIES SKIP_AUTOMOC ON
S K I P _ A U T O U I C O N
S K I P _ U N I T Y _ B U I L D _ I N C L U S I O N O N
2022-04-11 05:39:49 +00:00
S K I P _ P R E C O M P I L E _ H E A D E R S O N
2022-03-24 01:40:40 +00:00
)
2019-08-19 14:19:08 +00:00
list ( APPEND ${ outfiles } ${ outfile } )
endforeach ( )
set ( ${ outfiles } ${ ${outfiles } } PARENT_SCOPE )
2014-11-13 10:01:31 +00:00
endif ( )
2011-12-19 21:30:50 +00:00
endfunction ( )
2012-05-05 21:40:19 +00:00
2019-12-05 12:52:33 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_add_resources outfiles )
2019-12-05 12:52:33 +00:00
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 5 )
2021-08-31 05:56:00 +00:00
qt5_add_resources ( "${outfiles}" ${ ARGN } )
2019-12-05 12:52:33 +00:00
elseif ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
2021-08-31 05:56:00 +00:00
qt6_add_resources ( "${outfiles}" ${ ARGN } )
2019-12-05 12:52:33 +00:00
endif ( )
2021-09-06 01:18:06 +00:00
if ( TARGET ${ outfiles } )
cmake_parse_arguments ( PARSE_ARGV 1 arg "" "OUTPUT_TARGETS" "" )
if ( arg_OUTPUT_TARGETS )
set ( ${ arg_OUTPUT_TARGETS } ${ ${arg_OUTPUT_TARGETS } } PARENT_SCOPE )
endif ( )
else ( )
2021-08-31 05:56:00 +00:00
set ( "${outfiles}" "${${outfiles}}" PARENT_SCOPE )
endif ( )
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2019-08-23 09:39:30 +00:00
# qt6_add_big_resources(outfiles inputfile ... )
2018-05-18 10:19:38 +00:00
2019-09-19 06:45:21 +00:00
function ( qt6_add_big_resources outfiles )
2022-06-20 09:36:04 +00:00
if ( CMAKE_GENERATOR STREQUAL "Xcode" AND IOS )
message ( WARNING
" D u e t o C M a k e l i m i t a t i o n s , q t 6 _ a d d _ b i g _ r e s o u r c e s c a n ' t b e u s e d w h e n b u i l d i n g f o r i O S . "
" S e e h t t p s : / / b u g r e p o r t s . q t . i o / b r o w s e / Q T B U G - 1 0 3 4 9 7 f o r d e t a i l s . "
" F a l l i n g b a c k t o u s i n g q t 6 _ a d d _ r e s o u r c e s . "
" C o n s i d e r u s i n g q t 6 _ a d d _ r e s o u r c e s d i r e c t l y t o s i l e n c e t h i s w a r n i n g . "
)
qt6_add_resources ( ${ ARGV } )
set ( ${ outfiles } ${ ${outfiles } } PARENT_SCOPE )
return ( )
endif ( )
2019-05-20 09:37:27 +00:00
if ( CMAKE_VERSION VERSION_LESS 3.9 )
2019-08-23 09:39:30 +00:00
message ( FATAL_ERROR, "qt6_add_big_resources requires CMake 3.9 or newer" )
2019-05-20 09:37:27 +00:00
endif ( )
2018-05-18 10:19:38 +00:00
set ( options )
set ( oneValueArgs )
set ( multiValueArgs OPTIONS )
cmake_parse_arguments ( _RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
set ( rcc_files ${ _RCC_UNPARSED_ARGUMENTS } )
set ( rcc_options ${ _RCC_OPTIONS } )
if ( "${rcc_options}" MATCHES "-binary" )
2019-08-23 09:39:30 +00:00
message ( WARNING "Use qt6_add_binary_resources for binary option" )
2018-05-18 10:19:38 +00:00
endif ( )
2022-03-01 11:28:26 +00:00
if ( NOT QT_FEATURE_zstd )
list ( APPEND rcc_options "--no-zstd" )
endif ( )
2018-05-18 10:19:38 +00:00
foreach ( it ${ rcc_files } )
get_filename_component ( outfilename ${ it } NAME_WE )
2021-05-20 16:15:49 +00:00
# Provide unique targets and output file names
# in case we add multiple .qrc files with the same base name.
string ( MAKE_C_IDENTIFIER "_qt_big_resource_count_${outfilename}" prop )
get_property ( count GLOBAL PROPERTY ${ prop } )
if ( count )
string ( APPEND outfilename "_${count}" )
else ( )
set ( count 0 )
endif ( )
math ( EXPR count "${count} + 1" )
set_property ( GLOBAL PROPERTY ${ prop } ${ count } )
2018-05-18 10:19:38 +00:00
get_filename_component ( infile ${ it } ABSOLUTE )
set ( tmpoutfile ${ CMAKE_CURRENT_BINARY_DIR } /qrc_ ${ outfilename } tmp.cpp )
set ( outfile ${ CMAKE_CURRENT_BINARY_DIR } /qrc_ ${ outfilename } .o )
2019-09-19 06:45:21 +00:00
_qt6_parse_qrc_file ( ${ infile } _out_depends _rc_depends )
2021-05-20 11:22:28 +00:00
set_source_files_properties ( ${ infile } PROPERTIES SKIP_AUTOGEN ON )
2018-05-18 10:19:38 +00:00
add_custom_command ( OUTPUT ${ tmpoutfile }
2019-02-12 09:02:15 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c $ { r c c _ o p t i o n s } - - n a m e $ { o u t f i l e n a m e } - - p a s s 1 - - o u t p u t $ { t m p o u t f i l e } $ { i n f i l e }
2020-01-31 13:44:52 +00:00
D E P E N D S $ { i n f i l e } $ { _ r c _ d e p e n d s } " $ { o u t _ d e p e n d s } " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
2022-07-14 15:23:15 +00:00
C O M M E N T " R u n n i n g r c c p a s s 1 f o r r e s o u r c e $ { o u t f i l e n a m e } "
2020-01-31 13:44:52 +00:00
V E R B A T I M )
2018-05-18 10:19:38 +00:00
add_custom_target ( big_resources_ ${ outfilename } ALL DEPENDS ${ tmpoutfile } )
2022-07-14 15:23:15 +00:00
_qt_internal_add_rcc_pass2 (
R E S O U R C E _ N A M E $ { o u t f i l e n a m e }
R C C _ O P T I O N S $ { r c c _ o p t i o n s }
O B J E C T _ L I B r c c _ o b j e c t _ $ { o u t f i l e n a m e }
Q R C _ F I L E $ { i n f i l e }
P A S S 1 _ O U T P U T _ F I L E $ { t m p o u t f i l e }
O U T _ O B J E C T _ F I L E $ { o u t f i l e }
)
2018-05-18 10:19:38 +00:00
add_dependencies ( rcc_object_ ${ outfilename } big_resources_ ${ outfilename } )
2022-07-14 15:23:15 +00:00
list ( APPEND ${ outfiles } ${ outfile } )
2018-05-18 10:19:38 +00:00
endforeach ( )
set ( ${ outfiles } ${ ${outfiles } } PARENT_SCOPE )
endfunction ( )
2022-07-14 15:23:15 +00:00
function ( _qt_internal_add_rcc_pass2 )
set ( options )
set ( oneValueArgs
R E S O U R C E _ N A M E
O B J E C T _ L I B
Q R C _ F I L E
P A S S 1 _ O U T P U T _ F I L E
O U T _ O B J E C T _ F I L E
)
set ( multiValueArgs
R C C _ O P T I O N S
)
cmake_parse_arguments ( arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
add_library ( ${ arg_OBJECT_LIB } OBJECT ${ arg_PASS1_OUTPUT_FILE } )
_qt_internal_set_up_static_runtime_library ( ${ arg_OBJECT_LIB } )
target_compile_definitions ( ${ arg_OBJECT_LIB } PUBLIC
" $ < T A R G E T _ P R O P E R T Y : Q t 6 : : C o r e , I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S > " )
set_target_properties ( ${ arg_OBJECT_LIB } PROPERTIES
A U T O M O C O F F
A U T O U I C O F F )
# The modification of TARGET_OBJECTS needs the following change in cmake
# https://gitlab.kitware.com/cmake/cmake/commit/93c89bc75ceee599ba7c08b8fe1ac5104942054f
add_custom_command (
O U T P U T $ { a r g _ O U T _ O B J E C T _ F I L E }
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
$ { a r g _ R C C _ O P T I O N S } - - n a m e $ { a r g _ R E S O U R C E _ N A M E } - - p a s s 2
- - t e m p $ < T A R G E T _ O B J E C T S : $ { a r g _ O B J E C T _ L I B } >
- - o u t p u t $ { a r g _ O U T _ O B J E C T _ F I L E } $ { a r g _ Q R C _ F I L E }
D E P E N D S $ { a r g _ O B J E C T _ L I B } $ < T A R G E T _ O B J E C T S : $ { a r g _ O B J E C T _ L I B } >
$ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c
C O M M E N T " R u n n i n g r c c p a s s 2 f o r r e s o u r c e $ { a r g _ R E S O U R C E _ N A M E } "
V E R B A T I M )
endfunction ( )
2019-12-05 12:52:33 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_add_big_resources outfiles )
2019-12-05 12:52:33 +00:00
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 5 )
2021-08-31 05:56:00 +00:00
qt5_add_big_resources ( ${ outfiles } ${ ARGN } )
2019-12-05 12:52:33 +00:00
elseif ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
2021-08-31 05:56:00 +00:00
qt6_add_big_resources ( ${ outfiles } ${ ARGN } )
2019-12-05 12:52:33 +00:00
endif ( )
2021-08-31 05:56:00 +00:00
set ( "${outfiles}" "${${outfiles}}" PARENT_SCOPE )
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2021-03-23 04:48:56 +00:00
function ( _qt_internal_apply_win_prefix_and_suffix target )
if ( WIN32 )
# Table of prefix / suffixes for MSVC libraries as qmake expects them to be created.
# static - Qt6EdidSupport.lib (platform support libraries / or static QtCore, etc)
# shared - Qt6Core.dll
# shared import library - Qt6Core.lib
# module aka Qt plugin - qwindows.dll
# module import library - qwindows.lib
#
# The CMake defaults are fine for us.
# Table of prefix / suffixes for MinGW libraries as qmake expects them to be created.
# static - libQt6EdidSupport.a (platform support libraries / or static QtCore, etc)
# shared - Qt6Core.dll
# shared import library - libQt6Core.a
# module aka Qt plugin - qwindows.dll
# module import library - libqwindows.a
#
# CMake for Windows-GNU platforms defaults the prefix to "lib".
# CMake for Windows-GNU platforms defaults the import suffix to ".dll.a".
# These CMake defaults are not ok for us.
# This should cover both MINGW with GCC and CLANG.
if ( NOT MSVC )
set_property ( TARGET "${target}" PROPERTY IMPORT_SUFFIX ".a" )
get_target_property ( target_type ${ target } TYPE )
if ( target_type STREQUAL "STATIC_LIBRARY" )
set_property ( TARGET "${target}" PROPERTY PREFIX "lib" )
else ( )
set_property ( TARGET "${target}" PROPERTY PREFIX "" )
set_property ( TARGET "${target}" PROPERTY IMPORT_PREFIX "lib" )
endif ( )
endif ( )
endif ( )
endfunction ( )
2020-01-22 12:47:08 +00:00
set ( _Qt6_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/.." )
2018-06-14 12:50:39 +00:00
2020-10-14 11:20:55 +00:00
# This function is currently in Technical Preview.
# It's signature and behavior might change.
#
# Wrapper function that adds an executable with some Qt specific behavior.
2020-12-08 11:00:22 +00:00
# Some scenarios require steps to be deferred to the end of the current
# directory scope so that the caller has an opportunity to modify certain
# target properties.
2020-10-15 15:58:15 +00:00
function ( qt6_add_executable target )
2020-12-08 11:00:22 +00:00
cmake_parse_arguments ( PARSE_ARGV 1 arg "MANUAL_FINALIZATION" "" "" )
_qt_internal_create_executable ( "${target}" ${ arg_UNPARSED_ARGUMENTS } )
2021-09-16 08:13:25 +00:00
target_link_libraries ( "${target}" PRIVATE Qt6::Core )
2020-12-08 11:00:22 +00:00
if ( arg_MANUAL_FINALIZATION )
2021-05-18 17:42:55 +00:00
# Caller says they will call qt6_finalize_target() themselves later
2020-12-08 11:00:22 +00:00
return ( )
endif ( )
# Defer the finalization if we can. When the caller's project requires
# CMake 3.19 or later, this makes the calls to this function concise while
# still allowing target property modification before finalization.
if ( CMAKE_VERSION VERSION_GREATER_EQUAL 3.19 )
# Need to wrap in an EVAL CODE or else ${target} won't be evaluated
# due to special behavior of cmake_language() argument handling
2021-05-18 17:42:55 +00:00
cmake_language ( EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})" )
2020-12-08 11:00:22 +00:00
else ( )
2021-04-28 14:27:19 +00:00
set_target_properties ( "${target}" PROPERTIES _qt_is_immediately_finalized TRUE )
2021-05-18 17:42:55 +00:00
qt6_finalize_target ( "${target}" )
2020-12-08 11:00:22 +00:00
endif ( )
endfunction ( )
function ( _qt_internal_create_executable target )
2019-06-12 08:21:40 +00:00
if ( ANDROID )
2021-12-17 12:02:04 +00:00
list ( REMOVE_ITEM ARGN "WIN32" "MACOSX_BUNDLE" )
add_library ( "${target}" MODULE ${ ARGN } )
2019-06-26 14:19:13 +00:00
# On our qmake builds we do don't compile the executables with
# visibility=hidden. Not having this flag set will cause the
# executable to have main() hidden and can then no longer be loaded
# through dlopen()
set_property ( TARGET "${target}" PROPERTY C_VISIBILITY_PRESET default )
set_property ( TARGET "${target}" PROPERTY CXX_VISIBILITY_PRESET default )
2020-06-24 16:19:15 +00:00
set_property ( TARGET "${target}" PROPERTY OBJC_VISIBILITY_PRESET default )
set_property ( TARGET "${target}" PROPERTY OBJCXX_VISIBILITY_PRESET default )
2020-10-26 12:47:49 +00:00
qt6_android_apply_arch_suffix ( "${target}" )
2021-05-25 14:34:16 +00:00
set_property ( TARGET "${target}" PROPERTY _qt_is_android_executable TRUE )
2019-06-12 08:21:40 +00:00
else ( )
2021-12-17 12:02:04 +00:00
add_executable ( "${target}" ${ ARGN } )
2019-06-12 08:21:40 +00:00
endif ( )
2020-12-08 11:00:22 +00:00
2021-07-29 09:53:03 +00:00
_qt_internal_set_up_static_runtime_library ( "${target}" )
2020-12-08 11:00:22 +00:00
endfunction ( )
2020-02-21 15:32:13 +00:00
2021-05-18 17:42:55 +00:00
function ( _qt_internal_finalize_executable target )
2021-04-28 14:27:19 +00:00
get_target_property ( is_finalized "${target}" _qt_executable_is_finalized )
if ( is_finalized )
message ( AUTHOR_WARNING
2021-05-18 17:42:55 +00:00
" T r i e d t o c a l l q t 6 _ f i n a l i z e _ t a r g e t t w i c e o n e x e c u t a b l e : ' $ { t a r g e t } ' . \
2021-04-28 14:27:19 +00:00
D i d y o u f o r g e t t o s p e c i f y M A N U A L _ F I N A L I Z A T I O N t o q t 6 _ a d d _ e x e c u t a b l e ? " )
return ( )
endif ( )
2021-02-15 07:59:08 +00:00
# We can't evaluate generator expressions at configure time, so we can't
# ask for any transitive properties or even the full library dependency
2021-05-04 07:09:47 +00:00
# chain.
# We can still look at the immediate dependencies
# (and recursively their dependencies) and query
2021-02-15 07:59:08 +00:00
# any that are not expressed as generator expressions. For any we can
# identify as a CMake target known to the current scope, we can check if
# that target has a finalizer to be called. This is expected to cover the
# vast majority of use cases, since projects will typically link directly
# to Qt::* targets. For the cases where this isn't so, the project will be
# responsible for calling any relevant functions themselves instead of
# relying on these automatic finalization calls.
set ( finalizers )
2021-05-04 07:09:47 +00:00
__qt_internal_collect_all_target_dependencies ( "${target}" dep_targets )
if ( dep_targets )
foreach ( dep IN LISTS dep_targets )
2021-02-15 07:59:08 +00:00
get_target_property ( dep_finalizers ${ dep }
I N T E R F A C E _ Q T _ E X E C U T A B L E _ F I N A L I Z E R S
)
if ( dep_finalizers )
list ( APPEND finalizers ${ dep_finalizers } )
endif ( )
endforeach ( )
list ( REMOVE_DUPLICATES finalizers )
endif ( )
2021-05-04 07:09:47 +00:00
2021-02-15 07:59:08 +00:00
if ( finalizers )
if ( CMAKE_VERSION VERSION_LESS 3.18 )
2021-11-30 01:10:19 +00:00
# cmake_language() not available, fall back to the slower method of
# writing a file and including it
set ( contents "" )
foreach ( finalizer_func IN LISTS finalizers )
string ( APPEND contents "${finalizer_func}(${target})\n" )
endforeach ( )
set ( finalizer_file "${CMAKE_CURRENT_BINARY_DIR}/.qt/finalize_${target}.cmake" )
file ( WRITE ${ finalizer_file } "${contents}" )
include ( ${ finalizer_file } )
2021-02-15 07:59:08 +00:00
else ( )
foreach ( finalizer_func IN LISTS finalizers )
cmake_language ( CALL ${ finalizer_func } ${ target } )
endforeach ( )
endif ( )
endif ( )
2020-09-03 08:29:41 +00:00
if ( EMSCRIPTEN )
2021-08-04 07:44:55 +00:00
_qt_internal_wasm_add_target_helpers ( "${target}" )
2020-09-03 08:29:41 +00:00
endif ( )
2021-04-14 16:16:44 +00:00
if ( IOS )
2021-06-17 14:00:08 +00:00
_qt_internal_finalize_ios_app ( "${target}" )
2021-11-29 23:29:34 +00:00
elseif ( APPLE )
_qt_internal_finalize_macos_app ( "${target}" )
2021-04-14 16:16:44 +00:00
endif ( )
2021-04-28 14:27:19 +00:00
# For finalizer mode of plugin importing to work safely, we need to know the list of Qt
# dependencies the target has, but those might be added later than the qt_add_executable call.
# Most of our examples are like that. Only enable finalizer mode when we are sure that the user
2021-05-26 15:19:08 +00:00
# manually called qt_finalize_target at the end of their CMake project, or it was automatically
2021-06-10 17:01:35 +00:00
# done via a deferred call. This is also applicable to the resource object finalizer.
2021-04-28 14:27:19 +00:00
get_target_property ( is_immediately_finalized "${target}" _qt_is_immediately_finalized )
if ( NOT is_immediately_finalized )
__qt_internal_apply_plugin_imports_finalizer_mode ( "${target}" )
2021-06-15 11:09:57 +00:00
__qt_internal_process_dependency_object_libraries ( "${target}" )
2021-04-28 14:27:19 +00:00
endif ( )
set_target_properties ( ${ target } PROPERTIES _qt_executable_is_finalized TRUE )
2021-04-14 16:16:44 +00:00
endfunction ( )
2021-09-13 05:54:00 +00:00
# If a task needs to run before any targets are finalized in the current directory
# scope, call this function and pass the ID of that task as the argument.
function ( _qt_internal_delay_finalization_until_after defer_id )
set_property ( DIRECTORY APPEND PROPERTY qt_internal_finalizers_wait_for_ids "${defer_id}" )
endfunction ( )
2021-05-18 17:42:55 +00:00
function ( qt6_finalize_target target )
2021-09-13 05:54:00 +00:00
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.19" )
cmake_language ( DEFER GET_CALL_IDS ids_queued )
get_directory_property ( wait_for_ids qt_internal_finalizers_wait_for_ids )
while ( wait_for_ids )
list ( GET wait_for_ids 0 id_to_wait_for )
if ( id_to_wait_for IN_LIST ids_queued )
# Something else needs to run before we finalize targets.
# Try again later by re-deferring ourselves, which effectively
# puts us at the end of the current list of deferred actions.
cmake_language ( EVAL CODE "cmake_language(DEFER CALL ${CMAKE_CURRENT_FUNCTION} ${ARGV})" )
set_directory_properties ( PROPERTIES
q t _ i n t e r n a l _ f i n a l i z e r s _ w a i t _ f o r _ i d s " $ { w a i t _ f o r _ i d s } "
)
return ( )
endif ( )
list ( POP_FRONT wait_for_ids )
endwhile ( )
# No other deferred tasks to wait for
set_directory_properties ( PROPERTIES qt_internal_finalizers_wait_for_ids "" )
endif ( )
2021-05-18 17:42:55 +00:00
if ( NOT TARGET "${target}" )
message ( FATAL_ERROR "No target '${target}' found in current scope." )
endif ( )
get_target_property ( target_type ${ target } TYPE )
2021-05-25 14:34:16 +00:00
get_target_property ( is_android_executable "${target}" _qt_is_android_executable )
if ( target_type STREQUAL "EXECUTABLE" OR is_android_executable )
2021-05-18 17:42:55 +00:00
_qt_internal_finalize_executable ( ${ ARGV } )
endif ( )
endfunction ( )
2021-07-15 14:20:20 +00:00
function ( _qt_internal_handle_ios_launch_screen target )
# Check if user provided a launch screen path via a variable.
set ( launch_screen "" )
2022-07-06 15:19:52 +00:00
# Check if the project provided a launch screen path via a variable.
2021-07-15 14:20:20 +00:00
# This variable is currently in Technical Preview.
if ( QT_IOS_LAUNCH_SCREEN )
set ( launch_screen "${QT_IOS_LAUNCH_SCREEN}" )
endif ( )
2022-07-06 15:19:52 +00:00
# Check if the project provided a launch screen path via a target property, it takes precedence
# over the variable.
# This property is currently in Technical Preview.
get_target_property ( launch_screen_from_prop "${target}" QT_IOS_LAUNCH_SCREEN )
if ( launch_screen_from_prop )
set ( launch_screen "${launch_screen_from_prop}" )
2021-07-15 14:20:20 +00:00
endif ( )
2022-07-06 15:19:52 +00:00
# If the project hasn't provided a launch screen file path, use a copy of the template
# that qmake uses.
# It needs to be a copy because configure_file can't handle all the escaped double quotes
# present in the qmake template file.
set ( is_default_launch_screen FALSE )
if ( NOT launch_screen AND NOT QT_NO_SET_DEFAULT_IOS_LAUNCH_SCREEN )
set ( is_default_launch_screen TRUE )
2021-07-15 14:20:20 +00:00
set ( launch_screen
2022-07-06 15:19:52 +00:00
" $ { _ _ q t _ i n t e r n a l _ c m a k e _ i o s _ s u p p o r t _ f i l e s _ p a t h } / L a u n c h S c r e e n . s t o r y b o a r d " )
2021-07-15 14:20:20 +00:00
endif ( )
2022-07-06 15:19:52 +00:00
# Check that the launch screen exists.
2021-07-15 14:20:20 +00:00
if ( launch_screen )
if ( NOT IS_ABSOLUTE "${launch_screen}" )
message ( FATAL_ERROR
" P r o v i d e d l a u n c h s c r e e n v a l u e s h o u l d b e a n a b s o l u t e p a t h : ' $ { l a u n c h _ s c r e e n } ' " )
endif ( )
if ( NOT EXISTS "${launch_screen}" )
message ( FATAL_ERROR
" P r o v i d e d l a u n c h s c r e e n f i l e d o e s n o t e x i s t : ' $ { l a u n c h _ s c r e e n } ' " )
endif ( )
endif ( )
if ( launch_screen AND NOT QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE )
2022-07-06 15:19:52 +00:00
get_filename_component ( launch_screen_name "${launch_screen}" NAME )
2021-07-15 14:20:20 +00:00
2022-07-06 15:19:52 +00:00
# Make a copy of the default launch screen template for this target and replace the
# label inside the template with the target name.
if ( is_default_launch_screen )
# Configure our default template and place it in the build dir.
set ( launch_screen_in_path "${launch_screen}" )
2021-07-15 14:20:20 +00:00
2022-07-06 15:19:52 +00:00
string ( MAKE_C_IDENTIFIER "${target}" target_identifier )
set ( launch_screen_out_dir
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / . q t / l a u n c h _ s c r e e n _ s t o r y b o a r d s / $ { t a r g e t _ i d e n t i f i e r } " )
2021-07-15 14:20:20 +00:00
2022-07-06 15:19:52 +00:00
set ( launch_screen_out_path
" $ { l a u n c h _ s c r e e n _ o u t _ d i r } / $ { l a u n c h _ s c r e e n _ n a m e } " )
2021-07-15 14:20:20 +00:00
2022-07-06 15:19:52 +00:00
file ( MAKE_DIRECTORY "${launch_screen_out_dir}" )
2021-07-15 14:20:20 +00:00
2022-07-06 15:19:52 +00:00
# Replaces the value in the default template.
set ( QT_IOS_LAUNCH_SCREEN_TEXT "${target}" )
configure_file (
" $ { l a u n c h _ s c r e e n _ i n _ p a t h } "
" $ { l a u n c h _ s c r e e n _ o u t _ p a t h } "
@ O N L Y
)
2021-07-15 14:20:20 +00:00
2022-07-06 15:19:52 +00:00
set ( final_launch_screen_path "${launch_screen_out_path}" )
else ( )
set ( final_launch_screen_path "${launch_screen}" )
endif ( )
# Add the launch screen storyboard file as a source file, otherwise CMake doesn't consider
# it as a resource file and MACOSX_PACKAGE_LOCATION processing will be skipped.
target_sources ( "${target}" PRIVATE "${final_launch_screen_path}" )
# Ensure Xcode compiles the storyboard file and installs the compiled storyboard .nib files
# into the app bundle.
# We use target_sources and the MACOSX_PACKAGE_LOCATION source file property for that
# instead of the RESOURCE target property, becaues the latter could potentially end up
# needlessly installing the source storyboard file.
#
# We can't rely on policy CMP0118 since user project controls it.
set ( scope_args )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
set ( scope_args TARGET_DIRECTORY ${ target } )
endif ( )
set_source_files_properties ( "${final_launch_screen_path}" ${ scope_args }
P R O P E R T I E S M A C O S X _ P A C K A G E _ L O C A T I O N R e s o u r c e s )
# Save the launch screen name, so its value is added as an UILaunchStoryboardName entry
# in the Qt generated Info.plist file.
set_target_properties ( "${target}" PROPERTIES
_ q t _ i o s _ l a u n c h _ s c r e e n _ n a m e " $ { l a u n c h _ s c r e e n _ n a m e } "
_ q t _ i o s _ l a u n c h _ s c r e e n _ p a t h " $ { f i n a l _ l a u n c h _ s c r e e n _ p a t h } " )
2021-07-15 14:20:20 +00:00
endif ( )
endfunction ( )
2021-04-14 16:16:44 +00:00
function ( _qt_internal_find_ios_development_team_id out_var )
get_property ( team_id GLOBAL PROPERTY _qt_internal_ios_development_team_id )
get_property ( team_id_computed GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed )
if ( team_id_computed )
# Just in case if the value is non-empty but still booly FALSE.
if ( NOT team_id )
set ( team_id "" )
endif ( )
set ( "${out_var}" "${team_id}" PARENT_SCOPE )
return ( )
endif ( )
set_property ( GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed "TRUE" )
set ( home_dir "$ENV{HOME}" )
set ( xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist" )
# Extract the first account name (email) from the user's Xcode preferences
message ( DEBUG "Trying to extract an Xcode development team id from '${xcode_preferences_path}'" )
execute_process ( COMMAND "/usr/libexec/PlistBuddy"
- x - c " p r i n t I D E P r o v i s i o n i n g T e a m s " " $ { x c o d e _ p r e f e r e n c e s _ p a t h } "
O U T P U T _ V A R I A B L E t e a m s _ x m l
E R R O R _ V A R I A B L E p l i s t _ e r r o r )
2022-05-05 12:39:10 +00:00
# Parsing state.
set ( is_free "" )
set ( current_team_id "" )
set ( parsing_is_free FALSE )
set ( parsing_team_id FALSE )
set ( first_team_id "" )
# Parse the xml output and return the first encountered non-free team id. If no non-free team id
# is found, return the first encountered free team id.
# If no team is found, return an empty string.
#
# Example input:
#<plist version="1.0">
#<dict>
# <key>marty@planet.local</key>
# <array>
# <dict>
# <key>isFreeProvisioningTeam</key>
# <false/>
# <key>teamID</key>
# <string>AAA</string>
# ...
# </dict>
# <dict>
# <key>isFreeProvisioningTeam</key>
# <true/>
# <key>teamID</key>
# <string>BBB</string>
# ...
# </dict>
# </array>
#</dict>
#</plist>
2021-04-14 16:16:44 +00:00
if ( teams_xml AND NOT plist_error )
string ( REPLACE "\n" ";" teams_xml_lines "${teams_xml}" )
2022-05-05 12:39:10 +00:00
2021-04-14 16:16:44 +00:00
foreach ( xml_line ${ teams_xml_lines } )
2022-05-05 12:39:10 +00:00
string ( STRIP "${xml_line}" xml_line )
if ( xml_line STREQUAL "<dict>" )
# Clean any previously found values when a new team dict is matched.
set ( is_free "" )
set ( current_team_id "" )
elseif ( xml_line STREQUAL "<key>isFreeProvisioningTeam</key>" )
set ( parsing_is_free TRUE )
elseif ( parsing_is_free )
set ( parsing_is_free FALSE )
if ( xml_line MATCHES "true" )
set ( is_free TRUE )
else ( )
set ( is_free FALSE )
endif ( )
elseif ( xml_line STREQUAL "<key>teamID</key>" )
set ( parsing_team_id TRUE )
elseif ( parsing_team_id )
set ( parsing_team_id FALSE )
if ( xml_line MATCHES "<string>([^<]+)</string>" )
set ( current_team_id "${CMAKE_MATCH_1}" )
else ( )
continue ( )
endif ( )
string ( STRIP "${current_team_id}" current_team_id )
# If this is the first team id we found so far, remember that, regardless if's free
# or not.
if ( NOT first_team_id AND current_team_id )
set ( first_team_id "${current_team_id}" )
endif ( )
# Break early if we found a non-free team id and use it, because we prefer
# a non-free team for signing, just like qmake.
if ( NOT is_free AND current_team_id )
set ( first_team_id "${current_team_id}" )
break ( )
endif ( )
2021-04-14 16:16:44 +00:00
endif ( )
endforeach ( )
endif ( )
2022-05-05 12:39:10 +00:00
if ( NOT first_team_id )
2021-04-14 16:16:44 +00:00
message ( DEBUG "Failed to extract an Xcode development team id." )
2021-09-06 01:18:06 +00:00
set ( "${out_var}" "" PARENT_SCOPE )
2022-05-05 12:39:10 +00:00
else ( )
message ( DEBUG "Successfully extracted the first encountered Xcode development team id." )
set_property ( GLOBAL PROPERTY _qt_internal_ios_development_team_id "${first_team_id}" )
set ( "${out_var}" "${first_team_id}" PARENT_SCOPE )
2021-04-14 16:16:44 +00:00
endif ( )
endfunction ( )
function ( _qt_internal_get_ios_bundle_identifier_prefix out_var )
get_property ( prefix GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix )
get_property ( prefix_computed GLOBAL PROPERTY
_ q t _ i n t e r n a l _ i o s _ b u n d l e _ i d e n t i f i e r _ p r e f i x _ c o m p u t e d )
if ( prefix_computed )
# Just in case if the value is non-empty but still booly FALSE.
if ( NOT prefix )
set ( prefix "" )
endif ( )
set ( "${out_var}" "${prefix}" PARENT_SCOPE )
return ( )
endif ( )
set_property ( GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix_computed "TRUE" )
set ( home_dir "$ENV{HOME}" )
set ( xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist" )
message ( DEBUG "Trying to extract the default bundle identifier prefix from Xcode preferences." )
execute_process ( COMMAND "/usr/libexec/PlistBuddy"
- c " p r i n t I D E T e m p l a t e O p t i o n s : b u n d l e I d e n t i f i e r P r e f i x "
" $ { x c o d e _ p r e f e r e n c e s _ p a t h } "
O U T P U T _ V A R I A B L E p r e f i x
E R R O R _ V A R I A B L E p r e f i x _ e r r o r )
if ( prefix AND NOT prefix_error )
2022-06-10 14:41:59 +00:00
message ( DEBUG "Successfully extracted the default bundle identifier prefix." )
2021-04-14 16:16:44 +00:00
string ( STRIP "${prefix}" prefix )
else ( )
2022-06-10 14:41:59 +00:00
message ( DEBUG "Failed to extract the default bundle identifier prefix." )
2021-04-14 16:16:44 +00:00
endif ( )
2021-08-20 12:27:25 +00:00
if ( prefix AND NOT prefix_error )
2021-04-14 16:16:44 +00:00
set_property ( GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix "${prefix}" )
set ( "${out_var}" "${prefix}" PARENT_SCOPE )
2021-09-06 01:18:06 +00:00
else ( )
set ( "${out_var}" "" PARENT_SCOPE )
2021-04-14 16:16:44 +00:00
endif ( )
endfunction ( )
2022-05-11 11:34:02 +00:00
function ( _qt_internal_escape_rfc_1034_identifier value out_var )
# According to https://datatracker.ietf.org/doc/html/rfc1034#section-3.5
# we can only use letters, digits, dot (.) and hyphens (-).
# Underscores are not allowed.
string ( REGEX REPLACE "[^A-Za-z0-9.]" "-" value "${value}" )
set ( "${out_var}" "${value}" PARENT_SCOPE )
endfunction ( )
2021-04-14 16:16:44 +00:00
function ( _qt_internal_get_default_ios_bundle_identifier out_var )
_qt_internal_get_ios_bundle_identifier_prefix ( prefix )
if ( NOT prefix )
set ( prefix "com.yourcompany" )
2022-05-13 12:34:36 +00:00
# For a better out-of-the-box experience, try to create a unique prefix by appending
# the sha1 of the team id, if one is found.
_qt_internal_find_ios_development_team_id ( team_id )
if ( team_id )
string ( SHA1 hash "${team_id}" )
string ( SUBSTRING "${hash}" 0 8 infix )
string ( APPEND prefix ".${infix}" )
else ( )
message ( WARNING
" N o o r g a n i z a t i o n b u n d l e i d e n t i f i e r p r e f i x c o u l d b e r e t r i e v e d f r o m X c o d e "
" p r e f e r e n c e s . T h i s c a n l e a d t o c o d e s i g n i n g i s s u e s d u e t o a n o n - u n i q u e b u n d l e "
" i d e n t i f i e r . P l e a s e s e t u p a n o r g a n i z a t i o n p r e f i x b y c r e a t i n g a n e w p r o j e c t w i t h i n "
" X c o d e , o r c o n s i d e r p r o v i d i n g a c u s t o m b u n d l e i d e n t i f i e r b y s p e c i f y i n g t h e "
" X C O D E _ A T T R I B U T E _ P R O D U C T _ B U N D L E _ I D E N T I F I E R p r o p e r t y . "
)
endif ( )
2021-04-14 16:16:44 +00:00
endif ( )
2022-05-11 11:34:02 +00:00
# Escape the prefix according to rfc 1034, it's important for code-signing. If an invalid
# identifier is used, calling xcodebuild on the command line says that no provisioning profile
# could be found, with no additional error message. If one opens the generated project with
# Xcode and clicks on 'Try again' to get a new profile, it shows a semi-useful error message
# that the identifier is invalid.
_qt_internal_escape_rfc_1034_identifier ( "${prefix}" prefix )
set ( identifier "${prefix}.\${PRODUCT_NAME:rfc1034identifier}" )
set ( "${out_var}" "${identifier}" PARENT_SCOPE )
2021-04-14 16:16:44 +00:00
endfunction ( )
2021-08-17 09:21:01 +00:00
function ( _qt_internal_set_placeholder_apple_bundle_version target )
# If user hasn't provided neither a bundle version nor a bundle short version string for the
# app, set a placeholder value for both which will add them to the generated Info.plist file.
# This is required so that the app launches in the simulator (but apparently not for running
# on-device).
get_target_property ( bundle_version "${target}" MACOSX_BUNDLE_BUNDLE_VERSION )
get_target_property ( bundle_short_version "${target}" MACOSX_BUNDLE_SHORT_VERSION_STRING )
if ( NOT MACOSX_BUNDLE_BUNDLE_VERSION AND
N O T M A C O S X _ B U N D L E _ S H O R T _ V E R S I O N _ S T R I N G A N D
N O T b u n d l e _ v e r s i o n A N D
N O T b u n d l e _ s h o r t _ v e r s i o n A N D
N O T Q T _ N O _ S E T _ X C O D E _ B U N D L E _ V E R S I O N
2022-07-14 11:00:02 +00:00
)
2022-07-14 11:48:45 +00:00
get_target_property ( version "${target}" VERSION )
if ( NOT version )
set ( version "${PROJECT_VERSION}" )
if ( NOT version )
set ( version "1.0.0" )
endif ( )
endif ( )
# Use x.y for short version and x.y.z for full version
# Any versions longer than this will fail App Store
# submission.
string ( REPLACE "." ";" version_list ${ version } )
list ( LENGTH version_list version_list_length )
list ( GET version_list 0 version_major )
set ( bundle_short_version "${version_major}" )
if ( version_list_length GREATER 1 )
list ( GET version_list 1 version_minor )
string ( APPEND bundle_short_version ".${version_minor}" )
endif ( )
set ( bundle_version "${bundle_short_version}" )
if ( version_list_length GREATER 2 )
list ( GET version_list 2 version_patch )
string ( APPEND bundle_version ".${version_patch}" )
endif ( )
2022-07-14 11:00:02 +00:00
if ( NOT CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION
A N D N O T Q T _ N O _ S E T _ X C O D E _ A T T R I B U T E _ M A R K E T I N G _ V E R S I O N
A N D N O T C M A K E _ X C O D E _ A T T R I B U T E _ C U R R E N T _ P R O J E C T _ V E R S I O N
A N D N O T Q T _ N O _ S E T _ X C O D E _ A T T R I B U T E _ C U R R E N T _ P R O J E C T _ V E R S I O N )
get_target_property ( marketing_version "${target}"
X C O D E _ A T T R I B U T E _ M A R K E T I N G _ V E R S I O N )
get_target_property ( current_project_version "${target}"
X C O D E _ A T T R I B U T E _ C U R R E N T _ P R O J E C T _ V E R S I O N )
if ( NOT marketing_version AND NOT current_project_version )
set_target_properties ( "${target}"
P R O P E R T I E S
X C O D E _ A T T R I B U T E _ C U R R E N T _ P R O J E C T _ V E R S I O N " $ { b u n d l e _ v e r s i o n } "
X C O D E _ A T T R I B U T E _ M A R K E T I N G _ V E R S I O N " $ { b u n d l e _ s h o r t _ v e r s i o n } "
)
set ( bundle_version "$(CURRENT_PROJECT_VERSION)" )
set ( bundle_short_version "$(MARKETING_VERSION)" )
endif ( )
endif ( )
set_target_properties ( "${target}"
2021-08-17 09:21:01 +00:00
P R O P E R T I E S
M A C O S X _ B U N D L E _ B U N D L E _ V E R S I O N " $ { b u n d l e _ v e r s i o n } "
M A C O S X _ B U N D L E _ S H O R T _ V E R S I O N _ S T R I N G " $ { b u n d l e _ s h o r t _ v e r s i o n } "
)
endif ( )
endfunction ( )
2022-05-04 13:59:24 +00:00
function ( _qt_internal_set_xcode_development_team_id target )
2021-04-14 16:16:44 +00:00
# If user hasn't provided a development team id, try to find the first one specified
# in the Xcode preferences.
if ( NOT CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM AND NOT QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID )
get_target_property ( existing_team_id "${target}" XCODE_ATTRIBUTE_DEVELOPMENT_TEAM )
if ( NOT existing_team_id )
_qt_internal_find_ios_development_team_id ( team_id )
set_target_properties ( "${target}"
P R O P E R T I E S X C O D E _ A T T R I B U T E _ D E V E L O P M E N T _ T E A M " $ { t e a m _ i d } " )
endif ( )
endif ( )
2022-05-04 13:59:24 +00:00
endfunction ( )
2021-04-14 16:16:44 +00:00
2022-05-04 13:59:24 +00:00
function ( _qt_internal_set_xcode_bundle_identifier target )
2022-05-11 11:34:02 +00:00
# Skip all logic if requested.
if ( QT_NO_SET_XCODE_BUNDLE_IDENTIFIER )
return ( )
2021-04-14 16:16:44 +00:00
endif ( )
2022-05-11 11:34:02 +00:00
# There are two fields to consider: the CFBundleIdentifier key (CFBI) to be written to
# Info.plist
# and the PRODUCT_BUNDLE_IDENTIFIER (PBI) property to set in the Xcode project.
# The following logic enables the best out-of-the-box experience combined with maximum
# customization.
# 1) If values for both fields are not provided, assign ${PRODUCT_BUNDLE_IDENTIFIER} to CFBI
# (which is expanded by xcodebuild at build time and will use the value of PBI) and
# auto-compute a default PBI from Xcode's ${PRODUCT_NAME}.
# 2) If CFBI is set and PBI isn't, use given CFBI and keep PBI empty.
# 3) If PBI is set and CFBI isn't, assign ${PRODUCT_BUNDLE_IDENTIFIER} to CFBI and use
# the given PBI.
# 4) If both are set, use both given values.
# TLDR:
# cfbi pbi -> result_cfbi result_pbi
# unset unset computed computed
# set unset given_val unset
# unset set computed given_val
# set set given_val given_val
get_target_property ( existing_cfbi "${target}" MACOSX_BUNDLE_GUI_IDENTIFIER )
if ( NOT MACOSX_BUNDLE_GUI_IDENTIFIER AND NOT existing_cfbi )
set ( is_cfbi_given FALSE )
else ( )
set ( is_cfbi_given TRUE )
endif ( )
if ( NOT is_cfbi_given )
set_target_properties ( "${target}"
P R O P E R T I E S
M A C O S X _ B U N D L E _ G U I _ I D E N T I F I E R " \ $ { P R O D U C T _ B U N D L E _ I D E N T I F I E R } " )
endif ( )
get_target_property ( existing_pbi "${target}" XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER )
if ( NOT CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER AND NOT existing_pbi )
set ( is_pbi_given FALSE )
else ( )
set ( is_pbi_given TRUE )
endif ( )
if ( NOT is_pbi_given AND NOT is_cfbi_given )
_qt_internal_get_default_ios_bundle_identifier ( bundle_id )
set_target_properties ( "${target}"
P R O P E R T I E S
X C O D E _ A T T R I B U T E _ P R O D U C T _ B U N D L E _ I D E N T I F I E R " $ { b u n d l e _ i d } " )
2021-04-14 16:16:44 +00:00
endif ( )
2022-05-04 13:59:24 +00:00
endfunction ( )
2022-05-03 16:17:37 +00:00
function ( _qt_internal_set_xcode_targeted_device_family target )
if ( NOT CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
A N D N O T Q T _ N O _ S E T _ X C O D E _ T A R G E T E D _ D E V I C E _ F A M I L Y )
get_target_property ( existing_device_family
" $ { t a r g e t } " X C O D E _ A T T R I B U T E _ T A R G E T E D _ D E V I C E _ F A M I L Y )
if ( NOT existing_device_family )
set ( device_family_iphone_and_ipad "1,2" )
set_target_properties ( "${target}"
P R O P E R T I E S
X C O D E _ A T T R I B U T E _ T A R G E T E D _ D E V I C E _ F A M I L Y
" $ { d e v i c e _ f a m i l y _ i p h o n e _ a n d _ i p a d } " )
endif ( )
endif ( )
endfunction ( )
2022-05-04 13:42:06 +00:00
function ( _qt_internal_set_xcode_code_sign_style target )
if ( NOT CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE
A N D N O T Q T _ N O _ S E T _ X C O D E _ C O D E _ S I G N _ S T Y L E )
get_target_property ( existing_code_style
" $ { t a r g e t } " X C O D E _ A T T R I B U T E _ C O D E _ S I G N _ S T Y L E )
if ( NOT existing_code_style )
set ( existing_code_style "Automatic" )
set_target_properties ( "${target}"
P R O P E R T I E S
X C O D E _ A T T R I B U T E _ C O D E _ S I G N _ S T Y L E
" $ { e x i s t i n g _ c o d e _ s t y l e } " )
endif ( )
endif ( )
endfunction ( )
2022-07-13 22:36:32 +00:00
# Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/15183
function ( _qt_internal_set_xcode_install_path target )
if ( NOT CMAKE_XCODE_ATTRIBUTE_INSTALL_PATH
A N D N O T Q T _ N O _ S E T _ X C O D E _ I N S T A L L _ P A T H )
get_target_property ( existing_install_path
" $ { t a r g e t } " X C O D E _ A T T R I B U T E _ I N S T A L L _ P A T H )
if ( NOT existing_install_path )
set_target_properties ( "${target}"
P R O P E R T I E S
X C O D E _ A T T R I B U T E _ I N S T A L L _ P A T H
" $ ( i n h e r i t e d ) " )
endif ( )
endif ( )
endfunction ( )
2022-05-11 11:15:20 +00:00
function ( _qt_internal_set_xcode_bundle_display_name target )
# We want the value of CFBundleDisplayName to be ${PRODUCT_NAME}, but we can't put that
# into the Info.plist.in template file directly, because the implicit configure_file(Info.plist)
# done by CMake is not using the @ONLY option, so CMake would treat the assignment as
# variable expansion. Escaping using backslashes does not help.
# Work around it by assigning the dollar char to a separate cache var, and expand it, so that
# the final value in the file will be ${PRODUCT_NAME}, to be evaluated at build time by Xcode.
set ( QT_INTERNAL_DOLLAR_VAR "$" CACHE STRING "" )
endfunction ( )
2022-07-12 13:56:47 +00:00
function ( _qt_internal_set_xcode_bitcode_enablement target )
if ( CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE
O R Q T _ N O _ S E T _ X C O D E _ E N A B L E _ B I T C O D E )
return ( )
endif ( )
get_target_property ( existing_bitcode_enablement
" $ { t a r g e t } " X C O D E _ A T T R I B U T E _ E N A B L E _ B I T C O D E )
if ( NOT existing_bitcode_enablement MATCHES "-NOTFOUND" )
return ( )
endif ( )
# Disable bitcode to match Xcode 14's new default
set_target_properties ( "${target}"
P R O P E R T I E S
X C O D E _ A T T R I B U T E _ E N A B L E _ B I T C O D E
" N O " )
endfunction ( )
2022-07-06 15:19:52 +00:00
function ( _qt_internal_generate_ios_info_plist target )
# If the project already specifies a custom file, we don't override it.
get_target_property ( existing_plist "${target}" MACOSX_BUNDLE_INFO_PLIST )
if ( existing_plist )
return ( )
endif ( )
set ( info_plist_in "${__qt_internal_cmake_ios_support_files_path}/Info.plist.app.in" )
string ( MAKE_C_IDENTIFIER "${target}" target_identifier )
set ( info_plist_out_dir
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / . q t / i n f o _ p l i s t / $ { t a r g e t _ i d e n t i f i e r } " )
set ( info_plist_out "${info_plist_out_dir}/Info.plist" )
# Check if we need to specify a custom launch screen storyboard entry.
get_target_property ( launch_screen_name "${target}" _qt_ios_launch_screen_name )
if ( launch_screen_name )
set ( qt_ios_launch_screen_plist_entry "${launch_screen_name}" )
endif ( )
# Call configure_file to substitute Qt-specific @FOO@ values, not ${FOO} values.
#
# The output file will be another template file to be fed to CMake via the
# MACOSX_BUNDLE_INFO_PLIST property. CMake will then call configure_file on it to provide
# content for regular entries like CFBundleName, etc.
#
# We require this extra configure_file call so we can create unique Info.plist files for each
# target in a project, while also providing a way to add Qt specific entries that CMake
# does not support out of the box (e.g. a launch screen name).
configure_file (
" $ { i n f o _ p l i s t _ i n } "
" $ { i n f o _ p l i s t _ o u t } "
@ O N L Y
)
set_target_properties ( "${target}" PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${info_plist_out}" )
endfunction ( )
2022-08-03 14:51:34 +00:00
function ( _qt_internal_set_ios_simulator_arch target )
if ( CMAKE_XCODE_ATTRIBUTE_ARCHS
O R Q T _ N O _ S E T _ X C O D E _ A R C H S )
return ( )
endif ( )
get_target_property ( existing_archs
" $ { t a r g e t } " X C O D E _ A T T R I B U T E _ A R C H S )
if ( NOT existing_archs MATCHES "-NOTFOUND" )
return ( )
endif ( )
if ( NOT x86_64 IN_LIST QT_OSX_ARCHITECTURES )
return ( )
endif ( )
if ( CMAKE_OSX_ARCHITECTURES AND NOT x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES )
return ( )
endif ( )
set_target_properties ( "${target}"
P R O P E R T I E S
" X C O D E _ A T T R I B U T E _ A R C H S [ s d k = i p h o n e s i m u l a t o r * ] "
" x 8 6 _ 6 4 " )
endfunction ( )
2022-07-14 10:12:54 +00:00
function ( _qt_internal_finalize_apple_app target )
# Shared between macOS and iOS apps
2022-05-04 13:59:24 +00:00
_qt_internal_set_xcode_development_team_id ( "${target}" )
_qt_internal_set_xcode_bundle_identifier ( "${target}" )
2022-05-04 13:42:06 +00:00
_qt_internal_set_xcode_code_sign_style ( "${target}" )
2022-05-11 11:15:20 +00:00
_qt_internal_set_xcode_bundle_display_name ( "${target}" )
2022-07-13 22:36:32 +00:00
_qt_internal_set_xcode_install_path ( "${target}" )
2022-07-14 10:12:54 +00:00
_qt_internal_set_placeholder_apple_bundle_version ( "${target}" )
endfunction ( )
function ( _qt_internal_finalize_ios_app target )
_qt_internal_finalize_apple_app ( "${target}" )
2021-08-17 09:21:01 +00:00
2022-07-14 10:12:54 +00:00
_qt_internal_set_xcode_targeted_device_family ( "${target}" )
_qt_internal_set_xcode_bitcode_enablement ( "${target}" )
2021-07-15 14:20:20 +00:00
_qt_internal_handle_ios_launch_screen ( "${target}" )
2022-07-06 15:19:52 +00:00
_qt_internal_generate_ios_info_plist ( "${target}" )
2022-08-03 14:51:34 +00:00
_qt_internal_set_ios_simulator_arch ( "${target}" )
2019-06-11 13:46:31 +00:00
endfunction ( )
2021-11-29 23:29:34 +00:00
function ( _qt_internal_finalize_macos_app target )
get_target_property ( is_bundle ${ target } MACOSX_BUNDLE )
if ( NOT is_bundle )
return ( )
endif ( )
2022-07-14 10:12:54 +00:00
_qt_internal_finalize_apple_app ( "${target}" )
2021-11-29 23:29:34 +00:00
# Make sure the install rpath has at least the minimum needed if the app
# has any non-static frameworks. We can't rigorously know if the app will
# have any, even with a static Qt, so always add this. If there are no
# frameworks, it won't do any harm.
get_property ( install_rpath TARGET ${ target } PROPERTY INSTALL_RPATH )
list ( APPEND install_rpath "@executable_path/../Frameworks" )
list ( REMOVE_DUPLICATES install_rpath )
set_property ( TARGET ${ target } PROPERTY INSTALL_RPATH "${install_rpath}" )
endfunction ( )
2020-10-15 15:58:15 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_add_executable )
2020-10-15 15:58:15 +00:00
qt6_add_executable ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
function ( qt_finalize_target )
2021-05-18 17:42:55 +00:00
qt6_finalize_target ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
2021-06-02 15:08:35 +00:00
# Kept for compatibility with Qt Creator 4.15 wizards
2021-08-31 05:56:00 +00:00
function ( qt_finalize_executable )
2021-06-02 15:08:35 +00:00
qt6_finalize_target ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
2020-10-15 15:58:15 +00:00
endif ( )
2020-01-22 15:28:57 +00:00
function ( _qt_get_plugin_name_with_version target out_var )
string ( REGEX REPLACE "^Qt::(.+)" "Qt${QT_DEFAULT_MAJOR_VERSION}::\\1"
q t _ p l u g i n _ w i t h _ v e r s i o n " $ { t a r g e t } " )
if ( TARGET "${qt_plugin_with_version}" )
set ( "${out_var}" "${qt_plugin_with_version}" PARENT_SCOPE )
else ( )
set ( "${out_var}" "" PARENT_SCOPE )
endif ( )
endfunction ( )
2019-06-07 07:13:31 +00:00
macro ( _qt_import_plugin target plugin )
2020-01-22 15:28:57 +00:00
set ( _final_plugin_name "${plugin}" )
if ( NOT TARGET "${plugin}" )
_qt_get_plugin_name_with_version ( "${plugin}" _qt_plugin_with_version_name )
if ( TARGET "${_qt_plugin_with_version_name}" )
set ( _final_plugin_name "${_qt_plugin_with_version_name}" )
endif ( )
endif ( )
if ( NOT TARGET "${_final_plugin_name}" )
message (
" W a r n i n g : p l u g - i n $ { _ f i n a l _ p l u g i n _ n a m e } i s n o t k n o w n t o t h e c u r r e n t Q t i n s t a l l a t i o n . " )
else ( )
get_target_property ( _plugin_class_name "${_final_plugin_name}" QT_PLUGIN_CLASS_NAME )
if ( _plugin_class_name )
set_property ( TARGET "${target}" APPEND PROPERTY QT_PLUGINS "${plugin}" )
endif ( )
2019-06-07 07:13:31 +00:00
endif ( )
endmacro ( )
2020-11-30 18:28:00 +00:00
function ( _qt_internal_disable_static_default_plugins target )
set_target_properties ( ${ target } PROPERTIES QT_DEFAULT_PLUGINS 0 )
endfunction ( )
2019-12-05 12:52:33 +00:00
function ( qt6_import_plugins target )
2019-09-23 14:57:06 +00:00
cmake_parse_arguments ( arg "NO_DEFAULT" "" "INCLUDE;EXCLUDE;INCLUDE_BY_TYPE;EXCLUDE_BY_TYPE" ${ ARGN } )
2019-06-07 07:13:31 +00:00
2019-09-23 14:57:06 +00:00
# Handle NO_DEFAULT
2019-06-07 07:13:31 +00:00
if ( ${ arg_NO_DEFAULT } )
2020-11-30 18:28:00 +00:00
_qt_internal_disable_static_default_plugins ( "${target}" )
2019-06-07 07:13:31 +00:00
endif ( )
2019-09-23 14:57:06 +00:00
# Handle INCLUDE
2019-06-07 07:13:31 +00:00
foreach ( plugin ${ arg_INCLUDE } )
_qt_import_plugin ( "${target}" "${plugin}" )
endforeach ( )
2019-09-23 14:57:06 +00:00
# Handle EXCLUDE
2019-06-07 07:13:31 +00:00
foreach ( plugin ${ arg_EXCLUDE } )
set_property ( TARGET "${target}" APPEND PROPERTY QT_NO_PLUGINS "${plugin}" )
endforeach ( )
2019-09-23 14:57:06 +00:00
# Handle INCLUDE_BY_TYPE
set ( _current_type "" )
foreach ( _arg ${ arg_INCLUDE_BY_TYPE } )
string ( REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}" )
list ( FIND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE "${_plugin_type}" _has_plugin_type )
if ( ${ _has_plugin_type } GREATER_EQUAL 0 )
set ( _current_type "${_plugin_type}" )
else ( )
if ( "${_current_type}" STREQUAL "" )
message ( FATAL_ERROR "qt_import_plugins: invalid syntax for INCLUDE_BY_TYPE" )
endif ( )
2020-01-22 15:28:57 +00:00
# Check if passed plugin target name is a version-less one, and make a version-full
# one.
2021-05-06 14:38:53 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY "QT_PLUGINS_${_current_type}" "${_arg}" )
2021-04-28 14:27:19 +00:00
set_property ( TARGET "${target}" APPEND PROPERTY "_qt_plugins_by_type" "${_arg}" )
2020-01-22 15:28:57 +00:00
_qt_get_plugin_name_with_version ( "${_arg}" qt_plugin_with_version )
2021-05-06 14:38:53 +00:00
# TODO: Do we really need this check? We didn't have it in Qt5, and plugin targets
# wrapped in genexes end up causing warnings, but we explicitly use GENEX_EVAL to
# support them.
if ( NOT TARGET "${_arg}" AND NOT TARGET "${qt_plugin_with_version}" )
2019-09-23 14:57:06 +00:00
message ( "Warning: plug-in ${_arg} is not known to the current Qt installation." )
endif ( )
endif ( )
endforeach ( )
# Handle EXCLUDE_BY_TYPE
foreach ( _arg ${ arg_EXCLUDE_BY_TYPE } )
string ( REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}" )
set_property ( TARGET "${target}" PROPERTY "QT_PLUGINS_${_plugin_type}" "-" )
endforeach ( )
endfunction ( )
2019-10-11 14:16:29 +00:00
2019-12-05 12:52:33 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_import_plugins )
2019-12-05 12:52:33 +00:00
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 5 )
qt5_import_plugins ( ${ ARGV } )
elseif ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
qt6_import_plugins ( ${ ARGV } )
2018-10-17 20:03:28 +00:00
endif ( )
2021-08-31 05:56:00 +00:00
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2019-11-26 09:10:55 +00:00
2021-08-05 14:49:42 +00:00
# This function is currently in Technical Preview. It's signature may change or be removed entirely.
function ( qt6_set_finalizer_mode target )
cmake_parse_arguments ( arg "ENABLE;DISABLE" "" "MODES" ${ ARGN } )
if ( NOT arg_ENABLE AND NOT arg_DISABLE )
message ( FATAL_ERROR "No option was specified whether to enable or disable the modes." )
elseif ( arg_ENABLE AND arg_DISABLE )
message ( FATAL_ERROR "Both ENABLE and DISABLE options were specified." )
endif ( )
if ( NOT arg_MODES )
message ( FATAL_ERROR "No modes were specified in qt6_set_finalizer_mode() call." )
2021-04-28 14:27:19 +00:00
endif ( )
2021-08-05 14:49:42 +00:00
if ( arg_ENABLE )
set ( value "TRUE" )
elseif ( arg_DISABLE )
set ( value "FALSE" )
endif ( )
2021-04-28 14:27:19 +00:00
2021-08-05 14:49:42 +00:00
foreach ( mode ${ arg_MODES } )
__qt_internal_enable_finalizer_mode ( "${target}" "${mode}" "${value}" )
endforeach ( )
2021-05-19 17:46:24 +00:00
endfunction ( )
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_set_finalizer_mode )
2021-08-05 14:49:42 +00:00
qt6_set_finalizer_mode ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
2021-05-19 17:46:24 +00:00
endif ( )
2020-01-27 13:56:40 +00:00
2020-10-14 11:20:55 +00:00
function ( qt6_extract_metatypes target )
2019-11-26 09:10:55 +00:00
2020-02-03 15:52:18 +00:00
get_target_property ( existing_meta_types_file ${ target } INTERFACE_QT_META_TYPES_BUILD_FILE )
if ( existing_meta_types_file )
return ( )
endif ( )
2021-08-18 14:49:11 +00:00
set ( args_option
# TODO: Move this into a separate internal function, so it doesn't pollute the public one.
2021-09-23 07:42:06 +00:00
# When given, metatypes files will be installed into the default Qt
# metatypes folder. Only to be used by the Qt build.
2021-08-18 14:49:11 +00:00
_ _ Q T _ I N T E R N A L _ I N S T A L L
)
set ( args_single
# TODO: Move this into a separate internal function, so it doesn't pollute the public one.
2021-09-23 07:42:06 +00:00
# Location where to install the metatypes file. Only used if
# __QT_INTERNAL_INSTALL is given. It defaults to the
# ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}/metatypes directory.
# Executable metatypes files are never installed.
2021-08-18 14:49:11 +00:00
_ _ Q T _ I N T E R N A L _ I N S T A L L _ D I R
O U T P U T _ F I L E S
)
set ( args_multi
M A N U A L _ M O C _ J S O N _ F I L E S
)
2021-07-12 14:19:31 +00:00
cmake_parse_arguments ( arg
2021-08-18 14:49:11 +00:00
" $ { a r g s _ o p t i o n } "
" $ { a r g s _ s i n g l e } "
" $ { a r g s _ m u l t i } " $ { A R G N } )
2020-01-27 13:56:40 +00:00
2019-11-26 09:10:55 +00:00
get_target_property ( target_type ${ target } TYPE )
2020-02-03 15:52:18 +00:00
if ( target_type STREQUAL "INTERFACE_LIBRARY" )
message ( FATAL_ERROR "Meta types generation does not work on interface libraries" )
2019-11-26 09:10:55 +00:00
return ( )
endif ( )
2020-02-03 15:52:18 +00:00
if ( CMAKE_VERSION VERSION_LESS "3.16.0" )
message ( FATAL_ERROR "Meta types generation requires CMake >= 3.16" )
2019-11-26 09:10:55 +00:00
return ( )
endif ( )
get_target_property ( target_binary_dir ${ target } BINARY_DIR )
2020-02-03 15:52:18 +00:00
set ( type_list_file "${target_binary_dir}/meta_types/${target}_json_file_list.txt" )
set ( type_list_file_manual "${target_binary_dir}/meta_types/${target}_json_file_list_manual.txt" )
get_target_property ( uses_automoc ${ target } AUTOMOC )
set ( automoc_args )
set ( automoc_dependencies )
2020-05-25 16:52:16 +00:00
# Handle automoc generated data
2020-02-03 15:52:18 +00:00
if ( uses_automoc )
# Tell automoc to output json files)
set_property ( TARGET "${target}" APPEND PROPERTY
A U T O M O C _ M O C _ O P T I O N S " - - o u t p u t - j s o n "
)
2019-11-26 09:10:55 +00:00
2021-07-13 01:05:52 +00:00
get_property ( is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if ( NOT is_multi_config )
2020-02-03 15:52:18 +00:00
set ( cmake_autogen_cache_file
" $ { t a r g e t _ b i n a r y _ d i r } / C M a k e F i l e s / $ { t a r g e t } _ a u t o g e n . d i r / P a r s e C a c h e . t x t " )
2021-07-13 01:05:52 +00:00
set ( multi_config_args
2020-02-03 15:52:18 +00:00
- - c m a k e - a u t o g e n - i n c l u d e - d i r - p a t h " $ { t a r g e t _ b i n a r y _ d i r } / $ { t a r g e t } _ a u t o g e n / i n c l u d e "
)
else ( )
set ( cmake_autogen_cache_file
" $ { t a r g e t _ b i n a r y _ d i r } / C M a k e F i l e s / $ { t a r g e t } _ a u t o g e n . d i r / P a r s e C a c h e _ $ < C O N F I G > . t x t " )
2021-07-13 01:05:52 +00:00
set ( multi_config_args
2020-02-03 15:52:18 +00:00
- - c m a k e - a u t o g e n - i n c l u d e - d i r - p a t h " $ { t a r g e t _ b i n a r y _ d i r } / $ { t a r g e t } _ a u t o g e n / i n c l u d e _ $ < C O N F I G > "
" - - c m a k e - m u l t i - c o n f i g " )
endif ( )
set ( cmake_autogen_info_file
" $ { t a r g e t _ b i n a r y _ d i r } / C M a k e F i l e s / $ { t a r g e t } _ a u t o g e n . d i r / A u t o g e n I n f o . j s o n " )
2020-03-04 14:58:59 +00:00
set ( use_dep_files FALSE )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.17" ) # Requires automoc changes present only in 3.17
if ( CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" )
set ( use_dep_files TRUE )
endif ( )
endif ( )
2021-11-24 15:22:18 +00:00
set ( cmake_automoc_parser_timestamp "${type_list_file}.timestamp" )
2020-03-04 14:58:59 +00:00
if ( NOT use_dep_files )
2021-07-02 15:43:58 +00:00
# When a project is configured with a Visual Studio generator, CMake's
# cmQtAutoGenInitializer::InitAutogenTarget() can take one of two code paths on how to
# handle AUTOMOC rules.
# It either creates a ${target}_autogen custom target or uses PRE_BUILD build events.
#
# The latter in considered an optimization and is used by CMake when possible.
# Unfortunately that breaks our add_dependency call because we expect on _autogen target
# to always exist.
#
# Ensure the PRE_BUILD path is not taken by generating a dummy header file and adding it
# as a source file to the target. This causes the file to be added to
# cmQtAutoGenInitializer::AutogenTarget.DependFiles, which disables the PRE_BUILD path.
if ( CMAKE_GENERATOR MATCHES "Visual Studio" )
# The file name should be target specific, but still short, so we don't hit path
# length issues.
string ( MAKE_C_IDENTIFIER "ddf_${target}" dummy_dependency_file )
set ( dummy_out_file "${CMAKE_CURRENT_BINARY_DIR}/${dummy_dependency_file}.h" )
# The content shouldn't be empty so we don't trigger AUTOMOC warnings about it.
file ( GENERATE OUTPUT "${dummy_out_file}" CONTENT "//" )
set_source_files_properties ( "${dummy_out_file}" PROPERTIES
G E N E R A T E D T R U E
S K I P _ A U T O G E N O F F )
target_sources ( "${target}" PRIVATE "${dummy_out_file}" )
endif ( )
2020-03-04 14:58:59 +00:00
add_custom_target ( ${ target } _automoc_json_extraction
D E P E N D S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : c m a k e _ a u t o m o c _ p a r s e r
2021-11-24 15:22:18 +00:00
B Y P R O D U C T S
$ { t y p e _ l i s t _ f i l e }
" $ { c m a k e _ a u t o m o c _ p a r s e r _ t i m e s t a m p } "
2020-03-04 14:58:59 +00:00
C O M M A N D
$ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : c m a k e _ a u t o m o c _ p a r s e r
- - c m a k e - a u t o g e n - c a c h e - f i l e " $ { c m a k e _ a u t o g e n _ c a c h e _ f i l e } "
- - c m a k e - a u t o g e n - i n f o - f i l e " $ { c m a k e _ a u t o g e n _ i n f o _ f i l e } "
- - o u t p u t - f i l e - p a t h " $ { t y p e _ l i s t _ f i l e } "
2021-11-24 15:22:18 +00:00
- - t i m e s t a m p - f i l e - p a t h " $ { c m a k e _ a u t o m o c _ p a r s e r _ t i m e s t a m p } "
2021-07-13 01:05:52 +00:00
$ { m u l t i _ c o n f i g _ a r g s }
2021-06-16 14:58:22 +00:00
C O M M E N T " R u n n i n g A U T O M O C f i l e e x t r a c t i o n f o r t a r g e t $ { t a r g e t } "
2020-03-04 14:58:59 +00:00
C O M M A N D _ E X P A N D _ L I S T S
)
add_dependencies ( ${ target } _automoc_json_extraction ${ target } _autogen )
else ( )
set ( cmake_autogen_timestamp_file
" $ { t a r g e t _ b i n a r y _ d i r } / $ { t a r g e t } _ a u t o g e n / t i m e s t a m p "
)
add_custom_command ( OUTPUT ${ type_list_file }
D E P E N D S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : c m a k e _ a u t o m o c _ p a r s e r
$ { c m a k e _ a u t o g e n _ t i m e s t a m p _ f i l e }
2021-11-24 15:22:18 +00:00
B Y P R O D U C T S " $ { c m a k e _ a u t o m o c _ p a r s e r _ t i m e s t a m p } "
2020-03-04 14:58:59 +00:00
C O M M A N D
$ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : c m a k e _ a u t o m o c _ p a r s e r
- - c m a k e - a u t o g e n - c a c h e - f i l e " $ { c m a k e _ a u t o g e n _ c a c h e _ f i l e } "
- - c m a k e - a u t o g e n - i n f o - f i l e " $ { c m a k e _ a u t o g e n _ i n f o _ f i l e } "
- - o u t p u t - f i l e - p a t h " $ { t y p e _ l i s t _ f i l e } "
2021-11-24 15:22:18 +00:00
- - t i m e s t a m p - f i l e - p a t h " $ { c m a k e _ a u t o m o c _ p a r s e r _ t i m e s t a m p } "
2021-07-13 01:05:52 +00:00
$ { m u l t i _ c o n f i g _ a r g s }
2021-06-16 14:58:22 +00:00
C O M M E N T " R u n n i n g A U T O M O C f i l e e x t r a c t i o n f o r t a r g e t $ { t a r g e t } "
2020-03-04 14:58:59 +00:00
C O M M A N D _ E X P A N D _ L I S T S
2022-03-15 16:37:11 +00:00
V E R B A T I M
2020-03-04 14:58:59 +00:00
)
endif ( )
2020-02-03 15:52:18 +00:00
set ( automoc_args "@${type_list_file}" )
set ( automoc_dependencies "${type_list_file}" )
endif ( )
set ( manual_args )
set ( manual_dependencies )
if ( arg_MANUAL_MOC_JSON_FILES )
list ( REMOVE_DUPLICATES arg_MANUAL_MOC_JSON_FILES )
file ( GENERATE
O U T P U T $ { t y p e _ l i s t _ f i l e _ m a n u a l }
C O N T E N T " $ < J O I N : $ < G E N E X _ E V A L : $ { a r g _ M A N U A L _ M O C _ J S O N _ F I L E S } > , \ n > "
)
list ( APPEND manual_dependencies ${ arg_MANUAL_MOC_JSON_FILES } ${ type_list_file_manual } )
set ( manual_args "@${type_list_file_manual}" )
endif ( )
2019-11-26 09:10:55 +00:00
2020-02-03 15:52:18 +00:00
if ( NOT manual_args AND NOT automoc_args )
message ( FATAL_ERROR "Metatype generation requires either the use of AUTOMOC or a manual list of generated json files" )
endif ( )
2019-11-26 09:10:55 +00:00
2021-07-13 01:05:52 +00:00
if ( CMAKE_BUILD_TYPE AND NOT is_multi_config )
2019-11-26 09:10:55 +00:00
string ( TOLOWER ${ target } _ ${ CMAKE_BUILD_TYPE } target_lowercase )
else ( )
2019-12-06 14:12:17 +00:00
string ( TOLOWER ${ target } target_lowercase )
2019-11-26 09:10:55 +00:00
endif ( )
2020-01-27 13:56:40 +00:00
set ( metatypes_file_name "qt6${target_lowercase}_metatypes.json" )
set ( metatypes_file "${target_binary_dir}/meta_types/${metatypes_file_name}" )
2020-02-07 13:12:27 +00:00
set ( metatypes_file_gen "${target_binary_dir}/meta_types/${metatypes_file_name}.gen" )
2020-01-27 13:56:40 +00:00
set ( metatypes_dep_file_name "qt6${target_lowercase}_metatypes_dep.txt" )
set ( metatypes_dep_file "${target_binary_dir}/meta_types/${metatypes_dep_file_name}" )
2020-02-07 13:12:27 +00:00
# Due to generated source file dependency rules being tied to the directory
# scope in which they are created it is not possible for other targets which
# are defined in a separate scope to see these rules. This leads to failures
# in locating the generated source files.
# To work around this we write a dummy file to disk to make sure targets
# which link against the current target do not produce the error. This dummy
# file is then replaced with the contents of the generated file during
# build.
if ( NOT EXISTS ${ metatypes_file } )
file ( MAKE_DIRECTORY "${target_binary_dir}/meta_types" )
file ( TOUCH ${ metatypes_file } )
endif ( )
2020-03-20 09:03:59 +00:00
2021-07-05 15:37:15 +00:00
add_custom_command (
O U T P U T
$ { m e t a t y p e s _ f i l e _ g e n }
$ { m e t a t y p e s _ f i l e }
2020-02-03 15:52:18 +00:00
D E P E N D S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c $ { a u t o m o c _ d e p e n d e n c i e s } $ { m a n u a l _ d e p e n d e n c i e s }
2019-11-26 09:10:55 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c
2020-02-07 13:12:27 +00:00
- o $ { m e t a t y p e s _ f i l e _ g e n }
2020-02-03 15:52:18 +00:00
- - c o l l e c t - j s o n $ { a u t o m o c _ a r g s } $ { m a n u a l _ a r g s }
2020-02-07 13:12:27 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ i f _ d i f f e r e n t
$ { m e t a t y p e s _ f i l e _ g e n }
$ { m e t a t y p e s _ f i l e }
2021-06-16 14:58:22 +00:00
C O M M E N T " R u n n i n g m o c - - c o l l e c t - j s o n f o r t a r g e t $ { t a r g e t } "
2022-03-15 16:37:11 +00:00
V E R B A T I M
2019-11-26 09:10:55 +00:00
)
2021-09-07 05:51:18 +00:00
# We can't rely on policy CMP0118 since user project controls it
set ( scope_args )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
set ( scope_args TARGET_DIRECTORY ${ target } )
endif ( )
set_source_files_properties ( ${ metatypes_file_gen } ${ metatypes_file } ${ scope_args }
P R O P E R T I E S G E N E R A T E D T R U E
)
2021-07-12 14:19:31 +00:00
# We still need to add this file as a source of the target, otherwise the file
2020-02-07 13:12:27 +00:00
# rule above is not triggered. INTERFACE_SOURCES do not properly register
# as dependencies to build the current target.
2021-07-12 14:19:31 +00:00
# TODO: Can we pass ${metatypes_file} instead of ${metatypes_file_gen} as a source?
# TODO: Do we still need the _gen variant at all?
2020-02-07 13:12:27 +00:00
target_sources ( ${ target } PRIVATE ${ metatypes_file_gen } )
2021-09-07 05:51:18 +00:00
set_source_files_properties ( ${ metatypes_file } ${ scope_args }
P R O P E R T I E S H E A D E R _ F I L E _ O N L Y T R U E
)
2019-11-26 09:10:55 +00:00
set_target_properties ( ${ target } PROPERTIES
2020-01-27 13:56:40 +00:00
I N T E R F A C E _ Q T _ M O D U L E _ H A S _ M E T A _ T Y P E S Y E S
2020-05-25 16:52:16 +00:00
I N T E R F A C E _ Q T _ M E T A _ T Y P E S _ B U I L D _ F I L E " $ { m e t a t y p e s _ f i l e } "
2020-01-27 13:56:40 +00:00
)
2021-07-12 14:19:31 +00:00
# Set up consumption of files via INTERFACE_SOURCES.
set ( consumes_metatypes "$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>" )
set ( metatypes_file_genex_build
" $ < B U I L D _ I N T E R F A C E : $ < $ { c o n s u m e s _ m e t a t y p e s } : $ { m e t a t y p e s _ f i l e } > > "
)
target_sources ( ${ target } INTERFACE ${ metatypes_file_genex_build } )
2021-08-18 14:49:11 +00:00
if ( arg_OUTPUT_FILES )
2021-09-06 01:18:06 +00:00
set ( ${ arg_OUTPUT_FILES } "${metatypes_file}" PARENT_SCOPE )
2021-08-18 14:49:11 +00:00
endif ( )
2021-10-09 13:06:03 +00:00
# Check whether the generated json file needs to be installed.
2021-07-12 14:19:31 +00:00
# Executable metatypes.json files should not be installed. Qt non-prefix builds should also
# not install the files.
2021-08-18 14:49:11 +00:00
set ( should_install FALSE )
if ( NOT target_type STREQUAL "EXECUTABLE" AND arg___QT_INTERNAL_INSTALL )
set ( should_install TRUE )
2021-07-12 14:19:31 +00:00
endif ( )
# Automatically fill default install args when not specified.
2021-08-18 14:49:11 +00:00
if ( NOT arg___QT_INTERNAL_INSTALL_DIR )
2021-07-12 14:19:31 +00:00
# INSTALL_LIBDIR is not set when QtBuildInternals is not loaded (when not doing a Qt build).
# Default to a hardcoded location for user projects.
if ( INSTALL_LIBDIR )
2021-08-18 14:49:11 +00:00
set ( install_dir "${INSTALL_LIBDIR}/metatypes" )
2021-07-12 14:19:31 +00:00
else ( )
2021-08-18 14:49:11 +00:00
set ( install_dir "lib/metatypes" )
2020-02-03 15:52:18 +00:00
endif ( )
2021-08-18 14:49:11 +00:00
else ( )
set ( install_dir "${arg___QT_INTERNAL_INSTALL_DIR}" )
2020-01-27 13:56:40 +00:00
endif ( )
2021-07-12 14:19:31 +00:00
if ( should_install )
2021-08-18 14:49:11 +00:00
set ( metatypes_file_install_path "${install_dir}/${metatypes_file_name}" )
2021-07-12 14:19:31 +00:00
set ( metatypes_file_install_path_genex "$<INSTALL_PREFIX>/${metatypes_file_install_path}" )
set ( metatypes_file_genex_install
" $ < I N S T A L L _ I N T E R F A C E : $ < $ { c o n s u m e s _ m e t a t y p e s } : $ { m e t a t y p e s _ f i l e _ i n s t a l l _ p a t h _ g e n e x } > > "
)
target_sources ( ${ target } INTERFACE ${ metatypes_file_genex_install } )
2021-08-18 14:49:11 +00:00
install ( FILES "${metatypes_file}" DESTINATION "${install_dir}" )
2021-07-12 14:19:31 +00:00
endif ( )
2019-11-26 09:10:55 +00:00
endfunction ( )
2019-12-05 12:52:33 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_extract_metatypes )
2020-10-14 11:20:55 +00:00
qt6_extract_metatypes ( ${ ARGV } )
2021-09-06 01:18:06 +00:00
cmake_parse_arguments ( PARSE_ARGV 0 arg "" "OUTPUT_FILES" "" )
if ( arg_OUTPUT_FILES )
set ( ${ arg_OUTPUT_FILES } "${${arg_OUTPUT_FILES}}" PARENT_SCOPE )
endif ( )
2021-08-31 05:56:00 +00:00
endfunction ( )
2019-12-05 12:52:33 +00:00
endif ( )
2020-02-21 15:32:13 +00:00
# Generate Win32 RC files for a target. All entries in the RC file are generated
2020-05-04 19:55:40 +00:00
# from target properties:
2020-02-21 15:32:13 +00:00
#
# QT_TARGET_COMPANY_NAME: RC Company name
# QT_TARGET_DESCRIPTION: RC File Description
# QT_TARGET_VERSION: RC File and Product Version
# QT_TARGET_COPYRIGHT: RC LegalCopyright
# QT_TARGET_PRODUCT_NAME: RC ProductName
2020-05-11 15:04:21 +00:00
# QT_TARGET_COMMENTS: RC Comments
# QT_TARGET_ORIGINAL_FILENAME: RC Original FileName
# QT_TARGET_TRADEMARKS: RC LegalTrademarks
# QT_TARGET_INTERNALNAME: RC InternalName
2020-02-21 15:32:13 +00:00
# QT_TARGET_RC_ICONS: List of paths to icon files
#
2020-05-04 19:55:40 +00:00
# If you do not wish to auto-generate rc files, it's possible to provide your
2020-02-21 15:32:13 +00:00
# own RC file by setting the property QT_TARGET_WINDOWS_RC_FILE with a path to
# an existing rc file.
2020-10-14 11:20:55 +00:00
function ( _qt_internal_generate_win32_rc_file target )
2020-05-06 05:54:37 +00:00
set ( prohibited_target_types INTERFACE_LIBRARY STATIC_LIBRARY OBJECT_LIBRARY )
2020-02-21 15:32:13 +00:00
get_target_property ( target_type ${ target } TYPE )
2020-05-06 05:54:37 +00:00
if ( target_type IN_LIST prohibited_target_types )
2020-02-21 15:32:13 +00:00
return ( )
endif ( )
get_target_property ( target_binary_dir ${ target } BINARY_DIR )
get_target_property ( target_rc_file ${ target } QT_TARGET_WINDOWS_RC_FILE )
get_target_property ( target_version ${ target } QT_TARGET_VERSION )
if ( NOT target_rc_file AND NOT target_version )
return ( )
endif ( )
2021-10-25 11:23:47 +00:00
if ( MSVC )
set ( extra_rc_flags "/nologo" )
else ( )
set ( extra_rc_flags )
endif ( )
2020-05-04 19:55:40 +00:00
if ( target_rc_file )
# Use the provided RC file
target_sources ( ${ target } PRIVATE "${target_rc_file}" )
2021-10-25 11:23:47 +00:00
set_property ( SOURCE ${ target_rc_file } PROPERTY COMPILE_FLAGS "${extra_rc_flags}" )
2020-05-04 19:55:40 +00:00
else ( )
2020-02-21 15:32:13 +00:00
# Generate RC File
2020-05-04 19:55:40 +00:00
set ( rc_file_output "${target_binary_dir}/" )
if ( QT_GENERATOR_IS_MULTI_CONFIG )
string ( APPEND rc_file_output "$<CONFIG>/" )
endif ( )
string ( APPEND rc_file_output "${target}_resource.rc" )
2020-02-21 15:32:13 +00:00
set ( target_rc_file "${rc_file_output}" )
set ( company_name "" )
get_target_property ( target_company_name ${ target } QT_TARGET_COMPANY_NAME )
if ( target_company_name )
set ( company_name "${target_company_name}" )
endif ( )
set ( file_description "" )
get_target_property ( target_description ${ target } QT_TARGET_DESCRIPTION )
if ( target_description )
set ( file_description "${target_description}" )
endif ( )
set ( legal_copyright "" )
get_target_property ( target_copyright ${ target } QT_TARGET_COPYRIGHT )
if ( target_copyright )
set ( legal_copyright "${target_copyright}" )
endif ( )
set ( product_name "" )
get_target_property ( target_product_name ${ target } QT_TARGET_PRODUCT_NAME )
if ( target_product_name )
set ( product_name "${target_product_name}" )
else ( )
set ( product_name "${target}" )
endif ( )
2020-05-11 15:04:21 +00:00
set ( comments "" )
get_target_property ( target_comments ${ target } QT_TARGET_COMMENTS )
if ( target_comments )
set ( comments "${target_comments}" )
endif ( )
set ( legal_trademarks "" )
get_target_property ( target_trademarks ${ target } QT_TARGET_TRADEMARKS )
if ( target_trademarks )
set ( legal_trademarks "${target_trademarks}" )
endif ( )
2020-02-21 15:32:13 +00:00
set ( product_version "" )
if ( target_version )
if ( target_version MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" )
# nothing to do
elseif ( target_version MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+" )
set ( target_version "${target_version}.0" )
elseif ( target_version MATCHES "[0-9]+\\.[0-9]+" )
set ( target_version "${target_version}.0.0" )
elseif ( target_version MATCHES "[0-9]+" )
set ( target_version "${target_version}.0.0.0" )
else ( )
2020-07-27 08:17:04 +00:00
message ( FATAL_ERROR "Invalid version format: '${target_version}'" )
2020-02-21 15:32:13 +00:00
endif ( )
set ( product_version "${target_version}" )
else ( )
set ( product_version "0.0.0.0" )
endif ( )
set ( file_version "${product_version}" )
string ( REPLACE "." "," version_comma ${ product_version } )
2020-05-11 15:04:21 +00:00
set ( original_file_name "$<TARGET_FILE_NAME:${target}>" )
get_target_property ( target_original_file_name ${ target } QT_TARGET_ORIGINAL_FILENAME )
if ( target_original_file_name )
set ( original_file_name "${target_original_file_name}" )
endif ( )
set ( internal_name "" )
get_target_property ( target_internal_name ${ target } QT_TARGET_INTERNALNAME )
if ( target_internal_name )
set ( internal_name "${target_internal_name}" )
endif ( )
2020-02-21 15:32:13 +00:00
set ( icons "" )
get_target_property ( target_icons ${ target } QT_TARGET_RC_ICONS )
if ( target_icons )
set ( index 1 )
foreach ( icon IN LISTS target_icons )
2020-05-11 13:49:28 +00:00
string ( APPEND icons "IDI_ICON${index} ICON \" ${ icon } \"\n")
2020-02-21 15:32:13 +00:00
math ( EXPR index "${index} +1" )
endforeach ( )
endif ( )
2020-05-12 02:25:35 +00:00
set ( target_file_type "VFT_DLL" )
if ( target_type STREQUAL "EXECUTABLE" )
set ( target_file_type "VFT_APP" )
endif ( )
2020-02-21 15:32:13 +00:00
set ( contents " #include <windows.h>
2020-05-06 05:56:45 +00:00
$ { i c o n s }
2020-02-21 15:32:13 +00:00
V S _ V E R S I O N _ I N F O V E R S I O N I N F O
F I L E V E R S I O N $ { v e r s i o n _ c o m m a }
P R O D U C T V E R S I O N $ { v e r s i o n _ c o m m a }
F I L E F L A G S M A S K 0 x 3 f L
#ifdef _DEBUG
F I L E F L A G S V S _ F F _ D E B U G
#else
F I L E F L A G S 0 x 0 L
#endif
2020-05-04 08:51:01 +00:00
F I L E O S V O S _ N T _ W I N D O W S 3 2
2020-05-12 02:25:35 +00:00
F I L E T Y P E $ { t a r g e t _ f i l e _ t y p e }
2020-05-04 08:51:01 +00:00
F I L E S U B T Y P E V F T 2 _ U N K N O W N
2020-02-21 15:32:13 +00:00
B E G I N
B L O C K \ " S t r i n g F i l e I n f o \ "
B E G I N
B L O C K \ " 0 4 0 9 0 4 b 0 \ "
B E G I N
V A L U E \ " C o m p a n y N a m e \ " , \ " $ { c o m p a n y _ n a m e } \ "
V A L U E \ " F i l e D e s c r i p t i o n \ " , \ " $ { f i l e _ d e s c r i p t i o n } \ "
V A L U E \ " F i l e V e r s i o n \ " , \ " $ { f i l e _ v e r s i o n } \ "
V A L U E \ " L e g a l C o p y r i g h t \ " , \ " $ { l e g a l _ c o p y r i g h t } \ "
V A L U E \ " O r i g i n a l F i l e n a m e \ " , \ " $ { o r i g i n a l _ f i l e _ n a m e } \ "
V A L U E \ " P r o d u c t N a m e \ " , \ " $ { p r o d u c t _ n a m e } \ "
V A L U E \ " P r o d u c t V e r s i o n \ " , \ " $ { p r o d u c t _ v e r s i o n } \ "
2020-05-11 15:04:21 +00:00
V A L U E \ " C o m m e n t s \ " , \ " $ { c o m m e n t s } \ "
V A L U E \ " L e g a l T r a d e m a r k s \ " , \ " $ { l e g a l _ t r a d e m a r k s } \ "
V A L U E \ " I n t e r n a l N a m e \ " , \ " $ { i n t e r n a l _ n a m e } \ "
2020-02-21 15:32:13 +00:00
E N D
E N D
B L O C K \ " V a r F i l e I n f o \ "
B E G I N
V A L U E \ " T r a n s l a t i o n \ " , 0 x 0 4 0 9 , 1 2 0 0
E N D
E N D
/ * E n d o f V e r s i o n i n f o * / \ n "
)
# We can't use the output of file generate as source so we work around
# this by generating the file under a different name and then copying
# the file in place using add custom command.
file ( GENERATE OUTPUT "${rc_file_output}.tmp"
C O N T E N T " $ { c o n t e n t s } "
)
2020-05-04 19:55:40 +00:00
if ( QT_GENERATOR_IS_MULTI_CONFIG )
set ( cfgs ${ CMAKE_CONFIGURATION_TYPES } )
set ( outputs "" )
foreach ( cfg ${ cfgs } )
string ( REPLACE "$<CONFIG>" "${cfg}" expanded_rc_file_output "${rc_file_output}" )
list ( APPEND outputs "${expanded_rc_file_output}" )
endforeach ( )
else ( )
set ( cfgs "${CMAKE_BUILD_TYPE}" )
set ( outputs "${rc_file_output}" )
endif ( )
2020-11-10 11:50:21 +00:00
# We would like to do the following:
# target_sources(${target} PRIVATE "$<$<CONFIG:${cfg}>:${output}>")
2021-07-16 16:22:35 +00:00
#
# However, https://gitlab.kitware.com/cmake/cmake/-/issues/20682 doesn't let us do that
# in CMake 3.19 and earlier.
# We can do it in CMake 3.20 and later.
# And we have to do it with CMake 3.21.0 to avoid a different issue
# https://gitlab.kitware.com/cmake/cmake/-/issues/22436
#
# So use the object lib work around for <= 3.19 and target_sources directly for later
# versions.
set ( use_obj_lib FALSE )
set ( end_target "${target}" )
if ( CMAKE_VERSION VERSION_LESS 3.20 )
set ( use_obj_lib TRUE )
set ( end_target "${target}_rc" )
add_library ( ${ target } _rc OBJECT "${output}" )
target_link_libraries ( ${ target } PRIVATE $< TARGET_OBJECTS:${target}_rc > )
endif ( )
2021-09-07 05:51:18 +00:00
set ( scope_args )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
set ( scope_args TARGET_DIRECTORY ${ end_target } )
endif ( )
2020-05-04 19:55:40 +00:00
while ( outputs )
list ( POP_FRONT cfgs cfg )
list ( POP_FRONT outputs output )
set ( input "${output}.tmp" )
add_custom_command ( OUTPUT "${output}"
D E P E N D S " $ { i n p u t } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ i f _ d i f f e r e n t " $ { i n p u t } " " $ { o u t p u t } "
2022-03-15 16:37:11 +00:00
V E R B A T I M
2020-05-04 19:55:40 +00:00
)
2021-09-07 05:51:18 +00:00
# We can't rely on policy CMP0118 since user project controls it
2021-10-25 11:23:47 +00:00
set_source_files_properties ( ${ output } ${ scope_args } PROPERTIES
G E N E R A T E D T R U E
C O M P I L E _ F L A G S " $ { e x t r a _ r c _ f l a g s } "
2021-09-07 05:51:18 +00:00
)
2021-07-16 16:22:35 +00:00
target_sources ( ${ end_target } PRIVATE "$<$<CONFIG:${cfg}>:${output}>" )
2020-05-04 19:55:40 +00:00
endwhile ( )
endif ( )
2020-02-21 15:32:13 +00:00
endfunction ( )
2020-04-17 12:36:09 +00:00
function ( __qt_get_relative_resource_path_for_file output_alias file )
get_property ( alias SOURCE ${ file } PROPERTY QT_RESOURCE_ALIAS )
if ( NOT alias )
set ( alias "${file}" )
endif ( )
set ( ${ output_alias } ${ alias } PARENT_SCOPE )
endfunction ( )
2022-07-14 15:23:15 +00:00
# Performs linking and propagation of the specified objects via the target's usage requirements.
# The objects may be given as generator expression.
2021-06-15 11:09:57 +00:00
#
2022-07-14 15:23:15 +00:00
# Arguments:
# EXTRA_CONDITIONS
# Conditions to be checked before linking the object files to the end-point executable.
# EXTRA_TARGET_LINK_LIBRARIES_CONDITIONS
# Conditions for the target_link_libraries call.
# EXTRA_TARGET_SOURCES_CONDITIONS
# Conditions for the target_sources call.
function ( __qt_internal_propagate_object_files target objects )
set ( options "" )
2021-06-15 11:09:57 +00:00
set ( single_args "" )
2022-07-14 15:23:15 +00:00
set ( extra_conditions_args
E X T R A _ C O N D I T I O N S
E X T R A _ T A R G E T _ L I N K _ L I B R A R I E S _ C O N D I T I O N S
E X T R A _ T A R G E T _ S O U R C E S _ C O N D I T I O N S
2021-06-15 11:09:57 +00:00
)
2022-07-14 15:23:15 +00:00
set ( multi_args ${ extra_conditions_args } )
cmake_parse_arguments ( arg "${options}" "${single_args}" "${multi_args}" ${ ARGN } )
2021-06-15 11:09:57 +00:00
2022-07-14 15:23:15 +00:00
# Collect additional conditions.
foreach ( arg IN LISTS extra_conditions_args )
string ( TOLOWER "${arg}" lcvar )
if ( arg_ ${ arg } )
list ( JOIN arg_ ${ arg } "," ${ lcvar } )
else ( )
set ( ${ lcvar } "$<BOOL:TRUE>" )
endif ( )
endforeach ( )
2021-06-15 11:09:57 +00:00
# Do not litter the static libraries
set ( not_static_condition
" $ < N O T : $ < S T R E Q U A L : $ < T A R G E T _ P R O P E R T Y : T Y P E > , S T A T I C _ L I B R A R Y > > "
)
# Check if link order matters for the Platform.
set ( platform_link_order_property
" $ < T A R G E T _ P R O P E R T Y : $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : P l a t f o r m , _ q t _ l i n k _ o r d e r _ m a t t e r s > "
)
set ( platform_link_order_condition
" $ < B O O L : $ { p l a t f o r m _ l i n k _ o r d e r _ p r o p e r t y } > "
)
2021-06-29 16:00:39 +00:00
# Check if link options are propagated according to CMP0099
# In user builds the _qt_cmp0099_policy_check is set to FALSE or $<TARGET_POLICY:CMP0099>
# depending on the used CMake version.
# See __qt_internal_check_cmp0099_available for details.
set ( cmp0099_policy_check_property
" $ < T A R G E T _ P R O P E R T Y : $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : P l a t f o r m , _ q t _ c m p 0 0 9 9 _ p o l i c y _ c h e c k > "
)
set ( link_objects_using_link_options_condition
" $ < B O O L : $ < G E N E X _ E V A L : $ { c m p 0 0 9 9 _ p o l i c y _ c h e c k _ p r o p e r t y } > > "
)
2021-06-15 11:09:57 +00:00
# Collect link conditions for the target_sources call.
string ( JOIN "" target_sources_genex
" $ < "
" $ < A N D : "
" $ { n o t _ s t a t i c _ c o n d i t i o n } , "
" $ { p l a t f o r m _ l i n k _ o r d e r _ c o n d i t i o n } , "
2021-06-29 16:00:39 +00:00
" $ < N O T : $ { l i n k _ o b j e c t s _ u s i n g _ l i n k _ o p t i o n s _ c o n d i t i o n } > , "
2022-07-14 15:23:15 +00:00
" $ { e x t r a _ t a r g e t _ s o u r c e s _ c o n d i t i o n s } , "
2021-06-15 11:09:57 +00:00
" $ { e x t r a _ c o n d i t i o n s } "
" > "
" : $ { o b j e c t s } > "
)
target_sources ( ${ target } INTERFACE
" $ { t a r g e t _ s o u r c e s _ g e n e x } "
)
2021-06-29 16:00:39 +00:00
# Collect link conditions for the target_link_options call.
string ( JOIN "" target_link_options_genex
" $ < "
" $ < A N D : "
" $ { n o t _ s t a t i c _ c o n d i t i o n } , "
" $ { p l a t f o r m _ l i n k _ o r d e r _ c o n d i t i o n } , "
" $ { l i n k _ o b j e c t s _ u s i n g _ l i n k _ o p t i o n s _ c o n d i t i o n } , "
" $ { e x t r a _ c o n d i t i o n s } "
" > "
" : $ { o b j e c t s } > "
)
# target_link_options works well since CMake 3.17 which has policy CMP0099 set to NEW for the
2021-10-09 13:06:03 +00:00
# minimum required CMake version greater than or equal to 3.17. The default is OLD. See
2021-06-29 16:00:39 +00:00
# https://cmake.org/cmake/help/git-master/policy/CMP0099.html for details.
# This provides yet another way of linking object libraries if user sets the policy to NEW
# before calling find_package(Qt...).
target_link_options ( ${ target } INTERFACE
" $ { t a r g e t _ l i n k _ o p t i o n s _ g e n e x } "
)
2021-06-15 11:09:57 +00:00
# Collect link conditions for the target_link_libraries call.
string ( JOIN "" target_link_libraries_genex
" $ < "
" $ < A N D : "
" $ { n o t _ s t a t i c _ c o n d i t i o n } , "
" $ < N O T : $ { p l a t f o r m _ l i n k _ o r d e r _ c o n d i t i o n } > , "
2022-07-14 15:23:15 +00:00
" $ { e x t r a _ t a r g e t _ l i n k _ l i b r a r i e s _ c o n d i t i o n s } , "
2021-06-15 11:09:57 +00:00
" $ { e x t r a _ c o n d i t i o n s } "
" > "
" : $ { o b j e c t s } > "
)
target_link_libraries ( ${ target } INTERFACE
" $ { t a r g e t _ l i n k _ l i b r a r i e s _ g e n e x } "
)
2022-07-14 15:23:15 +00:00
endfunction ( )
# Performs linking and propagation of the object library via the target's usage requirements.
# Arguments:
# NO_LINK_OBJECT_LIBRARY_REQUIREMENTS_TO_TARGET skip linking of ${object_library} to ${target}, only
# propagate $<TARGET_OBJECTS:${object_library}> by linking it to ${target}. It's useful in case
# if ${object_library} depends on the ${target}. E.g. resource libraries depend on the Core
# library so linking them back to Core will cause a CMake error.
#
# EXTRA_CONDITIONS object library specific conditions to be checked before link the object library
# to the end-point executable.
function ( __qt_internal_propagate_object_library target object_library )
set ( options NO_LINK_OBJECT_LIBRARY_REQUIREMENTS_TO_TARGET )
set ( single_args "" )
set ( multi_args EXTRA_CONDITIONS )
cmake_parse_arguments ( arg "${options}" "${single_args}" "${multi_args}" ${ ARGN } )
get_target_property ( is_imported ${ object_library } IMPORTED )
if ( NOT is_imported )
target_link_libraries ( ${ object_library } PRIVATE ${ QT_CMAKE_EXPORT_NAMESPACE } ::Platform )
_qt_internal_copy_dependency_properties ( ${ object_library } ${ target } PRIVATE_ONLY )
endif ( )
# After internal discussion we decided to not rely on the linker order that CMake
# offers, until CMake provides the guaranteed linking order that suites our needs in a
# future CMake version.
# All object libraries mark themselves with the _is_qt_propagated_object_library property.
# Using a finalizer approach we walk through the target dependencies and look for libraries
# using the _is_qt_propagated_object_library property. Then, objects of the collected libraries
# are moved to the beginning of the linker line using target_sources.
#
# Note: target_link_libraries works well with linkers other than ld. If user didn't enforce
# a finalizer we rely on linker to resolve circular dependencies between objects and static
# libraries.
set_property ( TARGET ${ object_library } PROPERTY _is_qt_propagated_object_library TRUE )
if ( NOT is_imported )
set_property ( TARGET ${ object_library } APPEND PROPERTY
E X P O R T _ P R O P E R T I E S _ i s _ q t _ p r o p a g a t e d _ o b j e c t _ l i b r a r y
)
endif ( )
# Keep the implicit linking if finalizers are not used.
set ( not_finalizer_mode_condition
" $ < N O T : $ < B O O L : $ < T A R G E T _ P R O P E R T Y : _ q t _ o b j e c t _ l i b r a r i e s _ f i n a l i z e r _ m o d e > > > "
)
# Use TARGET_NAME to have the correct namespaced name in the exports.
set ( objects "$<TARGET_OBJECTS:$<TARGET_NAME:${object_library}>>" )
__qt_internal_propagate_object_files ( ${ target } ${ objects }
E X T R A _ C O N D I T I O N S $ { a r g _ E X T R A _ C O N D I T I O N S }
E X T R A _ T A R G E T _ S O U R C E S _ C O N D I T I O N S $ { n o t _ f i n a l i z e r _ m o d e _ c o n d i t i o n }
E X T R A _ T A R G E T _ L I N K _ L I B R A R I E S _ C O N D I T I O N S $ { n o t _ f i n a l i z e r _ m o d e _ c o n d i t i o n }
)
2021-06-15 11:09:57 +00:00
if ( NOT arg_NO_LINK_OBJECT_LIBRARY_REQUIREMENTS_TO_TARGET )
# It's necessary to link the object library target, since we want to pass the object library
# dependencies to the 'target'. Interface linking doesn't add the objects of the library to
# the end-point linker line but propagates all the dependencies of the object_library added
# before or AFTER the line below.
target_link_libraries ( ${ target } INTERFACE ${ object_library } )
endif ( )
endfunction ( )
2020-04-17 12:36:09 +00:00
function ( __qt_propagate_generated_resource target resource_name generated_source_code output_generated_target )
get_target_property ( type ${ target } TYPE )
if ( type STREQUAL STATIC_LIBRARY )
2020-11-26 16:13:49 +00:00
get_target_property ( resource_count ${ target } _qt_generated_resource_target_count )
if ( NOT resource_count )
set ( resource_count "0" )
endif ( )
math ( EXPR resource_count "${resource_count} + 1" )
set_target_properties ( ${ target } PROPERTIES _qt_generated_resource_target_count ${ resource_count } )
set ( resource_target "${target}_resources_${resource_count}" )
2020-04-17 12:36:09 +00:00
add_library ( "${resource_target}" OBJECT "${generated_source_code}" )
2021-03-29 14:46:19 +00:00
target_compile_definitions ( "${resource_target}" PRIVATE
" $ < T A R G E T _ P R O P E R T Y : $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : C o r e , I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S > "
)
2021-07-08 12:01:59 +00:00
_qt_internal_set_up_static_runtime_library ( "${resource_target}" )
2021-04-23 14:23:36 +00:00
2021-03-29 13:28:16 +00:00
# Special handling is required for the Core library resources. The linking of the Core
# library to the resources adds a circular dependency. This leads to the wrong
2021-06-15 11:09:57 +00:00
# objects/library order in the linker command line, since the Core library target is
# resolved first.
2021-03-29 13:28:16 +00:00
if ( NOT target STREQUAL "Core" )
target_link_libraries ( ${ resource_target } INTERFACE ${ QT_CMAKE_EXPORT_NAMESPACE } ::Core )
endif ( )
2020-11-20 11:49:53 +00:00
set_property ( TARGET ${ resource_target } APPEND PROPERTY _qt_resource_name ${ resource_name } )
2020-04-17 12:36:09 +00:00
2020-11-25 16:54:53 +00:00
# Save the path to the generated source file, relative to the the current build dir.
# The path will be used in static library prl file generation to ensure qmake links
# against the installed resource object files.
# Example saved path:
# .rcc/qrc_qprintdialog.cpp
file ( RELATIVE_PATH generated_cpp_file_relative_path
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
" $ { g e n e r a t e d _ s o u r c e _ c o d e } " )
set_property ( TARGET ${ resource_target } APPEND PROPERTY
_ q t _ r e s o u r c e _ g e n e r a t e d _ c p p _ r e l a t i v e _ p a t h " $ { g e n e r a t e d _ c p p _ f i l e _ r e l a t i v e _ p a t h } " )
2021-06-15 11:09:57 +00:00
if ( target STREQUAL "Core" )
set ( skip_direct_linking NO_LINK_OBJECT_LIBRARY_REQUIREMENTS_TO_TARGET )
endif ( )
__qt_internal_propagate_object_library ( ${ target } ${ resource_target }
$ { s k i p _ d i r e c t _ l i n k i n g }
2021-06-10 17:01:35 +00:00
)
2021-06-03 11:51:48 +00:00
2020-04-17 12:36:09 +00:00
set ( ${ output_generated_target } "${resource_target}" PARENT_SCOPE )
else ( )
set ( ${ output_generated_target } "" PARENT_SCOPE )
target_sources ( ${ target } PRIVATE ${ generated_source_code } )
endif ( )
endfunction ( )
2020-11-05 16:05:44 +00:00
# Creates fake targets and adds resource files to IDE's tree
2021-07-12 11:38:42 +00:00
# FIXME: We shouldn't need to create a separate target for this, the files
# should be added to the actual target instead.
2020-11-05 16:05:44 +00:00
function ( _qt_internal_expose_source_file_to_ide target file )
2021-07-12 11:38:42 +00:00
set ( ide_target ${ target } _other_files )
2020-11-05 16:05:44 +00:00
if ( NOT TARGET ${ ide_target } )
add_custom_target ( ${ ide_target } SOURCES "${file}" )
2021-09-30 18:54:16 +00:00
# The new Xcode build system requires a common target to drive the generation of files,
# otherwise project configuration fails.
# By adding ${target} as a dependency of ${target}_other_files,
# it becomes the common target, so project configuration succeeds.
if ( CMAKE_GENERATOR STREQUAL "Xcode" )
add_dependencies ( ${ ide_target } ${ target } )
endif ( )
2020-11-05 16:05:44 +00:00
else ( )
set_property ( TARGET ${ ide_target } APPEND PROPERTY SOURCES "${file}" )
endif ( )
2022-06-14 15:28:54 +00:00
set ( scope_args )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
set ( scope_args TARGET_DIRECTORY "${target}" )
endif ( )
get_source_file_property (
t a r g e t _ d e p e n d e n c y " $ { f i l e } " $ { s c o p e _ a r g s } _ q t _ r e s o u r c e _ t a r g e t _ d e p e n d e n c y )
if ( target_dependency )
if ( NOT TARGET "${target_dependency}" )
message ( FATAL_ERROR "Target dependency on source file ${file} is not a cmake target." )
endif ( )
add_dependencies ( ${ ide_target } ${ target_dependency } )
endif ( )
2020-11-05 16:05:44 +00:00
endfunction ( )
2020-04-17 12:36:09 +00:00
#
# Process resources via file path instead of QRC files. Behind the
2021-07-12 11:36:13 +00:00
# scenes, it will generate a qrc file.
2020-04-17 12:36:09 +00:00
#
# The QRC Prefix is set via the PREFIX parameter.
#
# Alias settings for files need to be set via the QT_RESOURCE_ALIAS property
2021-07-12 11:36:13 +00:00
# via the set_source_files_properties() command.
2020-04-17 12:36:09 +00:00
#
# When using this command with static libraries, one or more special targets
# will be generated. Should you wish to perform additional processing on these
# targets pass a value to the OUTPUT_TARGETS parameter.
#
2020-10-01 08:58:02 +00:00
function ( _qt_internal_process_resource target resourceName )
2022-07-14 15:23:15 +00:00
cmake_parse_arguments ( rcc "BIG_RESOURCES"
" P R E F I X ; L A N G ; B A S E ; O U T P U T _ T A R G E T S ; D E S T I N A T I O N " " F I L E S ; O P T I O N S " $ { A R G N } )
2020-11-10 14:18:49 +00:00
if ( "${rcc_OPTIONS}" MATCHES "-binary" )
set ( isBinary TRUE )
2022-07-14 15:23:15 +00:00
if ( arg_BIG_RESOURCES )
message ( FATAL_ERROR "BIG_RESOURCES cannot be used together with the -binary option." )
endif ( )
endif ( )
if ( arg_BIG_RESOURCES AND CMAKE_GENERATOR STREQUAL "Xcode" AND IOS )
message ( WARNING
" D u e t o C M a k e l i m i t a t i o n s , t h e B I G _ R E S O U R C E S o p t i o n c a n ' t b e u s e d w h e n b u i l d i n g "
" f o r i O S . "
" S e e h t t p s : / / b u g r e p o r t s . q t . i o / b r o w s e / Q T B U G - 1 0 3 4 9 7 f o r d e t a i l s . "
" F a l l i n g b a c k t o u s i n g r e g u l a r r e s o u r c e s . "
)
set ( arg_BIG_RESOURCES OFF )
endif ( )
if ( arg_BIG_RESOURCES AND CMAKE_VERSION VERSION_LESS "3.17" )
message ( WARNING
" T h e B I G _ R E S O U R C E S o p t i o n d o e s n o t w o r k r e l i a b l y w i t h C M a k e < 3 . 1 7 . "
" C o n s i d e r u p g r a d i n g t o a m o r e r e c e n t C M a k e v e r s i o n o r d i s a b l e t h e B I G _ R E S O U R C E S "
" o p t i o n f o r o l d e r C M a k e v e r s i o n s . "
)
2020-11-10 14:18:49 +00:00
endif ( )
2020-04-17 12:36:09 +00:00
string ( REPLACE "/" "_" resourceName ${ resourceName } )
string ( REPLACE "." "_" resourceName ${ resourceName } )
2022-02-10 11:58:41 +00:00
set ( resource_files "" )
# Strip the ending slashes from the file_path. If paths contain slashes in the end
# set/get source properties works incorrect and may have the same QT_RESOURCE_ALIAS
# for two different paths. See https://gitlab.kitware.com/cmake/cmake/-/issues/23212
# for details.
foreach ( file_path IN LISTS rcc_FILES )
if ( file_path MATCHES "(.+)/$" )
set ( file_path "${CMAKE_MATCH_1}" )
endif ( )
list ( APPEND resource_files ${ file_path } )
endforeach ( )
2021-06-07 07:34:43 +00:00
if ( NOT "${rcc_BASE}" STREQUAL "" )
get_filename_component ( abs_base "${rcc_BASE}" ABSOLUTE )
foreach ( file_path IN LISTS resource_files )
get_source_file_property ( alias "${file_path}" QT_RESOURCE_ALIAS )
if ( alias STREQUAL "NOTFOUND" )
get_filename_component ( abs_file "${file_path}" ABSOLUTE )
file ( RELATIVE_PATH rel_file "${abs_base}" "${abs_file}" )
set_property ( SOURCE "${file_path}" PROPERTY QT_RESOURCE_ALIAS "${rel_file}" )
endif ( )
endforeach ( )
2020-04-17 12:36:09 +00:00
endif ( )
2021-08-17 18:15:11 +00:00
if ( ANDROID )
if ( COMMAND _qt_internal_collect_qml_root_paths )
_qt_internal_collect_qml_root_paths ( ${ target } ${ resource_files } )
endif ( )
endif ( )
2020-04-17 12:36:09 +00:00
if ( NOT rcc_PREFIX )
get_target_property ( rcc_PREFIX ${ target } QT_RESOURCE_PREFIX )
if ( NOT rcc_PREFIX )
2020-10-01 08:58:02 +00:00
message ( FATAL_ERROR "_qt_internal_process_resource() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default." )
2020-04-17 12:36:09 +00:00
endif ( )
endif ( )
2021-07-12 11:36:13 +00:00
if ( NOT resource_files )
2020-04-17 12:36:09 +00:00
if ( rcc_OUTPUT_TARGETS )
2021-09-02 04:40:46 +00:00
set ( ${ rcc_OUTPUT_TARGETS } "" PARENT_SCOPE )
2020-04-17 12:36:09 +00:00
endif ( )
return ( )
endif ( )
2021-09-07 05:51:18 +00:00
set ( generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${resourceName}.qrc" )
2020-04-17 12:36:09 +00:00
# Generate .qrc file:
# <RCC><qresource ...>
set ( qrcContents "<RCC>\n <qresource" )
if ( rcc_PREFIX )
string ( APPEND qrcContents " prefix=\" ${ rcc_PREFIX } \"")
endif ( )
if ( rcc_LANG )
string ( APPEND qrcContents " lang=\" ${ rcc_LANG } \"")
endif ( )
string ( APPEND qrcContents ">\n" )
set ( resource_dependencies )
2021-07-12 11:36:13 +00:00
foreach ( file IN LISTS resource_files )
2020-04-17 12:36:09 +00:00
__qt_get_relative_resource_path_for_file ( file_resource_path ${ file } )
if ( NOT IS_ABSOLUTE ${ file } )
set ( file "${CMAKE_CURRENT_SOURCE_DIR}/${file}" )
endif ( )
### FIXME: escape file paths to be XML conform
# <file ...>...</file>
string ( APPEND qrcContents " <file alias=\" ${ file_resource_path } \">")
string ( APPEND qrcContents "${file}</file>\n" )
list ( APPEND files "${file}" )
2022-05-13 17:14:20 +00:00
set ( scope_args )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
set ( scope_args TARGET_DIRECTORY ${ target } )
endif ( )
get_source_file_property (
t a r g e t _ d e p e n d e n c y $ { f i l e } $ { s c o p e _ a r g s } _ q t _ r e s o u r c e _ t a r g e t _ d e p e n d e n c y )
2020-04-17 12:36:09 +00:00
if ( NOT target_dependency )
list ( APPEND resource_dependencies ${ file } )
else ( )
if ( NOT TARGET ${ target_dependency } )
message ( FATAL_ERROR "Target dependency on resource file ${file} is not a cmake target." )
endif ( )
list ( APPEND resource_dependencies ${ target_dependency } )
endif ( )
2020-11-05 16:05:44 +00:00
_qt_internal_expose_source_file_to_ide ( ${ target } "${file}" )
2020-04-17 12:36:09 +00:00
endforeach ( )
# </qresource></RCC>
string ( APPEND qrcContents " </qresource>\n</RCC>\n" )
2020-10-30 15:46:40 +00:00
set ( template_file "${__qt_core_macros_module_base_dir}/Qt6CoreConfigureFileTemplate.in" )
set ( qt_core_configure_file_contents "${qrcContents}" )
configure_file ( "${template_file}" "${generatedResourceFile}" )
2020-10-14 14:04:44 +00:00
2021-07-12 11:36:13 +00:00
set ( rccArgs --name "${resourceName}" "${generatedResourceFile}" )
2022-07-14 15:23:15 +00:00
set ( rccArgsAllPasses "" )
2020-04-17 12:36:09 +00:00
if ( rcc_OPTIONS )
2022-07-14 15:23:15 +00:00
list ( APPEND rccArgsAllPasses ${ rcc_OPTIONS } )
2020-04-17 12:36:09 +00:00
endif ( )
# When cross-building, we use host tools to generate target code. If the host rcc was compiled
# with zstd support, it expects the target QtCore to be able to decompress zstd compressed
# content. This might be true with qmake where host tools are built as part of the
# cross-compiled Qt, but with CMake we build tools separate from the cross-compiled Qt.
# If the target does not support zstd (feature is disabled), tell rcc not to generate
# zstd related code.
if ( NOT QT_FEATURE_zstd )
2022-07-14 15:23:15 +00:00
list ( APPEND rccArgsAllPasses "--no-zstd" )
2020-04-17 12:36:09 +00:00
endif ( )
2020-11-10 14:18:49 +00:00
set_property ( SOURCE "${generatedResourceFile}" PROPERTY SKIP_AUTOGEN ON )
# Set output file name for rcc command
if ( isBinary )
2021-09-07 05:51:18 +00:00
set ( generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/${resourceName}.rcc" )
2020-11-10 14:18:49 +00:00
if ( rcc_DESTINATION )
# Add .rcc suffix if it's not specified by user
get_filename_component ( destinationRccExt "${rcc_DESTINATION}" LAST_EXT )
if ( "${destinationRccExt}" STREQUAL ".rcc" )
set ( generatedOutfile "${rcc_DESTINATION}" )
else ( )
set ( generatedOutfile "${rcc_DESTINATION}.rcc" )
endif ( )
endif ( )
2022-07-14 15:23:15 +00:00
elseif ( rcc_BIG_RESOURCES )
set ( generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${resourceName}_tmp.cpp" )
2020-11-10 14:18:49 +00:00
else ( )
2021-07-12 11:36:13 +00:00
set ( generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${resourceName}.cpp" )
2020-11-10 14:18:49 +00:00
endif ( )
2022-07-14 15:23:15 +00:00
set ( pass_msg )
if ( rcc_BIG_RESOURCES )
list ( PREPEND rccArgs --pass 1 )
set ( pass_msg " pass 1" )
endif ( )
2020-11-10 14:18:49 +00:00
list ( PREPEND rccArgs --output "${generatedOutfile}" )
2020-04-17 12:36:09 +00:00
# Process .qrc file:
2020-11-10 14:18:49 +00:00
add_custom_command ( OUTPUT "${generatedOutfile}"
2022-07-14 15:23:15 +00:00
C O M M A N D " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c " $ { r c c A r g s } $ { r c c A r g s A l l P a s s e s }
2020-04-17 12:36:09 +00:00
D E P E N D S
$ { r e s o u r c e _ d e p e n d e n c i e s }
$ { g e n e r a t e d R e s o u r c e F i l e }
" $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c "
2022-07-14 15:23:15 +00:00
C O M M E N T " R u n n i n g r c c $ { p a s s _ m s g } f o r r e s o u r c e $ { r e s o u r c e N a m e } "
2020-04-17 12:36:09 +00:00
V E R B A T I M )
2020-11-10 14:18:49 +00:00
if ( isBinary )
# Add generated .rcc target to 'all' set
2021-09-07 05:51:18 +00:00
add_custom_target ( binary_resource_ ${ resourceName } ALL DEPENDS "${generatedOutfile}" )
2022-07-14 15:23:15 +00:00
return ( )
endif ( )
# We can't rely on policy CMP0118 since user project controls it.
# We also want SKIP_AUTOGEN known in the target's scope, where we can.
set ( scope_args )
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
set ( scope_args TARGET_DIRECTORY ${ target } )
endif ( )
set_source_files_properties ( ${ generatedOutfile } ${ scope_args } PROPERTIES
S K I P _ A U T O G E N T R U E
G E N E R A T E D T R U E
S K I P _ U N I T Y _ B U I L D _ I N C L U S I O N T R U E
S K I P _ P R E C O M P I L E _ H E A D E R S T R U E
)
get_target_property ( target_source_dir ${ target } SOURCE_DIR )
if ( NOT target_source_dir STREQUAL CMAKE_CURRENT_SOURCE_DIR )
# We have to create a separate target in this scope that depends on
# the generated file, otherwise the original target won't have the
# required dependencies in place to ensure correct build order.
add_custom_target ( ${ target } _ ${ resourceName } DEPENDS ${ generatedOutfile } )
add_dependencies ( ${ target } ${ target } _ ${ resourceName } )
endif ( )
if ( rcc_BIG_RESOURCES )
set ( pass1OutputFile ${ generatedOutfile } )
set ( generatedOutfile
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / . r c c / q r c _ $ { r e s o u r c e N a m e } $ { C M A K E _ C X X _ O U T P U T _ E X T E N S I O N } " )
_qt_internal_add_rcc_pass2 (
R E S O U R C E _ N A M E $ { r e s o u r c e N a m e }
R C C _ O P T I O N S $ { r c c A r g s A l l P a s s e s }
O B J E C T _ L I B $ { t a r g e t } _ $ { r e s o u r c e N a m e } _ o b j
Q R C _ F I L E $ { g e n e r a t e d R e s o u r c e F i l e }
P A S S 1 _ O U T P U T _ F I L E $ { p a s s 1 O u t p u t F i l e }
O U T _ O B J E C T _ F I L E $ { g e n e r a t e d O u t f i l e }
2021-09-07 05:51:18 +00:00
)
2022-07-14 15:23:15 +00:00
get_target_property ( type ${ target } TYPE )
if ( type STREQUAL STATIC_LIBRARY )
# Create a custom target to trigger the generation of ${generatedOutfile}
set ( pass2_target ${ target } _ ${ resourceName } _pass2 )
add_custom_target ( ${ pass2_target } DEPENDS ${ generatedOutfile } )
add_dependencies ( ${ target } ${ pass2_target } )
# Propagate the object files to the target.
__qt_internal_propagate_object_files ( ${ target } "${generatedOutfile}" )
else ( )
target_sources ( ${ target } PRIVATE ${ generatedOutfile } )
2021-09-07 05:51:18 +00:00
endif ( )
2022-07-14 15:23:15 +00:00
else ( )
__qt_propagate_generated_resource ( ${ target } ${ resourceName } "${generatedOutfile}"
o u t p u t _ t a r g e t s )
2021-09-02 04:40:46 +00:00
endif ( )
2022-07-14 15:23:15 +00:00
set_property ( TARGET ${ target }
A P P E N D P R O P E R T Y _ q t _ g e n e r a t e d _ q r c _ f i l e s " $ { g e n e r a t e d R e s o u r c e F i l e } " )
2021-09-02 04:40:46 +00:00
if ( rcc_OUTPUT_TARGETS )
set ( ${ rcc_OUTPUT_TARGETS } "${output_targets}" PARENT_SCOPE )
2020-04-17 12:36:09 +00:00
endif ( )
endfunction ( )
2020-04-21 11:28:57 +00:00
2021-03-23 04:48:56 +00:00
macro ( _qt_internal_get_add_plugin_keywords option_args single_args multi_args )
set ( ${ option_args }
S T A T I C
2021-04-06 11:06:11 +00:00
S H A R E D
CMake: Create plugin initializers for static user plugins
Previously we only created object library static plugin initializers
for Qt plugins only, not user-project plugins.
The reason was that if a user tried to install the plugin target via
an export set, CMake would error out saying that the _init library is
not part of the same export set.
Introduce an OUTPUT_TARGETS option that would allow projects to get
the name of the generated _init target, so they can install it if
needed.
This was already done for qt6_add_qml_module, so we just introduce the
same option for qt6_add_plugin.
Now user static plugins will have an _init target created, which will
be propagated to consumers whenever the consumers link against the
plugin itself.
We also need an internal option to disable this propagation, because
it's handled a bit differently for Qt plugins which can be linked
either via finalizers or via usage requirements.
Amends 91c65dd80cdd2de666448c14202c0c63718152b6
As a result of the implementation change, cleanup example projects
to ensure that they build successfully (the important part is
specifying the CLASS_NAME).
Only plugandpaint works properly with both shared and static Qt
builds.
echoplugin works with a shared Qt build, but not a static one due to
some assumptions in the C++ code about shared plugins.
styleplugin doesn't seem to work properly neither with shared Qt
builds nor static Qt builds, at least on macOS. But it builds fine.
For some reason even if the plugin is found, the style is not applied.
Amends 4caac1feea025b0ad496141e8f16ab88c04c2caa
Pick-to: 6.2
Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-19 09:42:12 +00:00
_ _ Q T _ I N T E R N A L _ N O _ P R O P A G A T E _ P L U G I N _ I N I T I A L I Z E R
2021-03-23 04:48:56 +00:00
)
set ( ${ single_args }
2021-08-04 14:18:44 +00:00
# TODO: For backward compatibility / transitional use only, remove once all repos no longer
# use it
2021-03-23 04:48:56 +00:00
T Y P E
2021-08-04 14:18:44 +00:00
2021-09-21 07:44:03 +00:00
P L U G I N _ T Y P E # Internal use only, may be changed or removed
2021-03-23 04:48:56 +00:00
C L A S S _ N A M E
2021-09-21 07:44:03 +00:00
O U T P U T _ N A M E # Internal use only, may be changed or removed
CMake: Create plugin initializers for static user plugins
Previously we only created object library static plugin initializers
for Qt plugins only, not user-project plugins.
The reason was that if a user tried to install the plugin target via
an export set, CMake would error out saying that the _init library is
not part of the same export set.
Introduce an OUTPUT_TARGETS option that would allow projects to get
the name of the generated _init target, so they can install it if
needed.
This was already done for qt6_add_qml_module, so we just introduce the
same option for qt6_add_plugin.
Now user static plugins will have an _init target created, which will
be propagated to consumers whenever the consumers link against the
plugin itself.
We also need an internal option to disable this propagation, because
it's handled a bit differently for Qt plugins which can be linked
either via finalizers or via usage requirements.
Amends 91c65dd80cdd2de666448c14202c0c63718152b6
As a result of the implementation change, cleanup example projects
to ensure that they build successfully (the important part is
specifying the CLASS_NAME).
Only plugandpaint works properly with both shared and static Qt
builds.
echoplugin works with a shared Qt build, but not a static one due to
some assumptions in the C++ code about shared plugins.
styleplugin doesn't seem to work properly neither with shared Qt
builds nor static Qt builds, at least on macOS. But it builds fine.
For some reason even if the plugin is found, the style is not applied.
Amends 4caac1feea025b0ad496141e8f16ab88c04c2caa
Pick-to: 6.2
Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-19 09:42:12 +00:00
O U T P U T _ T A R G E T S
2021-03-23 04:48:56 +00:00
)
set ( ${ multi_args } )
endmacro ( )
2020-04-21 11:28:57 +00:00
function ( qt6_add_plugin target )
2021-03-23 04:48:56 +00:00
_qt_internal_get_add_plugin_keywords ( opt_args single_args multi_args )
cmake_parse_arguments ( PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}" )
2021-08-04 14:18:44 +00:00
# Handle the inconsistent TYPE/PLUGIN_TYPE keyword naming between commands
if ( arg_TYPE )
if ( arg_PLUGIN_TYPE AND NOT arg_TYPE STREQUAL arg_PLUGIN_TYPE )
message ( FATAL_ERROR
" B o t h T Y P E a n d P L U G I N _ T Y P E w e r e g i v e n a n d w e r e d i f f e r e n t . "
" O n l y o n e o f t h e t w o s h o u l d b e u s e d . "
)
endif ( )
message ( AUTHOR_WARNING
" T h e T Y P E k e y w o r d i s d e p r e c a t e d a n d w i l l b e r e m o v e d s o o n . P l e a s e u s e P L U G I N _ T Y P E i n s t e a d . " )
set ( arg_PLUGIN_TYPE "${arg_TYPE}" )
unset ( arg_TYPE )
endif ( )
2021-04-06 11:06:11 +00:00
if ( arg_STATIC AND arg_SHARED )
message ( FATAL_ERROR
" B o t h S T A T I C a n d S H A R E D o p t i o n s w e r e g i v e n . O n l y o n e o f t h e t w o s h o u l d b e u s e d . "
)
endif ( )
# Explicit option takes priority over the computed default.
if ( arg_STATIC )
set ( create_static_plugin TRUE )
elseif ( arg_SHARED )
set ( create_static_plugin FALSE )
2021-05-19 10:35:18 +00:00
else ( )
# If no explicit STATIC/SHARED option is set, default to the flavor of the Qt build.
if ( QT6_IS_SHARED_LIBS_BUILD )
set ( create_static_plugin FALSE )
else ( )
set ( create_static_plugin TRUE )
endif ( )
2021-04-06 11:06:11 +00:00
endif ( )
2021-05-19 10:35:18 +00:00
# The default of _qt_internal_add_library creates SHARED in a shared Qt build, so we need to
# be explicit about the MODULE.
if ( create_static_plugin )
set ( type_to_create STATIC )
2020-04-21 11:28:57 +00:00
else ( )
2021-05-19 10:35:18 +00:00
set ( type_to_create MODULE )
endif ( )
2022-06-22 15:05:23 +00:00
_qt_internal_add_library ( ${ target } ${ type_to_create } ${ arg_UNPARSED_ARGUMENTS } )
2021-05-19 10:35:18 +00:00
get_target_property ( target_type "${target}" TYPE )
if ( target_type STREQUAL "STATIC_LIBRARY" )
target_compile_definitions ( ${ target } PRIVATE QT_STATICPLUGIN )
2020-04-21 11:28:57 +00:00
endif ( )
set ( output_name ${ target } )
if ( arg_OUTPUT_NAME )
set ( output_name ${ arg_OUTPUT_NAME } )
endif ( )
set_property ( TARGET "${target}" PROPERTY OUTPUT_NAME "${output_name}" )
if ( ANDROID )
set_target_properties ( ${ target }
P R O P E R T I E S
2021-08-04 14:18:44 +00:00
L I B R A R Y _ O U T P U T _ N A M E " p l u g i n s _ $ { a r g _ P L U G I N _ T Y P E } _ $ { o u t p u t _ n a m e } "
2020-04-21 11:28:57 +00:00
)
endif ( )
2020-04-28 12:07:29 +00:00
# Derive the class name from the target name if it's not explicitly specified.
set ( plugin_class_name "" )
2021-08-04 14:18:44 +00:00
if ( NOT "${arg_PLUGIN_TYPE}" STREQUAL "qml_plugin" )
2021-03-23 04:48:56 +00:00
if ( NOT arg_CLASS_NAME )
set ( plugin_class_name "${target}" )
else ( )
set ( plugin_class_name "${arg_CLASS_NAME}" )
endif ( )
2021-06-11 15:02:45 +00:00
else ( )
# Make sure to set any passed-in class name for qml plugins as well, because it's used for
# building the qml plugin foo_init object libraries.
if ( arg_CLASS_NAME )
set ( plugin_class_name "${arg_CLASS_NAME}" )
else ( )
message ( FATAL_ERROR "Qml plugin target has no CLASS_NAME specified: '${target}'" )
endif ( )
2020-04-28 12:07:29 +00:00
endif ( )
2021-06-11 15:02:45 +00:00
2020-04-28 12:07:29 +00:00
set_target_properties ( ${ target } PROPERTIES QT_PLUGIN_CLASS_NAME "${plugin_class_name}" )
CMake: Create plugin initializers for static user plugins
Previously we only created object library static plugin initializers
for Qt plugins only, not user-project plugins.
The reason was that if a user tried to install the plugin target via
an export set, CMake would error out saying that the _init library is
not part of the same export set.
Introduce an OUTPUT_TARGETS option that would allow projects to get
the name of the generated _init target, so they can install it if
needed.
This was already done for qt6_add_qml_module, so we just introduce the
same option for qt6_add_plugin.
Now user static plugins will have an _init target created, which will
be propagated to consumers whenever the consumers link against the
plugin itself.
We also need an internal option to disable this propagation, because
it's handled a bit differently for Qt plugins which can be linked
either via finalizers or via usage requirements.
Amends 91c65dd80cdd2de666448c14202c0c63718152b6
As a result of the implementation change, cleanup example projects
to ensure that they build successfully (the important part is
specifying the CLASS_NAME).
Only plugandpaint works properly with both shared and static Qt
builds.
echoplugin works with a shared Qt build, but not a static one due to
some assumptions in the C++ code about shared plugins.
styleplugin doesn't seem to work properly neither with shared Qt
builds nor static Qt builds, at least on macOS. But it builds fine.
For some reason even if the plugin is found, the style is not applied.
Amends 4caac1feea025b0ad496141e8f16ab88c04c2caa
Pick-to: 6.2
Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-19 09:42:12 +00:00
# Create a plugin initializer object library for static plugins.
# It contains a Q_IMPORT_PLUGIN(QT_PLUGIN_CLASS_NAME) call.
# Project targets will automatically link to the plugin initializer whenever they link to the
# plugin target.
# The plugin init target name is stored in OUTPUT_TARGETS, so projects may install them.
# Qml plugin inits are handled in Qt6QmlMacros.
if ( NOT "${arg_PLUGIN_TYPE}" STREQUAL "qml_plugin"
A N D t a r g e t _ t y p e S T R E Q U A L " S T A T I C _ L I B R A R Y " )
__qt_internal_add_static_plugin_init_object_library ( "${target}" plugin_init_target )
if ( arg_OUTPUT_TARGETS )
set ( ${ arg_OUTPUT_TARGETS } ${ plugin_init_target } PARENT_SCOPE )
endif ( )
# We don't automatically propagate the plugin init library for Qt provided plugins, because
# there are 2 other code paths that take care of that, one involving finalizers and the
# other regular usage requirements.
if ( NOT arg___QT_INTERNAL_NO_PROPAGATE_PLUGIN_INITIALIZER )
__qt_internal_propagate_object_library ( "${target}" "${plugin_init_target}" )
endif ( )
2021-09-06 01:18:06 +00:00
else ( )
if ( arg_OUTPUT_TARGETS )
set ( ${ arg_OUTPUT_TARGETS } "" PARENT_SCOPE )
endif ( )
CMake: Create plugin initializers for static user plugins
Previously we only created object library static plugin initializers
for Qt plugins only, not user-project plugins.
The reason was that if a user tried to install the plugin target via
an export set, CMake would error out saying that the _init library is
not part of the same export set.
Introduce an OUTPUT_TARGETS option that would allow projects to get
the name of the generated _init target, so they can install it if
needed.
This was already done for qt6_add_qml_module, so we just introduce the
same option for qt6_add_plugin.
Now user static plugins will have an _init target created, which will
be propagated to consumers whenever the consumers link against the
plugin itself.
We also need an internal option to disable this propagation, because
it's handled a bit differently for Qt plugins which can be linked
either via finalizers or via usage requirements.
Amends 91c65dd80cdd2de666448c14202c0c63718152b6
As a result of the implementation change, cleanup example projects
to ensure that they build successfully (the important part is
specifying the CLASS_NAME).
Only plugandpaint works properly with both shared and static Qt
builds.
echoplugin works with a shared Qt build, but not a static one due to
some assumptions in the C++ code about shared plugins.
styleplugin doesn't seem to work properly neither with shared Qt
builds nor static Qt builds, at least on macOS. But it builds fine.
For some reason even if the plugin is found, the style is not applied.
Amends 4caac1feea025b0ad496141e8f16ab88c04c2caa
Pick-to: 6.2
Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-19 09:42:12 +00:00
endif ( )
2020-04-21 11:28:57 +00:00
target_compile_definitions ( ${ target } PRIVATE
Q T _ P L U G I N
Q T _ D E P R E C A T E D _ W A R N I N G S
)
2021-11-04 15:08:34 +00:00
if ( target_type STREQUAL "MODULE_LIBRARY" )
if ( NOT TARGET qt_internal_plugins )
add_custom_target ( qt_internal_plugins )
endif ( )
add_dependencies ( qt_internal_plugins ${ target } )
endif ( )
2020-04-21 11:28:57 +00:00
endfunction ( )
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_add_plugin )
2020-10-15 15:09:29 +00:00
qt6_add_plugin ( ${ ARGV } )
2021-09-06 01:18:06 +00:00
cmake_parse_arguments ( PARSE_ARGV 1 arg "" "OUTPUT_TARGETS" "" )
if ( arg_OUTPUT_TARGETS )
set ( ${ arg_OUTPUT_TARGETS } ${ ${arg_OUTPUT_TARGETS } } PARENT_SCOPE )
endif ( )
2021-08-31 05:56:00 +00:00
endfunction ( )
2020-04-21 11:28:57 +00:00
endif ( )
2020-05-12 12:57:23 +00:00
2021-05-19 10:35:18 +00:00
# Creates a library by forwarding arguments to add_library, applies some Qt naming file name naming
# conventions and ensures the execution of Qt specific finalizers.
function ( qt6_add_library target )
cmake_parse_arguments ( PARSE_ARGV 1 arg "MANUAL_FINALIZATION" "" "" )
_qt_internal_add_library ( "${target}" ${ arg_UNPARSED_ARGUMENTS } )
if ( arg_MANUAL_FINALIZATION )
# Caller says they will call qt6_finalize_target() themselves later
return ( )
endif ( )
# Defer the finalization if we can. When the caller's project requires
# CMake 3.19 or later, this makes the calls to this function concise while
# still allowing target property modification before finalization.
if ( CMAKE_VERSION VERSION_GREATER_EQUAL 3.19 )
# Need to wrap in an EVAL CODE or else ${target} won't be evaluated
# due to special behavior of cmake_language() argument handling
cmake_language ( EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})" )
else ( )
set_target_properties ( "${target}" PROPERTIES _qt_is_immediately_finalized TRUE )
qt6_finalize_target ( "${target}" )
endif ( )
endfunction ( )
# Creates a library target by forwarding the arguments to add_library.
#
# Applies some Qt specific behaviors:
# - If no type option is specified, rather than defaulting to STATIC it defaults to STATIC or SHARED
# depending on the Qt configuration.
# - Applies Qt specific prefixes and suffixes to file names depending on platform.
function ( _qt_internal_add_library target )
set ( opt_args
S T A T I C
S H A R E D
M O D U L E
I N T E R F A C E
O B J E C T
)
set ( single_args "" )
set ( multi_args "" )
cmake_parse_arguments ( PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}" )
set ( option_type_count 0 )
if ( arg_STATIC )
set ( type_to_create STATIC )
math ( EXPR option_type_count "${option_type_count}+1" )
elseif ( arg_SHARED )
set ( type_to_create SHARED )
math ( EXPR option_type_count "${option_type_count}+1" )
elseif ( arg_MODULE )
set ( type_to_create MODULE )
math ( EXPR option_type_count "${option_type_count}+1" )
elseif ( arg_INTERFACE )
set ( type_to_create INTERFACE )
math ( EXPR option_type_count "${option_type_count}+1" )
elseif ( arg_OBJECT )
set ( type_to_create OBJECT )
math ( EXPR option_type_count "${option_type_count}+1" )
endif ( )
if ( option_type_count GREATER 1 )
message ( FATAL_ERROR
" M u l t i p l e t y p e o p t i o n s w e r e g i v e n . O n l y o n e s h o u l d b e u s e d . "
)
endif ( )
# If no explicit type option is set, default to the flavor of the Qt build.
# This in contrast to CMake which defaults to STATIC.
if ( NOT arg_STATIC AND NOT arg_SHARED AND NOT arg_MODULE AND NOT arg_INTERFACE
A N D N O T a r g _ O B J E C T )
if ( QT6_IS_SHARED_LIBS_BUILD )
set ( type_to_create SHARED )
else ( )
set ( type_to_create STATIC )
endif ( )
endif ( )
add_library ( ${ target } ${ type_to_create } ${ arg_UNPARSED_ARGUMENTS } )
2021-07-29 09:53:03 +00:00
_qt_internal_set_up_static_runtime_library ( ${ target } )
2021-05-19 10:35:18 +00:00
2021-05-26 09:27:11 +00:00
if ( NOT type_to_create STREQUAL "INTERFACE" AND NOT type_to_create STREQUAL "OBJECT" )
_qt_internal_apply_win_prefix_and_suffix ( "${target}" )
endif ( )
2021-05-19 10:35:18 +00:00
if ( arg_MODULE AND APPLE )
# CMake defaults to using .so extensions for loadable modules, aka plugins,
# but Qt plugins are actually suffixed with .dylib.
set_property ( TARGET "${target}" PROPERTY SUFFIX ".dylib" )
endif ( )
if ( ANDROID )
qt6_android_apply_arch_suffix ( "${target}" )
endif ( )
endfunction ( )
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_add_library )
2021-05-19 10:35:18 +00:00
qt6_add_library ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
2021-05-19 10:35:18 +00:00
endif ( )
2021-12-14 15:27:58 +00:00
# TODO: Remove once all repositories use qt_internal_add_example instead of add_subdirectory.
macro ( _qt_internal_override_example_install_dir_to_dot )
# Set INSTALL_EXAMPLEDIR to ".".
# This overrides the install destination of unclean Qt example projects to install directly
# to CMAKE_INSTALL_PREFIX.
if ( QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT )
set ( INSTALL_EXAMPLEDIR "." )
2022-07-26 13:51:02 +00:00
set ( _qt_internal_example_dir_set_to_dot TRUE )
2021-12-14 15:27:58 +00:00
endif ( )
endmacro ( )
2020-10-14 11:20:55 +00:00
function ( qt6_allow_non_utf8_sources target )
2020-05-12 12:57:23 +00:00
set_target_properties ( "${target}" PROPERTIES QT_NO_UTF8_SOURCE TRUE )
endfunction ( )
CMake: Don't use std=gnu++11 when building Qt internal targets
The logic is a bit involved in qmake.
The Qt internal qt_common.prf adds CONFIG += strict_c++ which applies
to qt modules, qt plugins, qml plugins, qt helper libs, winmain and
qt_apps, qt_tools, but NOT tests (which is important because the tests
on Windows MinGW fail to build without the GNU extensions).
Then default_post.prf checks for the strict_c++ value and either uses
the strict or non-strict C++ standard flags. default_post.prf is
loaded for all qmake projects, not just the Qt internal ones.
Now CMake doesn't provide a transitive based option to disable C++
GNU extensions with a mechanism similar to target_compile_features.
It only provides the CXX_EXTENSIONS property and it's associated
CMAKE_CXX_EXTENSIONS variable. We can't set the variable at a
directory scope, because that is too coarse grained.
So we rely on setting the property via a function in every relevant
qt_add_<target> function.
Now the naming of the function is weird.
We name the function as qt_internal_<...>, because it's not meant to be
used by Qt users.
We prepend an underscore to the name because we need to place it in
Qt6CoreMacros, so that the function can be called by
qt_add_qml_module which IS a public function.
That's because in Qt5 load(qml_plugin) was private API, but in Qt 6 +
CMake we decided to make qt_add_qml_module() as public API.
Change-Id: Id014626b087d590e25cb46843f93d0c67fc36e44
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-04 09:29:00 +00:00
2020-10-01 08:58:02 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-31 05:56:00 +00:00
function ( qt_allow_non_utf8_sources )
2020-10-14 11:20:55 +00:00
qt6_allow_non_utf8_sources ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
2020-10-01 08:58:02 +00:00
endif ( )
CMake: Don't use std=gnu++11 when building Qt internal targets
The logic is a bit involved in qmake.
The Qt internal qt_common.prf adds CONFIG += strict_c++ which applies
to qt modules, qt plugins, qml plugins, qt helper libs, winmain and
qt_apps, qt_tools, but NOT tests (which is important because the tests
on Windows MinGW fail to build without the GNU extensions).
Then default_post.prf checks for the strict_c++ value and either uses
the strict or non-strict C++ standard flags. default_post.prf is
loaded for all qmake projects, not just the Qt internal ones.
Now CMake doesn't provide a transitive based option to disable C++
GNU extensions with a mechanism similar to target_compile_features.
It only provides the CXX_EXTENSIONS property and it's associated
CMAKE_CXX_EXTENSIONS variable. We can't set the variable at a
directory scope, because that is too coarse grained.
So we rely on setting the property via a function in every relevant
qt_add_<target> function.
Now the naming of the function is weird.
We name the function as qt_internal_<...>, because it's not meant to be
used by Qt users.
We prepend an underscore to the name because we need to place it in
Qt6CoreMacros, so that the function can be called by
qt_add_qml_module which IS a public function.
That's because in Qt5 load(qml_plugin) was private API, but in Qt 6 +
CMake we decided to make qt_add_qml_module() as public API.
Change-Id: Id014626b087d590e25cb46843f93d0c67fc36e44
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-04 09:29:00 +00:00
function ( _qt_internal_apply_strict_cpp target )
# Disable C, Obj-C and C++ GNU extensions aka no "-std=gnu++11".
# Similar to mkspecs/features/default_post.prf's CONFIG += strict_cpp.
# Allow opt-out via variable.
if ( NOT QT_ENABLE_CXX_EXTENSIONS )
get_target_property ( target_type "${target}" TYPE )
if ( NOT target_type STREQUAL "INTERFACE_LIBRARY" )
set_target_properties ( "${target}" PROPERTIES
C X X _ E X T E N S I O N S O F F
C _ E X T E N S I O N S O F F
O B J C _ E X T E N S I O N S O F F
O B J C X X _ E X T E N S I O N S O F F )
endif ( )
endif ( )
endfunction ( )
2021-04-23 14:23:36 +00:00
2021-04-15 10:35:46 +00:00
# Wraps a tool command with a script that contains the necessary environment for the tool to run
# correctly.
# _qt_internal_wrap_tool_command(var <SET|APPEND> <command> [args...])
# Arguments:
# APPEND Selects the 'append' mode for the out_variable argument.
# SET Selects the 'set' mode for the out_variable argument.
function ( _qt_internal_wrap_tool_command out_variable action )
set ( append FALSE )
if ( action STREQUAL "APPEND" )
set ( append TRUE )
elseif ( NOT action STREQUAL "SET" )
message ( FATAL_ERROR "Invalid action specified ${action}. Supported actions: SET, APPEND" )
endif ( )
set ( cmd COMMAND ${ QT_TOOL_COMMAND_WRAPPER_PATH } ${ ARGN } )
if ( append )
list ( APPEND ${ out_variable } ${ cmd } )
else ( )
set ( ${ out_variable } ${ cmd } )
endif ( )
set ( ${ out_variable } "${${out_variable}}" PARENT_SCOPE )
endfunction ( )
2021-04-23 14:23:36 +00:00
# Copies properties of the dependency to the target.
# Arguments:
# PROPERTIES list of properties to copy. If not specified the following properties are copied
# by default: INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES COMPILE_DEFINITIONS
# COMPILE_OPTIONS COMPILE_FEATURES
# PRIVATE_ONLY copy only private properties (without INTERFACE analogues). Optional.
# INTERFACE_ONLY copy only interface properties (without non-prefixed analogues). Optional.
# Note: Not all properties have INTERFACE properties analogues.
# See https://cmake.org/cmake/help/latest/prop_tgt/EXPORT_PROPERTIES.html for details.
#
# PRIVATE_ONLY and INTERFACE_ONLY in the same call are not allowed. Omit these options to copy
# both sets.
function ( _qt_internal_copy_dependency_properties target dependency )
cmake_parse_arguments ( arg "INTERFACE_ONLY;PRIVATE_ONLY" "" "PROPERTIES" ${ ARGN } )
if ( arg_PRIVATE_ONLY AND arg_INTERFACE_ONLY )
message ( " Both PRIVATE_ONLY and INTERFACE_ONLY options are set.\
P l e a s e u s e _ q t _ i n t e r n a l _ c o p y _ d e p e n d e n c y _ p r o p e r t i e s w i t h o u t t h e s e o p t i o n s t o c o p y a s e t o f
p r o p e r t i e s o f b o t h t y p e s . "
)
endif ( )
if ( arg_PROPERTIES )
set ( common_props_to_set ${ arg_PROPERTIES } )
else ( )
set ( common_props_to_set
I N C L U D E _ D I R E C T O R I E S S Y S T E M _ I N C L U D E _ D I R E C T O R I E S
C O M P I L E _ D E F I N I T I O N S C O M P I L E _ O P T I O N S
C O M P I L E _ F E A T U R E S
)
endif ( )
set ( props_to_set "" )
if ( NOT arg_INTERFACE_ONLY )
set ( props_to_set ${ common_props_to_set } )
endif ( )
if ( NOT arg_PRIVATE_ONLY )
list ( TRANSFORM common_props_to_set PREPEND INTERFACE_
O U T P U T _ V A R I A B L E i n t e r f a c e _ p r o p e r t i e s )
list ( APPEND props_to_set ${ interface_properties } )
endif ( )
foreach ( prop ${ props_to_set } )
set_property ( TARGET
" $ { t a r g e t } " A P P E N D P R O P E R T Y
$ { p r o p } " $ < T A R G E T _ P R O P E R T Y : $ { d e p e n d e n c y } , $ { p r o p } > "
)
endforeach ( )
endfunction ( )
2021-05-21 08:22:04 +00:00
function ( qt6_disable_unicode_defines target )
set_target_properties ( ${ target } PROPERTIES QT_NO_UNICODE_DEFINES TRUE )
endfunction ( )
2021-08-17 14:25:03 +00:00
# Finalizer function for the top-level user projects.
#
# This function is currently in Technical Preview.
# Its signature and behavior might change.
function ( qt6_finalize_project )
if ( NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
message ( "qt6_finalize_project is called not in the top-level CMakeLists.txt." )
endif ( )
if ( ANDROID )
2021-12-27 16:45:39 +00:00
_qt_internal_collect_apk_dependencies ( )
2021-08-17 14:25:03 +00:00
endif ( )
endfunction ( )
2021-05-21 08:22:04 +00:00
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
2021-08-17 14:25:03 +00:00
function ( qt_finalize_project )
if ( QT_DEFAULT_MAJOR_VERSION EQUAL 6 )
qt6_finalize_project ( )
else ( )
message ( FATAL_ERROR "qt_finalize_project() is only available in Qt 6." )
endif ( )
endfunction ( )
2021-08-31 05:56:00 +00:00
function ( qt_disable_unicode_defines )
2021-05-21 08:22:04 +00:00
qt6_disable_unicode_defines ( ${ ARGV } )
2021-08-31 05:56:00 +00:00
endfunction ( )
2021-05-21 08:22:04 +00:00
endif ( )
2021-11-29 23:29:34 +00:00
function ( _qt_internal_get_deploy_impl_dir var )
set ( ${ var } "${CMAKE_BINARY_DIR}/.qt" PARENT_SCOPE )
endfunction ( )
function ( _qt_internal_add_deploy_support deploy_support_file )
get_filename_component ( deploy_support_file "${deploy_support_file}" REALPATH )
set ( target ${ QT_CMAKE_EXPORT_NAMESPACE } ::Core )
get_target_property ( aliased_target ${ target } ALIASED_TARGET )
if ( aliased_target )
set ( target ${ aliased_target } )
endif ( )
get_property ( scripts TARGET ${ target } PROPERTY _qt_deploy_support_files )
if ( NOT "${deploy_support_file}" IN_LIST scripts )
set_property ( TARGET ${ target } APPEND PROPERTY
_ q t _ d e p l o y _ s u p p o r t _ f i l e s " $ { d e p l o y _ s u p p o r t _ f i l e } "
)
endif ( )
endfunction ( )
# Sets up the commands for use at install/deploy time
function ( _qt_internal_setup_deploy_support )
get_property ( cmake_role GLOBAL PROPERTY CMAKE_ROLE )
if ( NOT cmake_role STREQUAL "PROJECT" )
return ( )
endif ( )
# Always set QT_DEPLOY_SUPPORT in the caller's scope, even if we've generated
# the deploy support file in a previous call. The project may be calling
# find_package() from sibling directories with separate variable scopes.
_qt_internal_get_deploy_impl_dir ( deploy_impl_dir )
get_cmake_property ( is_multi_config GENERATOR_IS_MULTI_CONFIG )
if ( is_multi_config )
set ( QT_DEPLOY_SUPPORT "${deploy_impl_dir}/QtDeploySupport-$<CONFIG>.cmake" )
else ( )
set ( QT_DEPLOY_SUPPORT "${deploy_impl_dir}/QtDeploySupport.cmake" )
endif ( )
set ( QT_DEPLOY_SUPPORT "${QT_DEPLOY_SUPPORT}" PARENT_SCOPE )
get_property ( have_generated_file GLOBAL PROPERTY _qt_have_generated_deploy_support )
if ( have_generated_file )
return ( )
endif ( )
set_property ( GLOBAL PROPERTY _qt_have_generated_deploy_support TRUE )
include ( GNUInstallDirs )
set ( target ${ QT_CMAKE_EXPORT_NAMESPACE } ::Core )
get_target_property ( aliased_target ${ target } ALIASED_TARGET )
if ( aliased_target )
set ( target ${ aliased_target } )
endif ( )
# Make sure to look under the Qt bin dir with find_program, rather than randomly picking up
# a deployqt tool in the system.
# QT6_INSTALL_PREFIX is not set during Qt build, so add the hints conditionally.
set ( find_program_hints )
if ( QT6_INSTALL_PREFIX )
set ( find_program_hints HINTS ${ QT6_INSTALL_PREFIX } / ${ QT6_INSTALL_BINS } )
endif ( )
# In the generator expression logic below, we need safe_target_file because
# CMake evaluates expressions in both the TRUE and FALSE branches of $<IF:...>.
# We still need a target to give to $<TARGET_FILE:...> when we have no deploy
# tool, so we cannot use something like $<TARGET_FILE:macdeployqt> directly.
if ( APPLE AND NOT IOS )
find_program ( MACDEPLOYQT_EXECUTABLE macdeployqt
$ { f i n d _ p r o g r a m _ h i n t s } )
set ( fallback "$<$<BOOL:${MACDEPLOYQT_EXECUTABLE}>:${MACDEPLOYQT_EXECUTABLE}>" )
set ( target_if_exists "$<TARGET_NAME_IF_EXISTS:${QT_CMAKE_EXPORT_NAMESPACE}::macdeployqt>" )
set ( have_deploy_tool "$<BOOL:${target_if_exists}>" )
set ( safe_target_file
" $ < T A R G E T _ F I L E : $ < I F : $ { h a v e _ d e p l o y _ t o o l } , $ { t a r g e t _ i f _ e x i s t s } , $ { t a r g e t } > > " )
set ( __QT_DEPLOY_TOOL "$<IF:${have_deploy_tool},${safe_target_file},${fallback}>" )
elseif ( WIN32 )
find_program ( WINDEPLOYQT_EXECUTABLE windeployqt
$ { f i n d _ p r o g r a m _ h i n t s } )
set ( fallback "$<$<BOOL:${WINDEPLOYQT_EXECUTABLE}>:${WINDEPLOYQT_EXECUTABLE}>" )
set ( target_if_exists "$<TARGET_NAME_IF_EXISTS:${QT_CMAKE_EXPORT_NAMESPACE}::windeployqt>" )
set ( have_deploy_tool "$<BOOL:${target_if_exists}>" )
set ( safe_target_file
" $ < T A R G E T _ F I L E : $ < I F : $ { h a v e _ d e p l o y _ t o o l } , $ { t a r g e t _ i f _ e x i s t s } , $ { t a r g e t } > > " )
set ( __QT_DEPLOY_TOOL "$<IF:${have_deploy_tool},${safe_target_file},${fallback}>" )
else ( )
# Android is handled as a build target, not via this install-based approach.
# Therefore, we don't consider androiddeployqt here.
set ( __QT_DEPLOY_TOOL "" )
endif ( )
_qt_internal_add_deploy_support ( "${CMAKE_CURRENT_LIST_DIR}/Qt6CoreDeploySupport.cmake" )
file ( GENERATE OUTPUT "${QT_DEPLOY_SUPPORT}" CONTENT
" cmake_minimum_required ( VERSION 3.16...3.21 )
# These are part of the public API. Projects should use them to provide a
# consistent set of prefix-relative destinations.
if ( NOT QT_DEPLOY_BIN_DIR )
set ( QT_DEPLOY_BIN_DIR \"${CMAKE_INSTALL_BINDIR}\")
endif ( )
if ( NOT QT_DEPLOY_LIB_DIR )
set ( QT_DEPLOY_LIB_DIR \"${CMAKE_INSTALL_LIBDIR}\")
endif ( )
if ( NOT QT_DEPLOY_PLUGINS_DIR )
set ( QT_DEPLOY_PLUGINS_DIR \"plugins\")
endif ( )
if ( NOT QT_DEPLOY_QML_DIR )
set ( QT_DEPLOY_QML_DIR \"qml\")
endif ( )
if ( NOT QT_DEPLOY_PREFIX )
set ( QT_DEPLOY_PREFIX \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
endif ( )
if ( QT_DEPLOY_PREFIX STREQUAL \"\")
set ( QT_DEPLOY_PREFIX . )
endif ( )
# These are internal implementation details. They may be removed at any time.
set ( __QT_DEPLOY_SYSTEM_NAME \"${CMAKE_SYSTEM_NAME}\")
set ( __QT_DEPLOY_IS_SHARED_LIBS_BUILD \"${QT6_IS_SHARED_LIBS_BUILD}\")
set ( __QT_DEPLOY_TOOL \"${__QT_DEPLOY_TOOL}\")
set ( __QT_DEPLOY_IMPL_DIR \"${deploy_impl_dir}\")
set ( __QT_DEPLOY_VERBOSE \"${QT_ENABLE_VERBOSE_DEPLOYMENT}\")
set ( __QT_CMAKE_EXPORT_NAMESPACE \"${QT_CMAKE_EXPORT_NAMESPACE}\")
set ( __QT_DEPLOY_GENERATOR_IS_MULTI_CONFIG \"${is_multi_config}\")
set ( __QT_DEPLOY_ACTIVE_CONFIG \"$<CONFIG>\")
2022-02-17 14:19:11 +00:00
set ( __QT_NO_CREATE_VERSIONLESS_FUNCTIONS \"${QT_NO_CREATE_VERSIONLESS_FUNCTIONS}\")
set ( __QT_DEFAULT_MAJOR_VERSION \"${QT_DEFAULT_MAJOR_VERSION}\")
2021-11-29 23:29:34 +00:00
# Define the CMake commands to be made available during deployment.
set ( __qt_deploy_support_files
\ " $ < J O I N : $ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , _ q t _ d e p l o y _ s u p p o r t _ f i l e s > , \ "
\ " > \ "
)
foreach ( __qt_deploy_support_file IN LISTS __qt_deploy_support_files )
include ( \"\${__qt_deploy_support_file}\")
endforeach ( )
unset ( __qt_deploy_support_file )
unset ( __qt_deploy_support_files )
" )
endfunction ( )
# Note this needs to be a macro because it sets variables intended for the
# calling scope.
macro ( qt6_standard_project_setup )
# A parent project might want to prevent child projects pulled in with
# add_subdirectory() from changing the parent's preferred arrangement.
# They can set this variable to true to effectively disable this function.
if ( NOT QT_NO_STANDARD_PROJECT_SETUP )
# All changes below this point should not result in a change to an
# existing value, except for CMAKE_INSTALL_RPATH which may append new
# values (but no duplicates).
# Use standard install locations, provided by GNUInstallDirs. All
# platforms should have this included so that we know the
# CMAKE_INSTALL_xxxDIR variables will be set.
include ( GNUInstallDirs )
if ( WIN32 )
# Windows has no RPATH support, so we need all non-plugin DLLs in
# the same directory as application executables if we want to be
# able to run them without having to augment the PATH environment
# variable. Don't discard an existing value in case the project has
# already set this to somewhere else. Our setting is somewhat
# opinionated, so make it easy for projects to choose something else.
if ( NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } )
endif ( )
elseif ( NOT APPLE )
# Apart from Windows and Apple, most other platforms support RPATH
# and $ORIGIN. Make executables and non-static libraries use an
# install RPATH that allows them to find library dependencies if the
# project installs things to the directories defined by the
# CMAKE_INSTALL_xxxDIR variables (which is what CMake's defaults
# are based on).
file ( RELATIVE_PATH __qt_relDir
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ I N S T A L L _ B I N D I R }
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ I N S T A L L _ L I B D I R }
)
list ( APPEND CMAKE_INSTALL_RPATH $ ORIGIN $ ORIGIN/ ${ __qt_relDir } )
list ( REMOVE_DUPLICATES CMAKE_INSTALL_RPATH )
unset ( __qt_reldir )
endif ( )
# Turn these on by default, unless they are already set. Projects can
# always turn off any they really don't want after we return.
2022-01-26 09:20:27 +00:00
foreach ( auto_set IN ITEMS MOC UIC )
2021-11-29 23:29:34 +00:00
if ( NOT DEFINED CMAKE_AUTO ${ auto_set } )
set ( CMAKE_AUTO ${ auto_set } TRUE )
endif ( )
endforeach ( )
endif ( )
endmacro ( )
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
macro ( qt_standard_project_setup )
qt6_standard_project_setup ( ${ ARGV } )
endmacro ( )
endif ( )
2021-12-09 11:23:27 +00:00
# This function is currently in Technical Preview.
# Its signature and behavior might change.
2021-11-29 23:29:34 +00:00
function ( qt6_generate_deploy_app_script )
# We use a TARGET keyword option instead of taking the target as the first
# positional argument. This is to keep open the possibility of deploying
# an app for which we don't have a target (e.g. an application from a
# third party project that the caller may want to include in their own
# package). We would add an EXECUTABLE keyword for that, which would be
# mutually exclusive with the TARGET keyword.
set ( no_value_options
N O _ U N S U P P O R T E D _ P L A T F O R M _ E R R O R
)
set ( single_value_options
T A R G E T
F I L E N A M E _ V A R I A B L E
)
set ( multi_value_options "" )
cmake_parse_arguments ( PARSE_ARGV 0 arg
" $ { n o _ v a l u e _ o p t i o n s } " " $ { s i n g l e _ v a l u e _ o p t i o n s } " " $ { m u l t i _ v a l u e _ o p t i o n s } "
)
if ( arg_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}" )
endif ( )
if ( NOT arg_TARGET )
message ( FATAL_ERROR "TARGET must be specified" )
endif ( )
if ( NOT arg_FILENAME_VARIABLE )
message ( FATAL_ERROR "FILENAME_VARIABLE must be specified" )
endif ( )
# Create a file name that will be unique for this target and the combination
# of arguments passed to this command. This allows the project to call us
# multiple times with different arguments for the same target (e.g. to
# create deployment scripts for different scenarios).
string ( MAKE_C_IDENTIFIER "${arg_TARGET}" target_id )
string ( SHA1 args_hash "${ARGV}" )
string ( SUBSTRING "${args_hash}" 0 10 short_hash )
_qt_internal_get_deploy_impl_dir ( deploy_impl_dir )
set ( file_name "${deploy_impl_dir}/deploy_${target_id}_${short_hash}" )
get_cmake_property ( is_multi_config GENERATOR_IS_MULTI_CONFIG )
if ( is_multi_config )
string ( APPEND file_name "-$<CONFIG>" )
endif ( )
set ( ${ arg_FILENAME_VARIABLE } "${file_name}" PARENT_SCOPE )
if ( QT6_IS_SHARED_LIBS_BUILD )
set ( qt_build_type_string "shared Qt libs" )
else ( )
set ( qt_build_type_string "static Qt libs" )
endif ( )
if ( APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD )
# TODO: Handle non-bundle applications if possible.
get_target_property ( is_bundle ${ arg_TARGET } MACOSX_BUNDLE )
if ( NOT is_bundle )
message ( FATAL_ERROR
" E x e c u t a b l e t a r g e t s h a v e t o b e a p p b u n d l e s t o u s e t h i s c o m m a n d "
" o n A p p l e p l a t f o r m s . "
)
endif ( )
file ( GENERATE OUTPUT "${file_name}" CONTENT "
include ( ${ QT_DEPLOY_SUPPORT } )
2022-02-17 15:14:09 +00:00
qt6_deploy_runtime_dependencies (
2021-11-29 23:29:34 +00:00
E X E C U T A B L E $ < T A R G E T _ F I L E _ N A M E : $ { a r g _ T A R G E T } > . a p p
)
" )
elseif ( WIN32 AND QT6_IS_SHARED_LIBS_BUILD )
file ( GENERATE OUTPUT "${file_name}" CONTENT "
include ( ${ QT_DEPLOY_SUPPORT } )
2022-02-17 15:14:09 +00:00
qt6_deploy_runtime_dependencies (
2022-02-17 14:03:21 +00:00
E X E C U T A B L E \ $ { Q T _ D E P L O Y _ B I N _ D I R } / $ < T A R G E T _ F I L E _ N A M E : $ { a r g _ T A R G E T } >
2021-11-29 23:29:34 +00:00
G E N E R A T E _ Q T _ C O N F
) " )
elseif ( NOT arg_NO_UNSUPPORTED_PLATFORM_ERROR AND NOT QT_INTERNAL_NO_UNSUPPORTED_PLATFORM_ERROR )
# Currently we don't deploy runtime dependencies if cross-compiling or using a static Qt.
# We also don't do it if targeting Linux, but we could provide an option to do
# so if we had a deploy tool or purely CMake-based deploy implementation.
# Error out by default unless the project opted out of the error.
# This provides us a migration path in the future without breaking compatibility promises.
message ( FATAL_ERROR
" S u p p o r t f o r i n s t a l l i n g r u n t i m e d e p e n d e n c i e s i s n o t i m p l e m e n t e d f o r "
" t h i s t a r g e t platform ( ${ CMAKE_SYSTEM_NAME } , ${ qt_build_type_string } ) . "
)
else ( )
file ( GENERATE OUTPUT "${file_name}" CONTENT "
include ( ${ QT_DEPLOY_SUPPORT } )
_qt_internal_show_skip_runtime_deploy_message ( \"${qt_build_type_string}\")
" )
endif ( )
endfunction ( )
if ( NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS )
macro ( qt_generate_deploy_app_script )
qt6_generate_deploy_app_script ( ${ ARGV } )
endmacro ( )
endif ( )