You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is easy to reach an infinite loop when using the windows cmake scripts. For example, if you call script\cmake_vs2022.bat build -DURHO3D_HOME="C:\Path\To\U3D\Build", you will get such a loop, as cmake_generic.bat only recognizes -D options when they are followed by a space.
Good observation. I ran into this somedays back while using Emcripten's emcmake which emits the CMAKE_TOOLCHAIN_FILE and CMAKE_CROSSCOMPILING_EMULATOR build options with no space after -D. I have a slightly different change I made to the loop section:
:loop:: Cache the first argument so substring operation can be performed on itset"ARG1=%~1"ifnot"%~1"=="" (
if"%~1"=="-D" (
if"%~2"=="MINGW"if"%~3"=="1"set"OPTS=-G "MinGW Makefiles""if"%~2"=="URHO3D_64BIT"if"%~3"=="1"set"arch=-A x64"if"%~2"=="URHO3D_64BIT"if"%~3"=="0"set"arch=-A Win32"set"BUILD_OPTS=%BUILD_OPTS% -D %~2=%~3"shiftshiftshift
) elseif"%ARG1:~0,2%"=="-D" (
:: Handle case where there is no space after "-D" in the optionsset"BUILD_OPTS=%BUILD_OPTS%%~1=%~2"shiftshift
)
if"%~1"=="-VS" (
set"OPTS=-G "Visual Studio %~2"%arch%%TOOLSET%"shiftshift
)
if"%~1"=="-G" (
:: Add quote to MinGW Makefiles flag since Emscripten's `emcmake` emits them without quotes and this breaks CMakeif"%~2"=="MinGW Makefiles" (
set"OPTS=%OPTS% -G "%~2""
) else (
set"OPTS=%OPTS% -G %~2"
)
shiftshift
)
goto loop
)
Right after checking if "%~1" == "-D" an else part checks if %~1 starts with -D and if so appends %~1=%~2 to %BUILD_OPTS%.
I also noticed that emcmake emits the MinGW makefiles generator flag without quotes around MinGW Makefiles and this breaks CMake. This is also handled in the change I made.
It is easy to reach an infinite loop when using the windows cmake scripts. For example, if you call
script\cmake_vs2022.bat build -DURHO3D_HOME="C:\Path\To\U3D\Build"
, you will get such a loop, as cmake_generic.bat only recognizes-D
options when they are followed by a space.The loop
should be changed to something like
to prevent the possibility of endlessly looping on an unrecognized argument.
The text was updated successfully, but these errors were encountered: