diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-04-15 12:35:46 +0200 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-04-30 23:11:29 +0200 |
commit | b3f9c2b3d1312b51119b86f3930be5d531cb2817 (patch) | |
tree | 99d8bc82f23879458d8fb42dda651a8293e6ca2f /cmake | |
parent | 7a1fdcedfce0a67345dc74cd77be4a8ecf0cbc1e (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 'cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index f22aad3e34..18027848c2 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -260,9 +260,24 @@ function(qt_setup_tool_path_command) list(APPEND command COMMAND) list(APPEND command set PATH=${bindir}$<SEMICOLON>%PATH%) set(QT_TOOL_PATH_SETUP_COMMAND "${command}" CACHE INTERNAL "internal command prefix for tool invocations" FORCE) + # QT_TOOL_PATH_SETUP_COMMAND is deprecated. Please use _qt_internal_wrap_tool_command + # instead. endfunction() qt_setup_tool_path_command() +function(qt_internal_generate_tool_command_wrapper) + if(NOT CMAKE_HOST_WIN32 OR DEFINED QT_TOOL_COMMAND_WRAPPER_PATH) + return() + endif() + set(bindir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}") + file(TO_NATIVE_PATH "${bindir}" bindir) + set(QT_TOOL_COMMAND_WRAPPER_PATH "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt_setup_tool_path.bat" + CACHE INTERNAL "Path to the wrapper of the tool commands") + file(GENERATE OUTPUT "${QT_TOOL_COMMAND_WRAPPER_PATH}" CONTENT + "@echo off\r\nset PATH=${bindir}$<SEMICOLON>%PATH%\r\n%*") +endfunction() +qt_internal_generate_tool_command_wrapper() + # Platform define path, etc. if(WIN32) set(QT_DEFAULT_PLATFORM_DEFINITIONS WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE) |