Hello! I’m trying to set up a project with two configurations:
- One for tests (Tests)
- Another one for debug (Debug)
In the Tests configuration, I want the file tests.cpp that contains the main function that runs the tests from Google Test to be compiled, but I want this file to be excluded from compilation in the Debug config.
In the Debug configuration, I want the file main.cpp that contains the main function of the application to be compiled, but I want this file to be excluded in the Tests config.
If this works, I won’t have any problems of “redefinition of main”, since there is one main in each of these files.
I was able to do this by tweaking around some configs of the Visual Studio and now the .vcxproj looks like this:
<ClCompile Include=”tests\tests.cpp”>
<ExcludedFromBuild Condition=”‘$(Configuration)|$(Platform)’==’Debug|x64′”>true</ExcludedFromBuild>
<ExcludedFromBuild Condition=”‘$(Configuration)|$(Platform)’==’Tests|x64′”>false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include=”main.cpp”>
<ExcludedFromBuild Condition=”‘$(Configuration)|$(Platform)’==’Tests|x64′”>true</ExcludedFromBuild>
<ExcludedFromBuild Condition=”‘$(Configuration)|$(Platform)’==’Debug|x64′”>false</ExcludedFromBuild>
</ClCompile>
But both files are still being compiled on both configurations. Can this be a case of VisualGDB overriding those settings and always compiling all files?