Skip to content

Commit

Permalink
- Instead of assuming a hard-coded visual studio installation path, w…
Browse files Browse the repository at this point in the history
…e're now using the vswhere.exe tool that the visual studio installs in every system. This removes the necessity to specify the msvc path in the command line if visual studio was not installed into the default path. Option to override is still possible as before. (#1980)

Signed-off-by: cuneyt.ozdas <[email protected]>
Co-authored-by: Doug Walker <[email protected]>
  • Loading branch information
cozdas and doug-walker authored Sep 12, 2024
1 parent 9864d75 commit 62d3557
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
34 changes: 21 additions & 13 deletions share/dev/windows/ocio.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ set INSTALL_PATH_OK=n
rem Python location
set PYTHON_PATH=

rem Microsoft Visual Studio path
set MSVS_PATH=%programfiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
rem Microsoft Visual Studio path (will auto-find if not passed in cmd args)
set MSVS_PATH=

set DO_CONFIGURE=0

Expand Down Expand Up @@ -75,6 +75,22 @@ if NOT "%~1"=="" (
goto :args_loop
)

rem If not overridden by the cmd line args, find and use the latest Visual Studio
if NOT DEFINED MSVS_PATH (
for /f %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -format value -property installationPath -latest') do (
echo Found Visual Studio installation at '%%i'
set MSVS_PATH=%%i
)
)

IF NOT EXIST "!MSVS_PATH!" (
echo Could not find MS Visual Studio. Please provide the location for Microsoft Visual Studio vcvars64.bat or modify MSVS_PATH in the script.
rem The double dash are in quote here because otherwise the echo command thow an error.
echo "--msvs <path>"
echo E.g. C:\Program Files\Microsoft Visual Studio\2022\Enterprise\
exit /b
)

rem Testing the path before cmake
IF NOT EXIST "!VCPKG_PATH!" (
echo Could not find Vcpkg. Please provide the location for vcpkg or modify VCPKG_PATH in this script.
Expand Down Expand Up @@ -103,14 +119,6 @@ if NOT EXIST "!PYTHON_PATH!\python.exe" (
)
)

IF NOT EXIST "!MSVS_PATH!" (
echo Could not find MS Visual Studio. Please provide the location for Microsoft Visual Studio vcvars64.bat or modify MSVS_PATH in the script.
rem The double dash are in quote here because otherwise the echo command thow an error.
echo "--msvs <path>"
echo E.g. C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
exit /b
)

if !CUSTOM_BUILD_PATH!==0 (
echo.
set /p BUILD_PATH_OK=Default build path [!BUILD_PATH!] is used. Is it ok? [y/n]:
Expand Down Expand Up @@ -139,7 +147,7 @@ set INSTALL_PATH=!INSTALL_PATH!\!CMAKE_BUILD_TYPE!

rem ****************************************************************************************************************
rem Setting up the environment using MS Visual Studio batch script
set VCVARS64_PATH="!MSVS_PATH!\vcvars64.bat"
set VCVARS64_PATH="!MSVS_PATH!\VC\Auxiliary\Build\vcvars64.bat"
IF NOT EXIST !VCVARS64_PATH! (
rem Checking for vcvars64.bat script.
rem !MSVS_PATH! is checked earlier in the script
Expand Down Expand Up @@ -295,8 +303,8 @@ echo.
echo Optional options depending on the environment:
echo --python Python installation location
echo.
echo --msvs path where to find vcvars64.bat from Microsoft Visual Studio
echo Default: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
echo --msvs Root folder of the Microsoft Visual Studio. (E.g. C:\Program Files\Microsoft Visual Studio\2022)
echo Default: installation path of the latest Visual Studio found in the system by the vswhere.exe tool.
echo.
echo --b build location
echo Default: %TEMP%\OCIO\build
Expand Down
14 changes: 6 additions & 8 deletions share/dev/windows/ocio_deps.bat
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,14 @@ if ErrorLevel 1 (
)

echo Checking for Microsoft Visual Studio...
set MSVS=0
for /d %%a in ("%programfiles%\Microsoft Visual Studio*") do (
for /f "tokens=3 delims=\" %%x in ("%%a") do set MSVS=1
set MSVS_PATH=
for /f %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -format value -property installationPath -latest') do (
echo Found Visual Studio installation at '%%i'
set MSVS_PATH=%%i
)

if !MSVS!==0 (
echo No Microsoft Visual Studio installation was found in !programfiles!.
echo For non-standard installation path, please use the following option:
rem The double dash are in quote here because otherwise the echo command thow an error.
echo "ocio_deps --vs <path>"
if NOT EXIST !MSVS_PATH! (
echo No Microsoft Visual Studio installation was found in the system.
exit /b
)

Expand Down

0 comments on commit 62d3557

Please sign in to comment.