summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-04-15 12:35:46 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2021-04-30 23:11:29 +0200
commitb3f9c2b3d1312b51119b86f3930be5d531cb2817 (patch)
tree99d8bc82f23879458d8fb42dda651a8293e6ca2f /src/corelib
parent7a1fdcedfce0a67345dc74cd77be4a8ecf0cbc1e (diff)
Add _qt_internal_wrap_tool_command to replace QT_TOOL_PATH_SETUP_COMMAND
QT_TOOL_PATH_SETUP_COMMAND is used in COMMAND list when call add_custom_command/add_custom_target. This is necessary to setup the necessary environment for the tool to run correctly. This approach is weak according to CMake documentation: "If more than one COMMAND is specified they will be executed in order, but not necessarily composed into a stateful shell or batch script." This change introduces the _qt_internal_wrap_tool_command function that uses a wrapping script that setups necessary environment for the tool and runs it in a single shell. The script is generated by the _qt_generate_tool_command_wrapper function. Change-Id: Id5270b91619b607a0c1e3a19b8c706edec43f388 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index d6a06d930d..804718df86 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1720,6 +1720,30 @@ function(_qt_internal_apply_strict_cpp target)
endif()
endfunction()
+# 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()
+
# Copies properties of the dependency to the target.
# Arguments:
# PROPERTIES list of properties to copy. If not specified the following properties are copied