MuertoExcobito
MuertoExcobito

Reputation: 10039

CMake: per configuration dependencies

In CMake, is it possible to make target dependencies specific to a particular configuration?

My structure is an executable, which can be built with different backend renderers, one OpenGL and the other D3D. The backend renderers have their own (static) libraries, and only one library should be linked in, based on the configuration (eg. GL_Debug, D3D_Debug, etc). However, it doesn't seem as though the add_dependency command has any options for per-configuration settings.

My current solution is to use generation configurations (Debug, Release, etc), and an option to select the renderer type, and regenerate the solution if I'd like to switch. However, this is clunky if I want to switch between the two frequently. Ideally, I would have a solution with all the renderer configurations, and could just switch between them in Visual Studio.

Upvotes: 2

Views: 634

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 65928

target_link_libraries command may link in configuration-dependent way. Alternatively, generator-expressions can be used for LINK_LIBRARIES property for executable/library.

Upvotes: 4

Related Questions