summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuild.cmake
diff options
context:
space:
mode:
authorAlexey Edelev <semlanik@gmail.com>2021-10-14 12:34:22 +0200
committerAlexey Edelev <semlanik@gmail.com>2021-10-15 15:53:23 +0200
commitf19f7295119d96b7606d475814328aac1d78c7cf (patch)
tree79bd22c05719c37efbcca63cbaadae75842eff18 /cmake/QtBuild.cmake
parenta36c84c6a3dca29afdb7741b16975c108be341ab (diff)
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>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r--cmake/QtBuild.cmake19
1 files changed, 15 insertions, 4 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index eff4cc9a26..b2cdd35667 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -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()