xref: /oneTBB/integration/windows/env/vars.bat (revision 5f1ae0dc)
1@echo off
2REM
3REM Copyright (c) 2005-2023 Intel Corporation
4REM
5REM Licensed under the Apache License, Version 2.0 (the "License");
6REM you may not use this file except in compliance with the License.
7REM You may obtain a copy of the License at
8REM
9REM     http://www.apache.org/licenses/LICENSE-2.0
10REM
11REM Unless required by applicable law or agreed to in writing, software
12REM distributed under the License is distributed on an "AS IS" BASIS,
13REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14REM See the License for the specific language governing permissions and
15REM limitations under the License.
16REM
17
18REM Syntax:
19REM  %SCRIPT_NAME% [^<arch^>] [^<vs^>]
20REM    ^<arch^> should be one of the following
21REM        ia32         : Set up for IA-32  architecture
22REM        intel64      : Set up for Intel(R) 64  architecture
23REM    if ^<arch^> is not set Intel(R) 64 architecture will be used
24REM    ^<vs^> should be one of the following
25REM        vs2019      : Set to use with Microsoft Visual Studio 2019 runtime DLLs
26REM        vs2022      : Set to use with Microsoft Visual Studio 2022 runtime DLLs
27REM        all         : Set to use oneTBB statically linked with Microsoft Visual C++ runtime
28REM    if ^<vs^> is not set oneTBB dynamically linked with Microsoft Visual C++ runtime will be used.
29
30set "SCRIPT_NAME=%~nx0"
31set "TBB_SCRIPT_DIR=%~d0%~p0"
32set "TBBROOT=%TBB_SCRIPT_DIR%.."
33
34:: Set the default arguments
35set TBB_TARGET_ARCH=intel64
36set TBB_ARCH_SUFFIX=
37set TBB_TARGET_VS=vc14
38
39:ParseArgs
40:: Parse the incoming arguments
41if /i "%1"==""             goto ParseLayout
42if /i "%1"=="ia32"         (set TBB_TARGET_ARCH=ia32)     & shift & goto ParseArgs
43if /i "%1"=="intel64"      (set TBB_TARGET_ARCH=intel64)  & shift & goto ParseArgs
44if /i "%1"=="vs2019"       (set TBB_TARGET_VS=vc14)       & shift & goto ParseArgs
45if /i "%1"=="vs2022"       (set TBB_TARGET_VS=vc14)       & shift & goto ParseArgs
46if /i "%1"=="all"          (set TBB_TARGET_VS=vc_mt)      & shift & goto ParseArgs
47
48:ParseLayout
49if exist "%TBBROOT%\redist\" (
50    set "TBB_BIN_DIR=%TBBROOT%\redist"
51    set "TBB_SUBDIR=%TBB_TARGET_ARCH%"
52    goto SetEnv
53)
54
55if "%TBB_TARGET_ARCH%" == "ia32" (
56    set TBB_ARCH_SUFFIX=32
57)
58if exist "%TBBROOT%\bin%TBB_ARCH_SUFFIX%" (
59    set "TBB_BIN_DIR=%TBBROOT%\bin%TBB_ARCH_SUFFIX%"
60    if "%TBB_TARGET_VS%" == "vc14" (
61        set TBB_TARGET_VS=
62    )
63    goto SetEnv
64)
65:: Couldn't parse TBBROOT/bin, unset variable
66set TBB_ARCH_SUFFIX=
67
68if exist "%TBBROOT%\..\redist\" (
69    set "TBB_BIN_DIR=%TBBROOT%\..\redist"
70    set "TBB_SUBDIR=%TBB_TARGET_ARCH%\tbb"
71    goto SetEnv
72)
73
74:SetEnv
75if exist "%TBB_BIN_DIR%\%TBB_SUBDIR%\%TBB_TARGET_VS%\tbb12.dll" (
76    set "TBB_DLL_PATH=%TBB_BIN_DIR%\%TBB_SUBDIR%\%TBB_TARGET_VS%"
77) else (
78    echo:
79    echo :: ERROR: tbb12.dll library does not exist in "%TBB_BIN_DIR%\%TBB_SUBDIR%\%TBB_TARGET_VS%\"
80    echo:
81    exit /b 255
82)
83
84set "PATH=%TBB_DLL_PATH%;%PATH%"
85
86set "LIB=%TBBROOT%\lib%TBB_ARCH_SUFFIX%\%TBB_SUBDIR%\%TBB_TARGET_VS%;%LIB%"
87set "INCLUDE=%TBBROOT%\include;%INCLUDE%"
88set "CPATH=%TBBROOT%\include;%CPATH%"
89set "CMAKE_PREFIX_PATH=%TBBROOT%;%CMAKE_PREFIX_PATH%"
90set "PKG_CONFIG_PATH=%TBBROOT%\lib%TBB_ARCH_SUFFIX%\pkgconfig;%PKG_CONFIG_PATH%"
91
92:End
93exit /B 0
94