Set CMAKE_GENERATOR environment variable to ensure MSVC version used

This commit is contained in:
Jebtrix 2022-01-29 11:44:25 -05:00 committed by Lukáš Matěna
parent b094ea3c9a
commit 8ce9241c48

View File

@ -164,6 +164,9 @@ IF NOT EXIST "%MSVC_DIR%" (
@ECHO ERROR: Compatible Visual Studio installation not found. 1>&2 @ECHO ERROR: Compatible Visual Studio installation not found. 1>&2
GOTO :HELP GOTO :HELP
) )
REM Cmake always defaults to latest supported MSVC generator. Let's make sure it uses what we select.
FOR /F "tokens=* USEBACKQ" %%I IN (`^""%VSWHERE%" %MSVC_FILTER% -nologo -property catalog_productLineVersion^"`) DO SET PS_PRODUCT_VERSION=%%I
REM Give the user a chance to cancel if we found something odd. REM Give the user a chance to cancel if we found something odd.
IF "%PS_ASK_TO_CONTINUE%" EQU "" GOTO :BUILD_ENV IF "%PS_ASK_TO_CONTINUE%" EQU "" GOTO :BUILD_ENV
@ECHO. @ECHO.
@ -183,6 +186,7 @@ SET PS_CURRENT_STEP=environment
@ECHO ** Deps path: %PS_DESTDIR% @ECHO ** Deps path: %PS_DESTDIR%
@ECHO ** Using Microsoft Visual Studio installation found at: @ECHO ** Using Microsoft Visual Studio installation found at:
@ECHO ** %MSVC_DIR% @ECHO ** %MSVC_DIR%
SET CMAKE_GENERATOR=Visual Studio %PS_VERSION% %PS_PRODUCT_VERSION%
CALL "%MSVC_DIR%\Common7\Tools\vsdevcmd.bat" -arch=%PS_ARCH% -host_arch=%PS_ARCH_HOST% -app_platform=Desktop CALL "%MSVC_DIR%\Common7\Tools\vsdevcmd.bat" -arch=%PS_ARCH% -host_arch=%PS_ARCH_HOST% -app_platform=Desktop
IF %ERRORLEVEL% NEQ 0 GOTO :END IF %ERRORLEVEL% NEQ 0 GOTO :END
REM Need to reset the echo state after vsdevcmd.bat clobbers it. REM Need to reset the echo state after vsdevcmd.bat clobbers it.