xref: /aosp_15_r20/external/abseil-cpp/ci/windows_msvc_cmake.bat (revision 9356374a3709195abf420251b3e825997ff56c0f)
1*9356374aSAndroid Build Coastguard Worker:: Copyright 2023 The Abseil Authors
2*9356374aSAndroid Build Coastguard Worker::
3*9356374aSAndroid Build Coastguard Worker:: Licensed under the Apache License, Version 2.0 (the "License");
4*9356374aSAndroid Build Coastguard Worker:: you may not use this file except in compliance with the License.
5*9356374aSAndroid Build Coastguard Worker:: You may obtain a copy of the License at
6*9356374aSAndroid Build Coastguard Worker::
7*9356374aSAndroid Build Coastguard Worker::     https://www.apache.org/licenses/LICENSE-2.0
8*9356374aSAndroid Build Coastguard Worker::
9*9356374aSAndroid Build Coastguard Worker:: Unless required by applicable law or agreed to in writing, software
10*9356374aSAndroid Build Coastguard Worker:: distributed under the License is distributed on an "AS IS" BASIS,
11*9356374aSAndroid Build Coastguard Worker:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*9356374aSAndroid Build Coastguard Worker:: See the License for the specific language governing permissions and
13*9356374aSAndroid Build Coastguard Worker:: limitations under the License.
14*9356374aSAndroid Build Coastguard Worker
15*9356374aSAndroid Build Coastguard WorkerSETLOCAL ENABLEDELAYEDEXPANSION
16*9356374aSAndroid Build Coastguard Worker
17*9356374aSAndroid Build Coastguard Worker:: The version of GoogleTest to be used in the CMake tests in this directory.
18*9356374aSAndroid Build Coastguard Worker:: Keep this in sync with the version in the WORKSPACE file.
19*9356374aSAndroid Build Coastguard WorkerSET ABSL_GOOGLETEST_VERSION=1.15.2
20*9356374aSAndroid Build Coastguard WorkerSET ABSL_GOOGLETEST_DOWNLOAD_URL=https://github.com/google/googletest/releases/download/v%ABSL_GOOGLETEST_VERSION%/googletest-%ABSL_GOOGLETEST_VERSION%.tar.gz
21*9356374aSAndroid Build Coastguard Worker
22*9356374aSAndroid Build Coastguard Worker:: Replace '\' with '/' in Windows paths for CMake.
23*9356374aSAndroid Build Coastguard Worker:: Note that this cannot go inside the IF block above, because BAT files are weird.
24*9356374aSAndroid Build Coastguard WorkerSET ABSL_GOOGLETEST_DOWNLOAD_URL=%ABSL_GOOGLETEST_DOWNLOAD_URL:\=/%
25*9356374aSAndroid Build Coastguard Worker
26*9356374aSAndroid Build Coastguard WorkerIF EXIST "C:\Program Files\CMake\bin\" (
27*9356374aSAndroid Build Coastguard Worker  SET CMAKE_BIN="C:\Program Files\CMake\bin\cmake.exe"
28*9356374aSAndroid Build Coastguard Worker  SET CTEST_BIN="C:\Program Files\CMake\bin\ctest.exe"
29*9356374aSAndroid Build Coastguard Worker) ELSE (
30*9356374aSAndroid Build Coastguard Worker  SET CMAKE_BIN="cmake.exe"
31*9356374aSAndroid Build Coastguard Worker  SET CTEST_BIN="ctest.exe"
32*9356374aSAndroid Build Coastguard Worker)
33*9356374aSAndroid Build Coastguard Worker
34*9356374aSAndroid Build Coastguard WorkerSET CTEST_OUTPUT_ON_FAILURE=1
35*9356374aSAndroid Build Coastguard WorkerSET CMAKE_BUILD_PARALLEL_LEVEL=16
36*9356374aSAndroid Build Coastguard WorkerSET CTEST_PARALLEL_LEVEL=16
37*9356374aSAndroid Build Coastguard Worker
38*9356374aSAndroid Build Coastguard Worker:: Change directory to the root of the project.
39*9356374aSAndroid Build Coastguard WorkerCD %~dp0\..
40*9356374aSAndroid Build Coastguard Workerif %errorlevel% neq 0 EXIT /B 1
41*9356374aSAndroid Build Coastguard Worker
42*9356374aSAndroid Build Coastguard WorkerSET TZDIR=%CD%\absl\time\internal\cctz\testdata\zoneinfo
43*9356374aSAndroid Build Coastguard Worker
44*9356374aSAndroid Build Coastguard WorkerMKDIR "build"
45*9356374aSAndroid Build Coastguard WorkerCD "build"
46*9356374aSAndroid Build Coastguard Worker
47*9356374aSAndroid Build Coastguard WorkerSET CXXFLAGS="/WX"
48*9356374aSAndroid Build Coastguard Worker
49*9356374aSAndroid Build Coastguard Worker%CMAKE_BIN% ^
50*9356374aSAndroid Build Coastguard Worker  -DABSL_BUILD_TESTING=ON ^
51*9356374aSAndroid Build Coastguard Worker  -DABSL_GOOGLETEST_DOWNLOAD_URL=%ABSL_GOOGLETEST_DOWNLOAD_URL% ^
52*9356374aSAndroid Build Coastguard Worker  -DBUILD_SHARED_LIBS=%ABSL_CMAKE_BUILD_SHARED% ^
53*9356374aSAndroid Build Coastguard Worker  -DCMAKE_CXX_STANDARD=%ABSL_CMAKE_CXX_STANDARD% ^
54*9356374aSAndroid Build Coastguard Worker  -G "%ABSL_CMAKE_GENERATOR%" ^
55*9356374aSAndroid Build Coastguard Worker  ..
56*9356374aSAndroid Build Coastguard WorkerIF %errorlevel% neq 0 EXIT /B 1
57*9356374aSAndroid Build Coastguard Worker
58*9356374aSAndroid Build Coastguard Worker%CMAKE_BIN% --build . --target ALL_BUILD --config %ABSL_CMAKE_BUILD_TYPE%
59*9356374aSAndroid Build Coastguard WorkerIF %errorlevel% neq 0 EXIT /B 1
60*9356374aSAndroid Build Coastguard Worker
61*9356374aSAndroid Build Coastguard Worker%CTEST_BIN% -C %ABSL_CMAKE_BUILD_TYPE% -E "absl_lifetime_test|absl_symbolize_test"
62*9356374aSAndroid Build Coastguard WorkerIF %errorlevel% neq 0 EXIT /B 1
63*9356374aSAndroid Build Coastguard Worker
64*9356374aSAndroid Build Coastguard WorkerEXIT /B 0
65