Skip to content

Commit

Permalink
Merge 167ea85 into 0925433
Browse files Browse the repository at this point in the history
  • Loading branch information
berryzplus authored Sep 16, 2019
2 parents 0925433 + 167ea85 commit 63f088c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 52 deletions.
26 changes: 12 additions & 14 deletions tests/googletest.build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ 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 (
echo git.exe was not found.
endlocal && exit /b 1
)

if not exist "%~dp0googletest\CMakeLists.txt" (
"%CMD_GIT%" submodule init %~dp0googletest || endlocal && exit /b 1
"%CMD_GIT%" submodule update %~dp0googletest || endlocal && exit /b 1
)

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

if not exist CMakeCache.txt (
call :run_cmake_configure
)

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

endlocal && exit /b 0

:run_cmake_configure
where ninja.exe > NUL 2>&1
if not errorlevel 1 (
set GENERATOR=Ninja
set GENERATOR_OPTS=-DCMAKE_BUILD_TYPE=%CONFIGURATION%
)

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

cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
cmake -G "%GENERATOR%" %GENERATOR_OPTS% ^
"-DCMAKE_C_COMPILER=%CMD_CL%" ^
"-DCMAKE_CXX_COMPILER=%CMD_CL%" ^
-DBUILD_GMOCK=OFF ^
Expand All @@ -44,9 +43,8 @@ cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
%SOURCE_DIR% ^
|| endlocal && exit /b 1

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

endlocal && exit /b 0

:find_cl_exe
for /f "usebackq delims=" %%a in (`where cl.exe`) do (
Expand Down
71 changes: 37 additions & 34 deletions tests/googletest.targets
Original file line number Diff line number Diff line change
@@ -1,64 +1,67 @@
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="GoogleTest">
<GoogleTestSourceDir>$(MSBuildThisFileDirectory)googletest\</GoogleTestSourceDir>
<GoogleTestBuildDir>$(MSBuildThisFileDirectory)build\$(Platform)\$(Configuration)\googletest\</GoogleTestBuildDir>
<GoogleTestBuildDir>$(MSBuildThisFileDirectory)build\$(Platform)\$(Configuration)\googletest</GoogleTestBuildDir>
<IncludePath>$(GoogleTestSourceDir)googletest\include;$(IncludePath)</IncludePath>
<LibraryPath>$(GoogleTestBuildDir)\lib;$(GoogleTestBuildDir)\lib\$(Configuration);$(LibraryPath)</LibraryPath>
<NameSuffix Condition="'$(Configuration)' == 'Debug'">d</NameSuffix>
<NameSuffix Condition="'$(Configuration)' == 'Release'"></NameSuffix>
</PropertyGroup>
<ItemDefinitionGroup Label="GoogleTest.Requirements">
<ClCompile>
<PreprocessorDefinitions>_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Label="GoogleTest.Libs" Condition="'$(Configuration)' == 'Debug'">
<ItemDefinitionGroup Label="GoogleTest.Libs">
<Link>
<AdditionalDependencies>gtestd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>gtest_maind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>gtest$(NameSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>gtest_main$(NameSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Label="GoogleTest.Libs" Condition="'$(Configuration)' == 'Release'">
<Link>
<AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>gtest_main.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup Label="GoogleTest.Pdbs" Condition="'$(Configuration)' == 'Debug'">
<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" 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">
<Target Name="FindGit" Condition="'$(GitCmd)' == ''">
<Message Text="Checking Git for Windows" Importance="high" />
<Exec Command="where &quot;$(PATH);$(ProgramW6432)\Git\Cmd;$(ProgramFiles)\Git\Cmd:git&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitCmd" />
</Exec>
<PropertyGroup>
<GitCmd>$([System.Text.RegularExpressions.Regex]::Replace('$(GitCmd)', '^([^;]+);.*', '$1'))</GitCmd>
</PropertyGroup>
</Target>
<Target Name="UpdateGoogleTest" DependsOnTargets="FindGit" Condition="!Exists('$(GoogleTestSourceDir)\CMakeLists.txt')">
<Exec Command="&quot;$(GitCmd)&quot; submodule init" WorkingDirectory="$(GoogleTestSourceDir)" />
<Exec Command="&quot;$(GitCmd)&quot; submodule update" WorkingDirectory="$(GoogleTestSourceDir)" />
</Target>
<Target Name="MakeGoogleTestBuildDir" Condition="!Exists('$(GoogleTestBuildDir)')">
<MakeDir Directories="$(GoogleTestBuildDir)" />
</Target>
<Target Name="BuildGoogleTest" DependsOnTargets="UpdateGoogleTest;MakeGoogleTestBuildDir" 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>
<ProductLineVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioEdition)', '^.* (\d+).*', '$1'))</ProductLineVersion>
<GeneratorSuffix Condition="'$(PlatformTarget)' == 'x86'"></GeneratorSuffix>
<GeneratorSuffix Condition="'$(PlatformTarget)' == 'x64'"> Win64</GeneratorSuffix>
<VsGeneratorName>Visual Studio $(NumVersion) $(ProductLineVersion)$(GeneratorSuffix)</VsGeneratorName>
</PropertyGroup>
<MakeDir Condition="!Exists('$(GoogleTestBuildDir)')" Directories="$(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)" />
<Exec Command="$(MSBuildThisFileDirectory)googletest.build.cmd $(GoogleTestSourceDir) &quot;$(VsGeneratorName)&quot; $(Configuration) &quot;$(VSInstallRoot)/VC/Auxiliary/Build/vcvarsall.bat&quot; $(VcVarsArchitecture)" WorkingDirectory="$(GoogleTestBuildDir)" />
</Target>
<Target Name="CopyGoogleTestPdb" AfterTargets="BuildGoogleTest">
<ItemGroup>
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\gtest$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest$(NameSuffix).pdb')" />
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\gtest_main$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\gtest_main$(NameSuffix).pdb')" />
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest$(NameSuffix).pdb')" />
<GoogleTestPdb Include="$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main$(NameSuffix).pdb" Condition="Exists('$(GoogleTestBuildDir)\bin\$(Configuration)\gtest_main$(NameSuffix).pdb')" />
</ItemGroup>
<Copy SourceFiles="@(GoogleTestPdbFound)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />
</Target>
<Target Name="AppendCleanTargets" BeforeTargets="CoreClean">
<!-- Add files to @Clean just before running CoreClean. -->
<ItemGroup>
<Clean Include="$(OutDir)gtestd.pdb" />
<Clean Include="$(OutDir)gtest_maind.pdb" />
<Clean Include="$(OutDir)gtest.pdb" />
<Clean Include="$(OutDir)gtest_main.pdb" />
<Clean Include="$(OutDir)gtest$(NameSuffix).pdb" />
<Clean Include="$(OutDir)gtest_main$(NameSuffix).pdb" />
</ItemGroup>
<RemoveDir Directories="$(GoogleTestBuildDir)" />
</Target>
Expand Down
9 changes: 5 additions & 4 deletions tests/unittests/tests1.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{701e3407-ec27-49f7-adc7-520cf2b4b438}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(ProjectDir)..\..\vcx-props\vcxcompat.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(ProjectDir)..\..\vcx-props\vcxcompat.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets">
Expand Down
6 changes: 6 additions & 0 deletions vcx-props/vcxcompat.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals" Condition="'$(VisualStudioVersion)' == '15.0'">
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="Globals" Condition="'$(VisualStudioVersion)' == '16.0'">
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(VisualStudioVersion)' == '15.0'">
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
Expand Down

0 comments on commit 63f088c

Please sign in to comment.