简体   繁体   中英

CMake: how to specify different steps for different build configurations for Visual Studio?

Let's say, now I have a step

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" )

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.

How to achieve this?

You can use generator-expressions as arguments for add_custom_command .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM