0

独自の構成を使用して GTest をコンパイルします。

<ProjectConfiguration Include="Test|Win32">
  <Configuration>Debug</Configuration>
  <Platform>Win32</Platform>
</ProjectConfiguration>

カスタムメイドのターゲットを使用して GTest を実行します

  <Target Name="RunTests">
    <Message Text="Configuration: $(Configuration)" Importance="High" />
    <Exec Command="..\$(Configuration)\@(BuildProjectFile->'%(Filename)').exe" />
  </Target>

独自の実行可能ファイルとして実行するのではなく、VS2010 を使用して GTest を実行したいと考えています。VS2010 デバッガーを使用してテストをデバッグする利点が必要です。

コンパイルを開始するための正しいタスクがあるので、デバッガーはそれを取得しますか、それとも VS2010 に何かを返して独自に実行を開始する必要がありますか?

4

1 に答える 1

0

Returns="@(ManagedTargetPath)"VSを使用することにより、実行可能ファイルが開始されることになっています。

タスクを介してテストを開始する代わりにExec、ターゲットをデバッグを有効にしてビルドし、TargetPathをVSに返して実行する必要があります。

次の例では、着信ビルド呼び出しをリダイレクトして、代わりに単体テストを実行し、VS2010のビルドインメカニズムを使用して単体テストを起動します。

(私は現在、*。ccファイルのブレークポイントが無視され、*。cファイルのブレークポイントが無視されない理由を理解していません-偶然かもしれません)

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="main.c" />
    <ClCompile Include="Source\A.c" />
    <ClCompile Include="Source\A_unittest.cc" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="main.h" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{7506F0B9-7FA3-4E1E-8EB5-A1819E232C59}</ProjectGuid>
    <RootNamespace>STACKOVERFLOW</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
    </ClCompile>
    <Link>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
    </ClCompile>
    <Link>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
  <Target 
    Name="NormalBuild" 
    Condition=" '$(_InvalidConfigurationWarning)' != 'true' " 
    DependsOnTargets="_DetermineManagedStateFromCL;CustomBeforeBuild;$(BuildDependsOn)" 
    Returns="@(ManagedTargetPath)">
    <ItemGroup>
      <ManagedTargetPath Include="$(TargetPath)" Condition="'$(ManagedAssembly)' == 'true'" />
    </ItemGroup>
  </Target>

  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Test|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
  </ItemGroup>

  <Target Name="Build"
    Returns="@(ManagedTargetPath)">
    <MSBuild Projects="STACKOVERFLOW.vcxproj" Targets="NormalBuild" Properties="Configuration=Test" />
  </Target>

  <Target Name="CustomBeforeBuild">
    <ItemGroup Condition="'$(Configuration)' == 'Test'">
      <ClCompile Remove="*main.c*" />
      <ClCompile Include="c:/gtest/*.c*" />
    </ItemGroup>
  </Target>

</Project>
于 2012-12-04T18:19:56.337 に答える