blob: 8405d7616891190f16503179c8786fca7f8fa6f4 [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.
17:: Set the COMPILER environment variable to one of:
18:: vc100 = Visual Studio 2010
19:: vc110 = Visual Studio 2012
20:: vc120 = Visual Studio 2013
21:: vc140 = Visual Studio 2015
22:: vc150 = Visual Studio 2017
23::
24:: Honors any existing COMPILER environment variable
25:: setting instead of overwriting it, to allow it
26:: to be forced if needed.
27::
28:: Sets ERRORLEVEL to 0 if COMPILER can be determined,
29:: to 1 if it cannot.
30::
31
32IF DEFINED COMPILER (
33 ECHO [warn ] using existing environment variable COMPILER
34 EXIT /B 0
35)
36
37CALL :CHECK 16
38IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc100)
39CALL :CHECK 17
40IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc110)
41CALL :CHECK 18
42IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc120)
43CALL :CHECK 19.00
44IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc140)
45CALL :CHECK 19.10
46IF %ERRORLEVEL% == 0 (IF NOT DEFINED COMPILER SET COMPILER=vc150)
47
48IF NOT DEFINED COMPILER (
49 ECHO [error] unable to determine the compiler edition
50 EXIT /B 1
51)
52
53ECHO [info ] detected compiler edition %COMPILER%
54EXIT /B 0
55
56:CHECK
57cl /? 2>&1 | findstr /C:"Version %1%." > nul
58EXIT /B %ERRORLEVEL%