r5sdk/CreateSolution.bat
Kawe Mazidjatari 2174cc977c Automatically detect Visual Studio version
Automatically detect when using the batch file to create solution files. The system will search from Visual Studio 2017 up to Visual Studio 2022.
2023-05-14 14:16:12 +02:00

35 lines
810 B
Batchfile

@echo off
setlocal
set BUILDDIR=build_intermediate
REM Check for Visual Studio versions in order
for %%V in (15 16 17) do (
reg query "HKEY_CLASSES_ROOT\VisualStudio.DTE.%%V.0" >> nul 2>&1
if NOT ERRORLEVEL 1 (
if "%%V"=="15" (
set "CMAKE_GENERATOR=Visual Studio 15 2017"
) else if "%%V"=="16" (
set "CMAKE_GENERATOR=Visual Studio 16 2019"
) else if "%%V"=="17" (
set "CMAKE_GENERATOR=Visual Studio 17 2022"
)
echo Using Visual Studio %%V as generator.
goto :build
)
)
echo Could not find a supported version of Visual Studio; exiting...
exit /b 1
:build
if not exist "%BUILDDIR%" (
mkdir "%BUILDDIR%"
)
cd "%BUILDDIR%"
cmake .. -G"%CMAKE_GENERATOR%" -A"x64"
cd ..
echo Finished generating solution files.