I have a dynamic library that gets a different name depending on configuration, specified in the CMake scripts by:
set_target_properties(${name} PROPERTIES O
Use generator expressions in the POST_BUILD command instead of manually computing the output path. These are configuration aware. Example:
add_custom_command(TARGET mylibrary POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy "$" "my_target_path/$/$" COMMENT "Copying to output directory")