forked from sakura-editor/sakura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogletest.build.cmd
81 lines (66 loc) · 2.09 KB
/
googletest.build.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
setlocal
set BUILD_BASE_DIR=%~dp1
set GOOGLETEST_INSTALL_PATH=%~dp2
set SOURCE_DIR=%~dp0googletest
:: find generic tools
if not defined CMD_VSWHERE call %~dp0..\tools\find-tools.bat
set /a NUM_VSVERSION_NEXT=NUM_VSVERSION + 1
if not exist "%CMD_CMAKE%" (
echo "no cmake found."
exit /b 1
)
pushd "%SOURCE_DIR%" || exit /b 1
if not exist CMakeLists.txt (
if not exist "%CMD_GIT%" (
echo "no git found."
exit /b 1
)
"%CMD_GIT%" submodule update --init || exit /b 1
)
popd
if not exist "%CMD_NINJA%" (
set GENERATOR="%CMAKE_G_PARAM%"
set GENERATOR_OPTS=-A %PLATFORM% "-DCMAKE_CONFIGURATION_TYPES=Debug;Release"
set "MAKE_PROGRAM=%CMD_MSBUILD%"
set "BUILD_DIR=%BUILD_BASE_DIR%googletest\%platform%"
) else (
set GENERATOR=Ninja
set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION%
set "MAKE_PROGRAM=%CMD_NINJA%"
set "BUILD_DIR=%BUILD_BASE_DIR%googletest\%platform%\%configuration%"
)
mkdir %BUILD_DIR% > NUL 2>&1
pushd %BUILD_DIR%
call :run_cmake_install
endlocal && exit /b 0
:run_cmake_install
call :run_cmake_configure
"%CMD_CMAKE%" --build . --config %CONFIGURATION% --target install || endlocal && exit /b 1
goto :EOF
:run_cmake_configure
call :find_cl_compiler
:: replace back-slash to slash in the path.
set CL_COMPILER=%CMD_CL:\=/%
:: install lib64 for x64-platform.
if "%PLATFORM%" == "x64" (
set GENERATOR_OPTS=-DCMAKE_INSTALL_LIBDIR=lib64 %GENERATOR_OPTS%
)
:: run cmake configuration.
"%CMD_CMAKE%" -G %GENERATOR% ^
"-DCMAKE_MAKE_PROGRAM=%MAKE_PROGRAM%" ^
"-DCMAKE_C_COMPILER=%CL_COMPILER%" ^
"-DCMAKE_CXX_COMPILER=%CL_COMPILER%" ^
-DCMAKE_INSTALL_PREFIX=%GOOGLETEST_INSTALL_PATH% ^
%GENERATOR_OPTS% ^
-DBUILD_GMOCK=OFF ^
-Dgtest_build_tests=OFF ^
-Dgtest_build_samples=OFF ^
%SOURCE_DIR% ^
|| endlocal && exit /b 1
goto :EOF
:find_cl_compiler
for /f "usebackq delims=" %%a in (`where cl.exe`) do (
set "CMD_CL=%%a"
goto :EOF
)
goto :EOF