blob: 733ffc53845569741348af2e988f328bccb648eb [file] [log] [blame]
James E. King, III07f59972017-03-10 06:18:33 -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:: gcc = MinGW / MSYS2 and gcc toolchain
19:: vc100 = Visual Studio 2010
20:: vc110 = Visual Studio 2012
21:: vc120 = Visual Studio 2013
22:: vc140 = Visual Studio 2015
James E. King III860a5f12018-03-06 14:23:23 -050023:: vc141 = Visual Studio 2017
James E. King, III07f59972017-03-10 06:18:33 -050024::
25:: Honors any existing COMPILER environment variable
26:: setting instead of overwriting it, to allow it
27:: to be forced if needed.
28::
29:: Sets ERRORLEVEL to 0 if COMPILER can be determined,
30:: to 1 if it cannot.
31::
32
33IF DEFINED COMPILER (
34 ECHO [warn ] using existing environment variable COMPILER
35 EXIT /B 0
36)
37
38IF NOT "%PROFILE:~0,4%" == "MSVC" (
39 SET COMPILER=gcc
40) ELSE (
41 CALL :CHECK 16
42 IF !ERRORLEVEL! == 0 (SET COMPILER=vc100)
43 CALL :CHECK 17
44 IF !ERRORLEVEL! == 0 (SET COMPILER=vc110)
45 CALL :CHECK 18
46 IF !ERRORLEVEL! == 0 (SET COMPILER=vc120)
James E. King III860a5f12018-03-06 14:23:23 -050047 CALL :CHECK 19.0
James E. King, III07f59972017-03-10 06:18:33 -050048 IF !ERRORLEVEL! == 0 (SET COMPILER=vc140)
James E. King III860a5f12018-03-06 14:23:23 -050049 CALL :CHECK 19.1
50 IF !ERRORLEVEL! == 0 (SET COMPILER=vc141)
James E. King, III07f59972017-03-10 06:18:33 -050051)
52
53IF NOT DEFINED COMPILER (
54 ECHO [error] unable to determine the compiler edition
55 EXIT /B 1
56)
57
58ECHO [info ] detected compiler edition %COMPILER%
59EXIT /B 0
60
61:CHECK
James E. King III860a5f12018-03-06 14:23:23 -050062cl /? 2>&1 | findstr /C:"Version %1%" > nul
James E. King, III07f59972017-03-10 06:18:33 -050063EXIT /B