Post build step only for release build

I ran into something similar, wanting to copy a DLL file to a destination directory but only for release builds. After lots of torn hair I managed to get it to work using a few generator expressions (the $<...> thingies). I'm putting it here seven years later not so much to solve your problem (though I would admire your level of pertinence), but in order to save the cranial hair of the next person having this same problem and finding this question on google:

set(no_copy $<NOT:$<CONFIG:Release>>) # An abbreviation to make the example easier to read.
add_custom_command(TARGET myDLL POST_BUILD
    COMMAND "${CMAKE_COMMAND}" -E
    # do nothing for non-Release build
    $<${no_copy}:echo>
    # output text to make clear that the copy command is not actually issued
    $<${no_copy}:"copy omitted for non-release build, command would have been ">
    # the actual copy command, which is overridden by the "echo" above
    # in the case of a non-release build
    copy_if_different $<TARGET_FILE:myDLL> ${DIR_FOR_DLL})

The trick is to write an echo in front of the command that would otherwise be issued. This way, the command is not executed, even though a bit of noise is output. One could enclose the remainder of the command line in a number of generator expressions to shorten the output at the expense of a completely unreadable cmake file. On the other hand there seems to be no way to suppress the copy portably without generating any output. Finally, if you think there's an easy out and you can just write if($<CONFIG:Release>) ... endif(), I advise you to spare yourself the disappointment.