Reputation: 4217
This one may be a bit strange. I have a solution in Visual Studio 2010 with three C++ projects. Two libraries and one executable application. Two configurations. In one configuration, I need the executable application to have a project dependency on one library, in the other configuration I need the executable application to have a project dependency on other library.
With specifics, there's a Direct3D9 implementation in the first library and an OpenGL implementation in the second library. The third project is a test harness that uses the same interface for both, the only difference is which library it links to. Two configurations exist in the test harness project, one for each implementation. I can not set the test harness project to depend on each implementation library individually based on active configuration.
How can I make the project dependencies configuration-specific?
Upvotes: 4
Views: 1220
Reputation: 1083
One trick which seems to work from the IDE:
Let both libraries also have a configuration NOT_USED;
set the Configuration Type (in Common Properties: General : Project Defaults) to Application (.exe) for the libraries in the NOT_USED configuration.
This will VS think he does not have a lib as result from these projects, and thus not provide a link error.
Upvotes: 0
Reputation: 3493
Is the C++ project format msbuild? If so, you should just be able to put a condition on the reference. Reference both projects and then edit the project file and add a condition on each one. This is how it would work in a C# project, not sure if c++ is the same:
<ProjectReference Include="..\DirectXLib\DirectXLib.csproj" Condition=" '$(Configuration)' == 'DirectX' ">
<Project>{99999-9999-9999-9999-99999999999}</Project>
<Name>DirectXLib</Name>
</ProjectReference>
<ProjectReference Include="..\OpenGLLib\OpenGLLib.csproj" Condition=" '$(Configuration)' == 'OpenGL' ">
<Project>{99999-9999-9999-9999-99999999999}</Project>
<Name>OpenGLLib</Name>
</ProjectReference>
Upvotes: 3
Reputation: 5177
I think the purpose of configuration manager is just for what you are asking, doesn't it?
At the solution level you specify what configurations you want to build and for each configuration you can specify what projects you want to build and in what order. And in each project's settings, you can specify what libraries to include and a whole bunch of other things you want to do.
Upvotes: 0