CMake:根据配置依赖 [英] CMake: per configuration dependencies
问题描述
在CMake中,是否可以使特定于配置的目标依赖关系?
In CMake, is it possible to make target dependencies specific to a particular configuration?
我的结构是一个可执行文件,可以使用不同的后端渲染器,一个OpenGL和另一个D3D来构建。后端渲染器具有自己的(静态)库,并且只能根据配置(例如GL_Debug,D3D_Debug等)链接一个库。但是,似乎似乎 add_dependency
命令对每个配置设置有任何选择。
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.
我目前的解决方案是使用生成配置(Debug,Release等)和选项
来选择渲染器类型,并重新生成解决方案,如果我想切换。但是,如果我想经常在两者之间切换,这是笨重的。理想情况下,我将有一个所有渲染器配置的解决方案,并且可以在Visual Studio中在它们之间切换。
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.
推荐答案
target_link_libraries
命令可能以配置相关的方式链接。或者,生成器表达式可用于可执行文件/库的 LINK_LIBRARIES 属性。
target_link_libraries
command may link in configuration-dependent way. Alternatively, generator-expressions can be used for LINK_LIBRARIES property for executable/library.
这篇关于CMake:根据配置依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!