1

I'm trying to build a Visual Studio solution (C++) using msbuild

 msbuild.exe mysolution.sln /p:platform="ARM" /p:configuration="Release"

I'm getting this error

error : all paths through this function will call itself [-Werror,-Winfinite-recursion]

I just want to be able to turn off -Werror from the command line, instead of turning it off in Project Properties > Configuration Properties > C/C++ > Treat Warnings As Errors

Thanks!

Edit 1. There are also other project properties that I would like to set that can't be fixed in code, such as Configuration Properties > General > Platform Toolset and Configuration Properties > General > Use of STL. FWIW, I'm targeting the ARM platform as you can see from my command line above.

Martin
  • 748
  • 7
  • 20
  • 4
    What about fixing the function instead? – SingerOfTheFall Feb 07 '17 at 13:56
  • Good suggestion, but he function is in an external library that I can't modify. – Martin Feb 07 '17 at 13:59
  • Possible duplicate of [How to set PreProcessorDefinitions as a task propery for the msbuild task](http://stackoverflow.com/questions/15141429/how-to-set-preprocessordefinitions-as-a-task-propery-for-the-msbuild-task); that question is about preprocessor definitions instead of 'Treat Warnings as Errors' but the principle is exactly the same. – stijn Feb 07 '17 at 15:18

1 Answers1

2

According to this post which also provided by stijn, we could not change the value of “TreatWarningAsError” by the MSBuild command line directly. Because the “TreatWarningAsError” is a ClCompile not PropertyGroup in the project file. You can add a target invoke MSBuild to pass an external parameter into the project file by MSBuild command line:

First, change the fixed values of “TreatWarningAsError” in the project file:

<ClCompile>
   ...
   <TreatWarningAsError>$(TWAESettings)</TreatWarningAsError>
</ClCompile>

Second, add a target in to the project file:

  <Target Name="TestBuild" Returns="@(ManagedTargetPath)">
    <MSBuild Projects="YourProjectName.vcxproj" Targets="NormalBuild" Properties="TWAESettings=true"/>
  </Target>

Third, use the MSBuild command line with the properties true or false:

msbuild /p:TWAESettings=false Or msbuild /p:TWAESettings=true

Update:

For Configuration Properties > General > Platform Toolset and Configuration Properties > General > Use of STL

You can change the Platform Toolset by the MSBuild command line directly:

msbuild /p:PlatformToolset=v140_xp

But I could not find "Use of STL", just "Use of ATL" instead. If "Use of STL" is a PropertyGroup in the project file, you can also change it by the MSBuild command line directly.

Community
  • 1
  • 1
Leo Liu
  • 71,098
  • 10
  • 114
  • 135