blob: bae2742f7bae3c069a73eaa6fb7843eba442a1c1 [file] [log] [blame]
James E. King, III4d651ab2017-02-19 22:19:55 -05001::
2:: Licensed under the Apache License, Version 2.0 (the "License");
3:: you may not use this file except in compliance with the License.
4:: You may obtain a copy of the License at
5::
6:: http://www.apache.org/licenses/LICENSE-2.0
7::
8:: Unless required by applicable law or agreed to in writing, software
9:: distributed under the License is distributed on an "AS IS" BASIS,
10:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11:: See the License for the specific language governing permissions and
12:: limitations under the License.
13::
14
15::
16:: Detect the compiler edition we're building in and then
17:: set the GENERATOR environment variable to one of:
18::
19:: Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
20:: Optional [arch] can be "Win64" or "ARM".
21:: Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
22:: Optional [arch] can be "Win64" or "ARM".
23:: Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
24:: Optional [arch] can be "Win64" or "ARM".
25:: Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
26:: Optional [arch] can be "Win64" or "ARM".
27:: Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
28:: Optional [arch] can be "Win64" or "IA64".
29::
30:: Honors any existing GENERATOR environment variable
31:: setting instead of overwriting it, to allow it
32:: to be forced if needed.
33::
34:: Sets ERRORLEVEL to 0 if GENERATOR can be determined,
35:: to 1 if it cannot.
36::
37:: Requires cl_setarch.bat to have been executed or the ARCH environment
38:: variable to be set.
39::
40
41IF "%ARCH%" == "x64" (SET GENARCH= Win64)
42
43IF DEFINED GENERATOR (
44 ECHO [warn ] using existing environment variable GENERATOR
45 EXIT /B 0
46)
47
48CALL :CHECK 16
49IF %ERRORLEVEL% == 0 (IF NOT DEFINED GENERATOR SET GENERATOR=Visual Studio 10 2010%GENARCH%)
50CALL :CHECK 17
51IF %ERRORLEVEL% == 0 (IF NOT DEFINED GENERATOR SET GENERATOR=Visual Studio 11 2012%GENARCH%)
52CALL :CHECK 18
53IF %ERRORLEVEL% == 0 (IF NOT DEFINED GENERATOR SET GENERATOR=Visual Studio 12 2013%GENARCH%)
54CALL :CHECK 19.00
55IF %ERRORLEVEL% == 0 (IF NOT DEFINED GENERATOR SET GENERATOR=Visual Studio 14 2015%GENARCH%)
56CALL :CHECK 19.10
57IF %ERRORLEVEL% == 0 (IF NOT DEFINED GENERATOR SET GENERATOR=Visual Studio 15 2017%GENARCH%)
58
59IF NOT DEFINED GENERATOR (
60 ECHO [error] unable to determine the CMake generator to use
61 EXIT /B 1
62)
63
64ECHO [info ] using CMake generator %GENERATOR%
65EXIT /B 0
66
67:CHECK
68cl /? 2>&1 | findstr /C:"Version %1%." > nul
69EXIT /B %ERRORLEVEL%