Build visual studio C++ project within solution for multiple platforms

前端 未结 1 1238
深忆病人
深忆病人 2021-01-29 04:58

I have a Visual Studio solution that contains multiple C# projects and a C++ project.

The C++ project is properly configured to build both for x64 and win32 (has separa

相关标签:
1条回答
  • 2021-01-29 05:35

    How can I configure my solution to build the C++ project for both x64 and win32 when building the entire solution?

    Please use Batch Build to build your solution.

    1) First Right-click on your solution and choose Batch Build.

    2) Second, check the C++ project which you want to build. You can then check both 64-bit and 32-bit for the project, and you can also select Debug or Release for the Configuration. Finally, click Build or Rebuild to generate different versions of the output files at the same time.

    3) When you finish, please open the solution folder. In my side, Debug or Release folder is just for 32-bit while x64 folder is just for 64-bit.

    Update 1

    Since you do not want to config VS settings and then use Batch Build, l think you can use custom build target in the xxxx.vcxproj file.

    Please add these targets into xxxx.vcxproj of all C++ Projects in the whole solution.

    <Target Name="BuildFunction" AfterTargets="Build">
        <MSBuild Condition="'$(Platform)'=='Win32'" Projects="$(MSBuildProjectFile)" Properties="Platform=x64;PlatFormTarget=x64" RunEachTargetSeparately="true"  />
        <MSBuild Condition="'$(Platform)'=='x64'"   Projects="$(MSBuildProjectFile)" Properties="Platform=Win32;PlatFormTarget=x86" RunEachTargetSeparately="true" />
      </Target>
    
      <Target Name="CleanAll" AfterTargets="Clean">
        <MSBuild Condition="'$(Platform)'=='Win32'" Projects="$(MSBuildProjectFile)" Targets="Clean" Properties="Platform=x64;PlatFormTarget=x64" RunEachTargetSeparately="true"  />
        <MSBuild Condition="'$(Platform)'=='x64'"   Projects="$(MSBuildProjectFile)" Targets="Clean" Properties="Platform=Win32;PlatFormTarget=x86" RunEachTargetSeparately="true" />
    
      </Target>
    

    These targets depends on Build or Clean target. So when you build the project, they will always execute later and build the project into the other version.

    Besides, this method is tied to your solution, so when someone else clones your solution, Build directly from your script or click Build in VS IDE and then you see the x64 and x86 versions of the files in the solution.

    Hope it could help you.

    0 讨论(0)
提交回复
热议问题