Improve double call protection of qt_internal_generate_tool_command_wrapper
file(GENERATE) might fail if an unrelated configuration error happens, and yet QT_TOOL_COMMAND_WRAPPER_PATH would already be set. Set the cache variable only if generating was successful and replace the QT_TOOL_COMMAND_WRAPPER_PATH valiable check with GLOBAL property to protect the function from double call. For CMake versions higher than or equal to 3.18 replace 'file(GENERATE' call with 'file(CONFIGURE' to generate the wrapper at configure time with the use of a plain semicolon character. Pick-to: 6.2 Fixes: QTBUG-96870 Change-Id: Icf9c40f571d9c069043604f67ffcf2762966f6d0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
a36c84c6a3
commit
f19f729511
@ -266,15 +266,26 @@ 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)
|
||||
get_property(is_called GLOBAL PROPERTY _qt_internal_generate_tool_command_wrapper_called)
|
||||
if(NOT CMAKE_HOST_WIN32 OR is_called)
|
||||
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"
|
||||
set(tool_command_wrapper_path "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt_setup_tool_path.bat")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.18)
|
||||
# TODO: It doesn't make sense to generate wrapper at generator stage. Since file(CONFIGURE
|
||||
# was added in CMake 3.18, keep file(GENERATE for compatibility, until the minimum required
|
||||
# version is raised to 3.18.
|
||||
file(GENERATE OUTPUT "${tool_command_wrapper_path}" CONTENT
|
||||
"@echo off\r\nset PATH=${bindir}$<SEMICOLON>%PATH%\r\n%*")
|
||||
else()
|
||||
file(CONFIGURE OUTPUT "${tool_command_wrapper_path}" CONTENT
|
||||
"@echo off\r\nset PATH=${bindir};%PATH%\r\n%*")
|
||||
endif()
|
||||
set(QT_TOOL_COMMAND_WRAPPER_PATH "${tool_command_wrapper_path}"
|
||||
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%*")
|
||||
set_property(GLOBAL PROPERTY _qt_internal_generate_tool_command_wrapper_called TRUE)
|
||||
endfunction()
|
||||
qt_internal_generate_tool_command_wrapper()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user