CMake: per configuration dependencies

妖精的绣舞 提交于 2019-12-11 03:23:32

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/31810049/cmake-per-configuration-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!