0028824: Possibility to build OCCT 7.1.0 and above using Visual Studio 2008
[occt.git] / adm / templates / env.bat
CommitLineData
910970ab 1@echo off
2
3rem Use:
4rem - first argument specifies version of Visual Studio (vc8, vc9, or vc10),
5rem - second argument specifies architecture (win32 or win64),
6rem - third argument specifies build mode (Debug or Release)
7rem Default options are:
8rem vc8 win32 Release
9
10set "SCRIPTROOT=%~dp0"
11set "SCRIPTROOT=%SCRIPTROOT:~0,-1%"
910970ab 12
13rem ----- Reset values to defaults -----
14set "CASDEB="
72c37458 15set "VCVER=vc10"
16set "ARCH=64"
910970ab 17set "VCVARS="
18set "HAVE_TBB=false"
19set "HAVE_OPENCL=false"
20set "HAVE_FREEIMAGE=false"
e22105a9 21set "HAVE_FFMPEG=false"
910970ab 22set "HAVE_GL2PS=false"
910970ab 23set "HAVE_VTK=false"
1ce0716b 24set "HAVE_GLES2=false"
f60111dc 25set "HAVE_D3D=false"
e22105a9 26set "HAVE_ZLIB=false"
27set "HAVE_LIBLZMA=false"
910970ab 28set "CSF_OPT_INC="
29set "CSF_OPT_LIB32="
30set "CSF_OPT_LIB64="
31set "CSF_OPT_BIN32="
32set "CSF_OPT_BIN64="
33
e31a8e52 34if not ["%CASROOT%"] == [""] if exist "%SCRIPTROOT%\%CASROOT%" set "CASROOT=%SCRIPTROOT%\%CASROOT%"
35if ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
36
249dd6ed 37rem ----- Load local settings -----
38if exist "%CASROOT%\custom.bat" (
39 call "%CASROOT%\custom.bat" %1 %2 %3 %4 %5
40)
41
910970ab 42rem ----- Read script arguments (override local settings) -----
43if not ["%1"] == [""] set "VCVER=%1"
44if not ["%2"] == [""] set "ARCH=%2"
45if /I ["%ARCH%"] == ["win32"] set "ARCH=32"
46if /I ["%ARCH%"] == ["win64"] set "ARCH=64"
47if /I ["%3"] == ["debug"] set "CASDEB=d"
48if /I ["%3"] == ["d"] set "CASDEB=d"
316d77d9 49if /I ["%3"] == ["i"] set "CASDEB=i"
50if /I ["%3"] == ["relwithdeb"] set "CASDEB=i"
910970ab 51
249dd6ed 52rem Decode VCVER variable and define related ones:
53rem
54rem VCFMT - "vc" followed by full version number of Visual Studio toolset
55rem (same as VCVER without optional suffix "-uwp")
56rem VCLIB - name of folder contining binaries
57rem (same as VCVER except without third version in number)
58rem VCPROP - name of required Visual Studion Workload (starting with VS 2017)
59rem
60rem Note that for VS before 2015 (vc14) always
61rem VCFMT=VCLIB=VCVER and VCPROP=NativeDesktop
62
63rem Since VS 2017, environment variables like VS100COMNTOOLS are not defined
64rem any more, we can only use vswhere.exe tool to find Visual Studio.
65rem Add path to vswhere.exe
66set "PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
67
68rem for vc10-12, interpretation is trivial
69set VCFMT=%VCVER%
70set VCLIB=%VCVER:~0,4%
71set VCPROP=NativeDesktop
72rem vc14 and later can have optional suffix "-uwp"
73if "%VCVER:~-4%" == "-uwp" (
74 set VCFMT=%VCVER:~0,-4%
75 set VCLIB=%VCLIB%-uwp
76 set VCPROP=Universal
77)
78rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%
d6cda17a 79
48691eaa 80rem ----- Parsing of Visual Studio platform -----
81set "VisualStudioExpressName=VCExpress"
82
83if not "%DevEnvDir%" == "" (
84 rem If DevEnvDir is already defined (e.g. in custom.bat), use that value
71c810df 85) else if /I "%VCFMT%" == "vc9" (
86 set "DevEnvDir=%VS90COMNTOOLS%..\IDE"
48691eaa 87) else if /I "%VCFMT%" == "vc10" (
88 set "DevEnvDir=%VS100COMNTOOLS%..\IDE"
89) else if /I "%VCFMT%" == "vc11" (
90 set "DevEnvDir=%VS110COMNTOOLS%..\IDE"
91 rem Visual Studio Express starting from VS 2012 is called "for Windows Desktop"
92 rem and has a new name for executable - WDExpress
93 set "VisualStudioExpressName=WDExpress"
94) else if /I "%VCFMT%" == "vc12" (
95 set "DevEnvDir=%VS120COMNTOOLS%..\IDE"
96 set "VisualStudioExpressName=WDExpress"
97) else if /I "%VCFMT%" == "vc14" (
98 set "DevEnvDir=%VS140COMNTOOLS%..\IDE"
99) else if /I "%VCFMT%" == "vc141" (
100 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
101 set "DevEnvDir=%%i\Common7\IDE\"
102 )
c0f08310 103) else if /I "%VCFMT%" == "gcc" (
104 rem MinGW
48691eaa 105) else (
71c810df 106 echo Error: first argument ^(%VCVER%^) should specify supported version of Visual C++,
107 echo one of:
108 echo vc9 = VS 2008 ^(SP1^)
109 echo vc10 = VS 2010 ^(SP3^)
110 echo vc11 = VS 2012 ^(SP3^)
111 echo vc12 = VS 2013 ^(SP3^)
112 echo vc14 = VS 2015
113 echo vc141 = VS 2017
48691eaa 114 exit /B
115)
116
117rem ----- Parsing vcvarsall for qt samples and define PlatformToolset -----
71c810df 118if /I "%VCFMT%" == "vc9" (
119 set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
120 set "VCPlatformToolSet=v90"
121) else if /I "%VCFMT%" == "vc10" (
48691eaa 122 set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
123 set "VCPlatformToolSet=v100"
124) else if /I "%VCFMT%" == "vc11" (
125 set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
126 set "VCPlatformToolSet=v110"
127) else if /I "%VCFMT%" == "vc12" (
128 set "VCVARS=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
129 set "VCPlatformToolSet=v120"
130) else if /I "%VCFMT%" == "vc14" (
131 set "VCVARS=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat"
132 set "VCPlatformToolSet=v140"
133) else if /I "%VCFMT%" == "vc141" (
134 for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
135 set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
136 )
137 set "VCPlatformToolSet=v141"
c0f08310 138) else if /I "%VCFMT%" == "gcc" (
139 rem MinGW
48691eaa 140) else (
71c810df 141 echo Error: wrong VS identifier
142 exit /B
48691eaa 143)
144
72c37458 145set "CSF_OPT_LIB32D=%CSF_OPT_LIB32%"
146set "CSF_OPT_LIB64D=%CSF_OPT_LIB64%"
147set "CSF_OPT_BIN32D=%CSF_OPT_BIN32%"
148set "CSF_OPT_BIN64D=%CSF_OPT_BIN64%"
149set "CSF_OPT_LIB32I=%CSF_OPT_LIB32%"
150set "CSF_OPT_LIB64I=%CSF_OPT_LIB64%"
151set "CSF_OPT_BIN32I=%CSF_OPT_BIN32%"
152set "CSF_OPT_BIN64I=%CSF_OPT_BIN64%"
910970ab 153
154rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
155set "CSF_OPT_CMPL="
156set "PRODUCTS_DEFINES="
e22105a9 157if ["%HAVE_TBB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_TBB" & set "CSF_DEFINES=HAVE_TBB;%CSF_DEFINES%"
158if ["%HAVE_OPENCL%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENCL" & set "CSF_DEFINES=HAVE_OPENCL;%CSF_DEFINES%"
159if ["%HAVE_GL2PS%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GL2PS" & set "CSF_DEFINES=HAVE_GL2PS;%CSF_DEFINES%"
160if ["%HAVE_FREEIMAGE%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FREEIMAGE" & set "CSF_DEFINES=HAVE_FREEIMAGE;%CSF_DEFINES%"
161if ["%HAVE_FFMPEG%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_FFMPEG" & set "CSF_DEFINES=HAVE_FFMPEG;%CSF_DEFINES%"
162if ["%HAVE_VTK%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_VTK" & set "CSF_DEFINES=HAVE_VTK;%CSF_DEFINES%"
163if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_GLES2" & set "CSF_DEFINES=HAVE_GLES2;%CSF_DEFINES%"
164if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_D3D" & set "CSF_DEFINES=HAVE_D3D;%CSF_DEFINES%"
165if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%"
166if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%"
910970ab 167
168rem Eliminate VS warning
169if ["%CSF_DEFINES%"] == [""] set "CSF_DEFINES=;"
170
171rem ----- Optional 3rd-parties should be enabled by HAVE macros -----
172if not ["%PRODUCTS_DEFINES%"] == [""] set "CSF_OPT_CMPL=%CSF_OPT_CMPL% %PRODUCTS_DEFINES%"
173
174rem ----- Colect 3rd-parties additional include paths into compiler options -----
175for %%a in ("%CSF_OPT_INC:;=";"%") do (
176 set "anItem=%%~a"
177 if not ["%%~a"] == [""] call :concatCmplInc %%~a
178)
179
180rem ----- Colect 3rd-parties additional library paths (32-bit) into linker options -----
181set "OPT_LIB32="
182for %%a in ("%CSF_OPT_LIB32:;=";"%") do (
183 set "anItem=%%~a"
184 if not ["%%~a"] == [""] call :concatLib32 %%~a
185)
186
187rem ----- Colect 3rd-parties additional library paths (64-bit) into linker options -----
188set "OPT_LIB64="
189for %%a in ("%CSF_OPT_LIB64:;=";"%") do (
190 set "anItem=%%~a"
191 if not ["%%~a"] == [""] call :concatLib64 %%~a
192)
193
910970ab 194set "CSF_OPT_LNK32=%CSF_OPT_LNK32% %OPT_LIB32%"
910970ab 195set "CSF_OPT_LNK64=%CSF_OPT_LNK64% %OPT_LIB64%"
316d77d9 196set "CSF_OPT_LNK32D=%CSF_OPT_LNK32D% %OPT_LIB32%"
910970ab 197set "CSF_OPT_LNK64D=%CSF_OPT_LNK64D% %OPT_LIB64%"
316d77d9 198set "CSF_OPT_LNK32I=%CSF_OPT_LNK32I% %OPT_LIB32%"
199set "CSF_OPT_LNK64I=%CSF_OPT_LNK64I% %OPT_LIB64%"
910970ab 200
4b3541c6 201rem ----- Default paths to sub-folders (can be different in install env) -----
202if "%CSF_OCCTIncludePath%" == "" set "CSF_OCCTIncludePath=%CASROOT%\inc"
203if "%CSF_OCCTResourcePath%" == "" set "CSF_OCCTResourcePath=%CASROOT%\src"
204if "%CSF_OCCTSamplesPath%" == "" set "CSF_OCCTSamplesPath=%CASROOT%\samples"
205if "%CSF_OCCTDataPath%" == "" set "CSF_OCCTDataPath=%CASROOT%\data"
206if "%CSF_OCCTTestsPath%" == "" set "CSF_OCCTTestsPath=%CASROOT%\tests"
d6cda17a 207if "%CSF_OCCTBinPath%" == "" set "CSF_OCCTBinPath=%CASROOT%\win%ARCH%\%VCLIB%\bin%CASDEB%"
208if "%CSF_OCCTLibPath%" == "" set "CSF_OCCTLibPath=%CASROOT%\win%ARCH%\%VCLIB%\lib%CASDEB%"
910970ab 209
210rem ----- Set path to 3rd party and OCCT libraries -----
4b3541c6 211set "PATH=%CSF_OCCTBinPath%;%PATH%"
316d77d9 212if ["%CASDEB%"] == [""] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32%;%PATH%"
213if ["%CASDEB%"] == [""] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64%;%PATH%"
214if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32D%;%PATH%"
215if ["%CASDEB%"] == ["d"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64D%;%PATH%"
316d77d9 216if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["32"] set "PATH=%CSF_OPT_BIN32I%;%PATH%"
217if ["%CASDEB%"] == ["i"] if ["%ARCH%"] == ["64"] set "PATH=%CSF_OPT_BIN64I%;%PATH%"
910970ab 218
219rem ----- Set envoronment variables used by OCCT -----
220set CSF_LANGUAGE=us
221set MMGT_CLEAR=1
4b3541c6 222set "CSF_SHMessage=%CSF_OCCTResourcePath%\SHMessage"
223set "CSF_MDTVTexturesDirectory=%CSF_OCCTResourcePath%\Textures"
224set "CSF_ShadersDirectory=%CSF_OCCTResourcePath%\Shaders"
225set "CSF_XSMessage=%CSF_OCCTResourcePath%\XSMessage"
226set "CSF_TObjMessage=%CSF_OCCTResourcePath%\TObj"
227set "CSF_StandardDefaults=%CSF_OCCTResourcePath%\StdResource"
228set "CSF_PluginDefaults=%CSF_OCCTResourcePath%\StdResource"
229set "CSF_XCAFDefaults=%CSF_OCCTResourcePath%\StdResource"
230set "CSF_TObjDefaults=%CSF_OCCTResourcePath%\StdResource"
231set "CSF_StandardLiteDefaults=%CSF_OCCTResourcePath%\StdResource"
4b3541c6 232set "CSF_IGESDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
233set "CSF_STEPDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
234set "CSF_XmlOcafResource=%CSF_OCCTResourcePath%\XmlOcafResource"
235set "CSF_MIGRATION_TYPES=%CSF_OCCTResourcePath%\StdResource\MigrationSheet.txt"
910970ab 236
237rem Draw Harness special stuff
4b3541c6 238if exist "%CSF_OCCTResourcePath%\DrawResources\DrawDefault" (
239 set "DRAWDEFAULT=%CSF_OCCTResourcePath%\DrawResources\DrawDefault"
240)
241if exist "%CSF_OCCTResourcePath%\DrawResources" (
242 set "DRAWHOME=%CSF_OCCTResourcePath%\DrawResources"
910970ab 243 set "CSF_DrawPluginDefaults=%DRAWHOME%"
244)
910970ab 245goto :eof
246
247:concatCmplInc
248set "CSF_OPT_CMPL=%CSF_OPT_CMPL% -I%1"
249goto :eof
250
251:concatLib32
7c65581d 252rem Compiler options for Code::Blocks: -L for gcc/mingw and /LIBPATH for msvc
253rem set "OPT_LIB32=%OPT_LIB32% /LIBPATH:%1"
254set "OPT_LIB32=%OPT_LIB32% -L%1"
910970ab 255goto :eof
256
257:concatLib64
7c65581d 258rem Compiler options for Code::Blocks: -L for gcc/mingw and /LIBPATH for msvc
259rem set "OPT_LIB64=%OPT_LIB64% /LIBPATH:%1"
260set "OPT_LIB64=%OPT_LIB64% -L%1"
910970ab 261goto :eof