3 :: Copyright (C) 2018-2019 Intel Corporation
5 :: Licensed under the Apache License, Version 2.0 (the "License");
6 :: you may not use this file except in compliance with the License.
7 :: You may obtain a copy of the License at
9 :: http://www.apache.org/licenses/LICENSE-2.0
11 :: Unless required by applicable law or agreed to in writing, software
12 :: distributed under the License is distributed on an "AS IS" BASIS,
13 :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 :: See the License for the specific language governing permissions and
15 :: limitations under the License.
19 SETLOCAL EnableDelayedExpansion
22 set "SOLUTION_DIR64=%USERPROFILE%\Documents\Intel\OpenVINO\inference_engine_samples_build"
23 if "%InferenceEngine_DIR%"=="" set "InferenceEngine_DIR=%ROOT_DIR%\..\share"
32 ) else if "%1"=="VS2017" (
34 ) else if "%1"=="VS2019" (
37 echo Unrecognized option specified "%1"
38 echo Supported command line options: VS2015, VS2017, VS2019
43 if "%INTEL_OPENVINO_DIR%"=="" (
44 if exist "%ROOT_DIR%\..\..\bin\setupvars.bat" (
45 call "%ROOT_DIR%\..\..\bin\setupvars.bat"
47 if exist "%ROOT_DIR%\..\..\..\bin\setupvars.bat" (
48 call "%ROOT_DIR%\..\..\..\bin\setupvars.bat"
50 echo Failed to set the environment variables automatically
51 echo To fix, run the following command: ^<INSTALL_DIR^>\bin\setupvars.bat
52 echo where INSTALL_DIR is the OpenVINO installation directory.
58 if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
65 if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
67 cd "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
68 ) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
70 cd "%ProgramFiles%\Microsoft Visual Studio\Installer"
72 echo "vswhere tool is not found"
75 if !VSWHERE! == "true" (
76 if "!VS_VERSION!"=="" (
77 echo Searching the latest Visual Studio...
78 for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
82 echo Searching Visual Studio !VS_VERSION!...
83 for /f "usebackq tokens=*" %%i in (`vswhere -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
85 if not "!CUR_VS:%VS_VERSION%=!"=="!CUR_VS!" (
90 if exist "!VS_PATH!\MSBuild\14.0\Bin\MSBuild.exe" (
91 set "MSBUILD_BIN=!VS_PATH!\MSBuild\14.0\Bin\MSBuild.exe"
93 if exist "!VS_PATH!\MSBuild\15.0\Bin\MSBuild.exe" (
94 set "MSBUILD_BIN=!VS_PATH!\MSBuild\15.0\Bin\MSBuild.exe"
96 if exist "!VS_PATH!\MSBuild\Current\Bin\MSBuild.exe" (
97 set "MSBUILD_BIN=!VS_PATH!\MSBuild\Current\Bin\MSBuild.exe"
101 if "!MSBUILD_BIN!" == "" (
102 if "!VS_VERSION!"=="2015" (
103 if exist "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" (
104 set "MSBUILD_BIN=C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
105 set "MSBUILD_VERSION=14 2015"
107 ) else if "!VS_VERSION!"=="2017" (
108 if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe" (
109 set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
110 set "MSBUILD_VERSION=15 2017"
111 ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" (
112 set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe"
113 set "MSBUILD_VERSION=15 2017"
114 ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" (
115 set "MSBUILD_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"
116 set "MSBUILD_VERSION=15 2017"
120 if not "!MSBUILD_BIN:2019=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=16 2019"
121 if not "!MSBUILD_BIN:2017=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=15 2017"
122 if not "!MSBUILD_BIN:2015=!"=="!MSBUILD_BIN!" set "MSBUILD_VERSION=14 2015"
125 if "!MSBUILD_BIN!" == "" (
126 echo Build tools for Microsoft Visual Studio !VS_VERSION! cannot be found. If you use Visual Studio 2017, please download and install build tools from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017
130 if exist "%SOLUTION_DIR64%\CMakeCache.txt" del "%SOLUTION_DIR64%\CMakeCache.txt"
132 echo Creating Visual Studio %MSBUILD_VERSION% %PLATFORM% files in %SOLUTION_DIR64%... && ^
133 cd "%ROOT_DIR%" && cmake -E make_directory "%SOLUTION_DIR64%" && cd "%SOLUTION_DIR64%" && cmake -G "Visual Studio !MSBUILD_VERSION!" -A %PLATFORM% "%ROOT_DIR%"
136 echo ###############^|^| Build Inference Engine samples using MS Visual Studio (MSBuild.exe) ^|^|###############
138 echo "!MSBUILD_BIN!" Samples.sln /p:Configuration=Release
139 "!MSBUILD_BIN!" Samples.sln /p:Configuration=Release
140 if ERRORLEVEL 1 GOTO errorHandling