-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
223 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,81 @@ | ||
setlocal | ||
set SOURCE_DIR=%1 | ||
set GENERATOR=%~2 | ||
set CONFIGURATION=%~3 | ||
set VCVARSALL_PATH=%4 | ||
set VCVARS_ARCH=%~5 | ||
|
||
@rem call vcvasall.bat when we run in the Visual Studio IDE. | ||
if defined VCVARSALL_PATH ( | ||
call %VCVARSALL_PATH% %VCVARS_ARCH% || endlocal && exit /b 1 | ||
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 | ||
) | ||
|
||
if not exist CMakeCache.txt ( | ||
call :run_cmake_configure | ||
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% | ||
|
||
cmake --build . --config %CONFIGURATION% || endlocal && exit /b 1 | ||
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 | ||
where ninja.exe > NUL 2>&1 | ||
if not errorlevel 1 ( | ||
set GENERATOR=Ninja | ||
set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION% | ||
) | ||
call :find_cl_compiler | ||
|
||
@rem find cl.exe in the PATH | ||
call :find_cl_exe | ||
:: replace back-slash to slash in the path. | ||
set CL_COMPILER=%CMD_CL:\=/% | ||
|
||
if not defined CMD_CL ( | ||
echo cl.exe was not found. | ||
endlocal && exit /b 1 | ||
:: install lib64 for x64-platform. | ||
if "%PLATFORM%" == "x64" ( | ||
set GENERATOR_OPTS=-DCMAKE_INSTALL_LIBDIR=lib64 %GENERATOR_OPTS% | ||
) | ||
set CMD_CL=%CMD_CL:\=/% | ||
|
||
cmake -G "%GENERATOR%" %GENERATOR_OPTS% ^ | ||
"-DCMAKE_C_COMPILER=%CMD_CL%" ^ | ||
"-DCMAKE_CXX_COMPILER=%CMD_CL%" ^ | ||
-DBUILD_GMOCK=OFF ^ | ||
-Dgtest_build_tests=OFF ^ | ||
-Dgtest_build_samples=OFF ^ | ||
%SOURCE_DIR% ^ | ||
|| endlocal && exit /b 1 | ||
|
||
:: 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_exe | ||
:find_cl_compiler | ||
for /f "usebackq delims=" %%a in (`where cl.exe`) do ( | ||
set CMD_CL=%%a | ||
goto :EOF | ||
set "CMD_CL=%%a" | ||
goto :EOF | ||
) | ||
goto :EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.