CMake:如何为Visual Studio的不同构建配置指定不同的步骤? [英] CMake: how to specify different steps for different build configurations for Visual Studio?

查看:83
本文介绍了CMake:如何为Visual Studio的不同构建配置指定不同的步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,现在我迈出了一步

Let's say, now I have a step

add_custom_command(TARGET MyTarget POST_BUILDCOMMAND"$ {CMAKE_COMMAND}" -E复制$ {PROJECT_ROOT}/libs/somelib/Debug/lib.dll$ {PROJECT_ROOT}/bin/Debug/注释将依赖项dll复制到输出目录")

add_custom_command(TARGET MyTarget POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy ${PROJECT_ROOT}/libs/somelib/Debug/lib.dll ${PROJECT_ROOT}/bin/Debug/ COMMENT "Copying dependency dll to output directory" )

我想对其进行更改,以便在调用Visual Studio build进行Debug配置时,它使用的路径与调用Release配置时使用的路径不同.

I want to change it so that, if Visual Studio build is called for Debug configuration, it uses different paths from when it is called for Release configuration.

如何实现?

推荐答案

您可以使用

You can use generator-expressions as arguments for add_custom_command.

例如,表达式 $< CONFIG> 被评估为构建类型, $< TARGET_FILE_DIR:MyTarget> 被评估为可执行文件或库所在的目录生成.

E.g., expression $<CONFIG> is evaluated to the build type, $<TARGET_FILE_DIR:MyTarget> is evaluated to the directory, where executable or library is generated.

这篇关于CMake:如何为Visual Studio的不同构建配置指定不同的步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆