如何为每个特定目标运行不同的add_custom_command?
我与Visual Studio合作,并有不同的途径用于不同的配置(调试,发行):
if(WIN32 )
set(static_release ${my_lib}_release/SomeLibrary.lib)
set(static_debug ${my_lib}_debug/SomeLibrary.lib)
endif(WIN32)
然后我想运行不同的命令< < add_custom_command(target ...>>对于那些不同的配置,如下所示:
#A command which can be applied for Debug configuration:
add_custom_command(TARGET mylib
POST_BUILD
COMMAND lib /out:$<TARGET_FILE:mylib> $<TARGET_FILE:mylib> ${static_debug}
COMMENT "Concatenating static libs"
CONFIG Debug)
#A command which can be applied for Release configuration:
add_custom_command(TARGET mylib
POST_BUILD
COMMAND lib /out:$<TARGET_FILE:mylib> $<TARGET_FILE:mylib> ${static_release}
COMMENT "Concatenating static libs"
CONFIG Release)
不幸的是,Visual Studio为每种配置运行两个自定义命令。
我也尝试使用
add_custom_command(TARGET myLib
POST_BUILD
COMMAND lib /out:$<TARGET_FILE:myLib> $<TARGET_FILE:myLib> "$<IF:$<CONFIG:Debug>,${static_debug},$<CONFIG:Release>,${static_release}>"
COMMENT "Concatenating static libs"
CONFIG "$<IF:$<CONFIG:Debug>,Debug,$<CONFIG:Release>,Release")
,但VS不运行此命令,并且它不使用它' T根本工作
。
I work with Visual Studio and have different paths to work for different configurations (Debug, Release):
if(WIN32 )
set(static_release ${my_lib}_release/SomeLibrary.lib)
set(static_debug ${my_lib}_debug/SomeLibrary.lib)
endif(WIN32)
Then I want to run different commands < <add_custom_command(TARGET ...> > for those different configurations as follows:
#A command which can be applied for Debug configuration:
add_custom_command(TARGET mylib
POST_BUILD
COMMAND lib /out:lt;TARGET_FILE:mylib> lt;TARGET_FILE:mylib> ${static_debug}
COMMENT "Concatenating static libs"
CONFIG Debug)
#A command which can be applied for Release configuration:
add_custom_command(TARGET mylib
POST_BUILD
COMMAND lib /out:lt;TARGET_FILE:mylib> lt;TARGET_FILE:mylib> ${static_release}
COMMENT "Concatenating static libs"
CONFIG Release)
Unfortunately, Visual Studio runs both of those custom commands for each configuration.
I also tried to use
add_custom_command(TARGET myLib
POST_BUILD
COMMAND lib /out:lt;TARGET_FILE:myLib> lt;TARGET_FILE:myLib> "lt;IF:lt;CONFIG:Debug>,${static_debug},lt;CONFIG:Release>,${static_release}>"
COMMENT "Concatenating static libs"
CONFIG "lt;IF:lt;CONFIG:Debug>,Debug,lt;CONFIG:Release>,Release")
but VS doesn't run this command and it doesn’t work at all.
Is it possible to run only needed custom command for each configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只是失去了终点”。
谢谢。
I just have lost end ">".
Thanks.