qtbase/bin/qt-cmake-create.bat.in
Richard Moe Gustavsen 458be44aeb CMake/Windows: add setlocal to the Windows bat files
Several of the cmake bat files sets "script_dir_path". The problem
is that those assignments are not local to the script files. E.g
when qt-configure-module.bat gives it a value, and then call
qt-cmake.bat, qt-cmake.bat will assign it a different value. And
this value will overwrite the original value in
qt-configure-module.bat. So when the call returns, that script can
sometimes fail.

This happens (for unknown reasons) if the Qt source code path
contains a link to a different drive, created with mklink /d.
This is typical if Windows is running in a virtual machine, and
the Qt source code is shared with the host on e.g drive Q:.
In that case you might want to a folder on C: be a symlink to Q:, in
order to build Qt.

This patch will make sure we add "setlocal" in all the affected
bat files, so that any changes done to e.g "script_dir_path"
stays local to each file.

Pick-to: 6.5 6.6 6.7
Change-Id: Iee18e06eb0beece0c85c4345d9bfc0194e466e56
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-04 20:31:48 +01:00

20 lines
669 B
Batchfile

@echo off
setlocal
:: The directory of this script is the expanded absolute path of the "$qt_prefix/bin" directory.
set script_dir_path=%~dp0
:: Try to use original cmake, otherwise to make it relocatable, use any cmake found in PATH.
set cmake_path=@CMAKE_COMMAND@
if not exist "%cmake_path%" set cmake_path=cmake
if NOT "%~2" == "" goto :showhelp
if NOT "%~1" == "" (set PROJECT_DIR=%~1) else (set PROJECT_DIR=%cd%)
"%cmake_path%" -DPROJECT_DIR="%PROJECT_DIR%" -P "%script_dir_path%\@__GlobalConfig_relative_path_from_bin_dir_to_cmake_config_dir@\QtInitProject.cmake"
exit /b %errorlevel%
:showhelp
echo Usage
echo. qt-cmake-create <path/to/project>
exit /b 1