Slow Deprecation of FILENAME_VARIABLE, replacement by OUTPUT_SCRIPT

As discussed in the latest CMake API Review, we are deprecating the
FILENAME_VARIABLE variable name everywhere, and replacing it with
OUTPUT_SCRIPT.

[ChangeLog][CMake] The FILENAME_VARIABLE option of
qt_generate_deploy_script and qt_generate_deploy_app_script is now
deprecated, use OUTPUT_SCRIPT option instead.

Change-Id: Ic8be33eefbc48540166ea0fcf1d1948b052d4b8a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 2b2065bf35768cfbef833c588c8d93d5a09a76ba)
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Amir Masoud Abdol 2022-12-15 19:45:52 +01:00 committed by Amir Masoud Abdol
parent d980be646a
commit a0f953f019
7 changed files with 61 additions and 20 deletions

View File

@ -2804,9 +2804,13 @@ function(qt6_generate_deploy_script)
set(no_value_options "")
set(single_value_options
CONTENT
FILENAME_VARIABLE
OUTPUT_SCRIPT
NAME
TARGET
# TODO: For backward compatibility / transitional use only,
# remove at some point
FILENAME_VARIABLE
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 0 arg
@ -2815,9 +2819,26 @@ function(qt6_generate_deploy_script)
if(arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
if(NOT arg_FILENAME_VARIABLE)
message(FATAL_ERROR "FILENAME_VARIABLE must be specified")
# TODO: Remove when FILENAME_VARIABLE is fully removed
# Handle the slow deprecation of FILENAME_VARIABLE
if(arg_FILENAME_VARIABLE)
if(arg_OUTPUT_SCRIPT AND NOT arg_FILENAME_VARIABLE STREQUAL arg_OUTPUT_SCRIPT)
message(FATAL_ERROR
"Both FILENAME_VARIABLE and OUTPUT_SCRIPT were given and were different. "
"Only one of the two should be used."
)
endif()
message(AUTHOR_WARNING
"The FILENAME_VARIABLE keyword is deprecated and will be removed soon. Please use OUTPUT_SCRIPT instead.")
set(arg_OUTPUT_SCRIPT "${arg_FILENAME_VARIABLE}")
unset(arg_FILENAME_VARIABLE)
endif()
if(NOT arg_OUTPUT_SCRIPT)
message(FATAL_ERROR "OUTPUT_SCRIPT must be specified")
endif()
if("${arg_CONTENT}" STREQUAL "")
message(FATAL_ERROR "CONTENT must be specified")
endif()
@ -2851,22 +2872,22 @@ function(qt6_generate_deploy_script)
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}")
set(deploy_script "${deploy_impl_dir}/deploy_${target_id}_${short_hash}")
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
set(config_infix "-$<CONFIG>")
else()
set(config_infix "")
endif()
string(APPEND file_name "${config_infix}.cmake")
set(${arg_FILENAME_VARIABLE} "${file_name}" PARENT_SCOPE)
string(APPEND deploy_script "${config_infix}.cmake")
set(${arg_OUTPUT_SCRIPT} "${deploy_script}" PARENT_SCOPE)
set(boiler_plate "include(${QT_DEPLOY_SUPPORT})
include(\"\${CMAKE_CURRENT_LIST_DIR}/${arg_TARGET}-plugins${config_infix}.cmake\" OPTIONAL)
set(__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE \"${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE}\")
")
list(TRANSFORM arg_CONTENT REPLACE "\\$" "\$")
file(GENERATE OUTPUT ${file_name} CONTENT "${boiler_plate}${arg_CONTENT}")
file(GENERATE OUTPUT ${deploy_script} CONTENT "${boiler_plate}${arg_CONTENT}")
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@ -2892,6 +2913,10 @@ function(qt6_generate_deploy_app_script)
)
set(single_value_options
TARGET
OUTPUT_SCRIPT
# TODO: For backward compatibility / transitional use only,
# remove at some point
FILENAME_VARIABLE
)
set(qt_deploy_runtime_dependencies_options
@ -2915,8 +2940,24 @@ function(qt6_generate_deploy_app_script)
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")
# TODO: Remove when FILENAME_VARIABLE is fully removed
# Handle the slow deprecation of FILENAME_VARIABLE
if(arg_FILENAME_VARIABLE)
if(arg_OUTPUT_SCRIPT AND NOT arg_FILENAME_VARIABLE STREQUAL arg_OUTPUT_SCRIPT)
message(FATAL_ERROR
"Both FILENAME_VARIABLE and OUTPUT_SCRIPT were given and were different. "
"Only one of the two should be used."
)
endif()
message(AUTHOR_WARNING
"The FILENAME_VARIABLE keyword is deprecated and will be removed soon. Please use OUTPUT_SCRIPT instead.")
set(arg_OUTPUT_SCRIPT "${arg_FILENAME_VARIABLE}")
unset(arg_FILENAME_VARIABLE)
endif()
if(NOT arg_OUTPUT_SCRIPT)
message(FATAL_ERROR "OUTPUT_SCRIPT must be specified")
endif()
if(QT6_IS_SHARED_LIBS_BUILD)
@ -2927,7 +2968,7 @@ function(qt6_generate_deploy_app_script)
set(generate_args
TARGET ${arg_TARGET}
FILENAME_VARIABLE file_name
OUTPUT_SCRIPT deploy_script
)
set(common_deploy_args "")
@ -2993,7 +3034,7 @@ _qt_internal_show_skip_runtime_deploy_message(\"${qt_build_type_string}\")
")
endif()
set(${arg_FILENAME_VARIABLE} "${file_name}" PARENT_SCOPE)
set(${arg_OUTPUT_SCRIPT} "${deploy_script}" PARENT_SCOPE)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)

View File

@ -17,7 +17,7 @@ install(TARGETS MyApp
qt_generate_deploy_script(
TARGET MyApp
FILENAME_VARIABLE deploy_script
OUTPUT_SCRIPT deploy_script
CONTENT "
qt_deploy_runtime_dependencies(
EXECUTABLE $<TARGET_FILE_NAME:MyApp>

View File

@ -64,7 +64,7 @@ as shown in the example below. This helps avoid hard-coding an absolute path.
\badcode
# The following script must only be executed at install time
qt_generate_deploy_script(
FILENAME_VARIABLE deploy_script
OUTPUT_SCRIPT deploy_script
CONTENT "
qt_deploy_qt_conf(\"\${QT_DEPLOY_PREFIX}/\${QT_DEPLOY_BIN_DIR}/qt.conf\"
DATA_DIR \"./custom_data_dir\"

View File

@ -20,7 +20,7 @@
\badcode
qt_generate_deploy_app_script(
TARGET target
FILENAME_VARIABLE var_name
OUTPUT_SCRIPT <var>
[NO_TRANSLATIONS]
[NO_UNSUPPORTED_PLATFORM_ERROR]
[PRE_INCLUDE_REGEXES regexes...]
@ -47,7 +47,7 @@ determined by \l{GNUInstallDirs} (except for macOS app bundles, which follow
Apple's requirements instead).
The command generates a script whose name will be stored in the variable named
by the \c{FILENAME_VARIABLE} option. That script is only written at CMake
by the \c{OUTPUT_SCRIPT} option. That script is only written at CMake
generation time. It is intended to be used with the \l{install(SCRIPT)} command,
which should come after the application's target has been installed using
\l{install(TARGETS)}.
@ -105,7 +105,7 @@ install(TARGETS MyApp
qt_generate_deploy_app_script(
TARGET MyApp
FILENAME_VARIABLE deploy_script
OUTPUT_SCRIPT deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})

View File

@ -18,7 +18,7 @@
\badcode
qt_generate_deploy_script(
FILENAME_VARIABLE var_name
OUTPUT_SCRIPT <var>
[TARGET target]
[NAME script_name]
[CONTENT content]
@ -30,7 +30,7 @@ qt_generate_deploy_script(
\section1 Description
The command generates a script whose full file path will be stored in the
variable named by the \c{FILENAME_VARIABLE} option. That script is only written
variable named by the \c{OUTPUT_SCRIPT} option. That script is only written
at CMake generation time. It is intended to be used with the \l{install(SCRIPT)}
command, which should come after the application's target has been installed
using \l{install(TARGETS)}.

View File

@ -26,7 +26,7 @@ set(helper_app_path "\${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:HelperApp>")
# Generate a deployment script to be executed at install time
qt_generate_deploy_script(
TARGET MyApp
FILENAME_VARIABLE deploy_script
OUTPUT_SCRIPT deploy_script
CONTENT "
qt_deploy_runtime_dependencies(
EXECUTABLE \"${executable_path}\"

View File

@ -33,7 +33,7 @@ function(create_test_executable target)
qt_generate_deploy_app_script(
TARGET ${target}
FILENAME_VARIABLE deploy_script
OUTPUT_SCRIPT deploy_script
# Don't fail at configure time on unsupported platforms
NO_UNSUPPORTED_PLATFORM_ERROR
)