Skip to content

Commit

Permalink
Merge pull request #1001 from berryzplus/feature/set_default_generator
Browse files Browse the repository at this point in the history
googletestのビルドに使うジェネレータをお任せにしないように変える
  • Loading branch information
berryzplus authored Aug 18, 2019
2 parents 75d5f21 + fee7da2 commit 67cd51a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
28 changes: 13 additions & 15 deletions tests/googletest.build.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@rem echo off
setlocal
set SOURCE_DIR=%1
set CONFIGURATION=%2
set VCVARSALL_PATH=%3
set VCVARS_ARCH=%4
set GENERATOR=%~2
set CONFIGURATION=%~3
set VCVARSALL_PATH=%4
set VCVARS_ARCH=%~5

if not defined CMD_GIT call %~dp0..\tools\find-tools.bat
if not defined CMD_GIT (
Expand All @@ -16,16 +16,14 @@ if not exist "%~dp0googletest\CMakeLists.txt" (
"%CMD_GIT%" submodule update %~dp0googletest || endlocal && exit /b 1
)

set GENERATOR=

@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
)

where ninja.exe > NUL 2>&1
if not errorlevel 1 (
set GENERATOR=-G "Ninja"
set GENERATOR=Ninja
)

@rem find cl.exe in the PATH
Expand All @@ -37,16 +35,16 @@ if not defined CMD_CL (
)
set CMD_CL=%CMD_CL:\=/%

cmake %GENERATOR% -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
"-DCMAKE_C_COMPILER=%CMD_CL%" ^
"-DCMAKE_CXX_COMPILER=%CMD_CL%" ^
-DBUILD_GMOCK=OFF ^
-Dgtest_build_tests=OFF ^
-Dgtest_build_samples=OFF ^
%SOURCE_DIR% ^
cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
"-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

cmake --build . || endlocal && exit /b 1
cmake --build . --config %CONFIGURATION% || endlocal && exit /b 1

endlocal && exit /b 0

Expand Down
24 changes: 18 additions & 6 deletions tests/googletest.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<GoogleTestSourceDir>$(MSBuildThisFileDirectory)googletest\</GoogleTestSourceDir>
<GoogleTestBuildDir>$(MSBuildThisFileDirectory)build\$(Platform)\$(Configuration)\googletest\</GoogleTestBuildDir>
<IncludePath>$(GoogleTestSourceDir)googletest\include;$(IncludePath)</IncludePath>
<LibraryPath>$(GoogleTestBuildDir)\lib;$(LibraryPath)</LibraryPath>
<LibraryPath>$(GoogleTestBuildDir)\lib;$(GoogleTestBuildDir)\lib\$(Configuration);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Label="GoogleTest.Requirements">
<ClCompile>
Expand All @@ -23,22 +23,34 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Debug'">
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtestd.pdb" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_maind.pdb" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtestd.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtestd.pdb')" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_maind.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest_maind.pdb')" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtestd.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtestd.pdb')" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_maind.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_maind.pdb')" />
</ItemGroup>
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Release'">
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest.pdb" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_main.pdb" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest.pdb')" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\gtest_main.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest_main.pdb')" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest.pdb')" />
<ReferenceCopyLocalPaths Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main.pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main.pdb')" />
</ItemGroup>
<Target Name="BuildGoogleTest" BeforeTargets="ClCompile">
<PropertyGroup>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PlatformTarget)' == 'x86'">x86</VcVarsArchitecture>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'x86' And '$(PlatformTarget)' == 'x64'">x86_amd64</VcVarsArchitecture>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' And '$(PlatformTarget)' == 'x86'">amd64_x86</VcVarsArchitecture>
<VcVarsArchitecture Condition="'$(PROCESSOR_ARCHITECTURE)' == 'AMD64' And '$(PlatformTarget)' == 'x64'">amd64</VcVarsArchitecture>
<NumVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1'))</NumVersion>
<NextVersion>$([MSBuild]::Add($(NumVersion), 1))</NextVersion>
<GeneratorSuffix Condition="'$(PlatformTarget)' == 'x86'"></GeneratorSuffix>
<GeneratorSuffix Condition="'$(PlatformTarget)' == 'x64'"> Win64</GeneratorSuffix>
</PropertyGroup>
<MakeDir Condition="!Exists('$(GoogleTestBuildDir)')" Directories="$(GoogleTestBuildDir)" />
<Exec Command="$(MSBuildThisFileDirectory)googletest.build.cmd $(GoogleTestSourceDir) $(Configuration) &quot;$(VCInstallDir)Auxiliary/Build/vcvarsall.bat&quot; $(VcVarsArchitecture)" WorkingDirectory="$(GoogleTestBuildDir)" />
<Message Text="Cheking product line version of the Visual Studio." Importance="high" />
<Exec Command="&quot;$(VSInstallDir)..\..\Installer\vswhere.exe&quot; -version [$(NumVersion),$(NextVersion)] -property catalog_productLineVersion" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ProductLineVersion" />
</Exec>
<Exec Command="$(MSBuildThisFileDirectory)googletest.build.cmd $(GoogleTestSourceDir) &quot;Visual Studio $(NumVersion) $(ProductLineVersion)$(GeneratorSuffix)&quot; $(Configuration) &quot;$(VSInstallRoot)/VC/Auxiliary/Build/vcvarsall.bat&quot; $(VcVarsArchitecture)" WorkingDirectory="$(GoogleTestBuildDir)" />
</Target>
<Target Name="AppendCleanTargets" BeforeTargets="CoreClean">
<!-- Add files to @Clean just before running CoreClean. -->
Expand Down

0 comments on commit 67cd51a

Please sign in to comment.