title: Copy target file to another location in a post build step in CMake
body: <p>I have a dynamic library that gets a different name depending on configuration, specified in the CMake scripts by:</p>
  
  <pre><code>set_target_properties(${name} PROPERTIES OUTPUT_NAME ${outputName}64)
  set_target_properties(${name} PROPERTIES DEBUG_OUTPUT_NAME ${outputName}64_d)
  </code></pre>
  
  <p>The end result is that I get a different name on release and debug builds. I would like to copy the resulting library to a different directory as a post-build step, but the gift(?) of CMake-Fu did not smile upon yours truly.</p>
  
  <p>I have tried doing this:</p>
  
  <pre><code>GET_TARGET_PROPERTY(origfile mylibrary LOCATION)
  STRING(REGEX REPLACE "/" "\\\\" origfile ${origfile})
  
  set(targetfile my_target_path\\${CMAKE_CFG_INTDIR}\\)
  STRING(REGEX REPLACE "/" "\\\\" targetfile ${targetfile})
  
  add_custom_command(TARGET mylibrary POST_BUILD
      COMMAND copy ${origfile} ${targetfile}
  )
  </code></pre>
  
  <p>This works fine for release builds, but for debug the source does not include the _d that I would have expected.
  <strong>How do I get the output path for the target so that I can copy the file?</strong></p>
  
  <p><strong>Note:</strong> As can be seen from the above snippet, this is currently for Windows/Visual Studio, but I would like this to work on OS X / Xcode / make as well.</p>
  
  <p><strong>Note:</strong> I need the library to be placed in an extra directory that serves as the output directory for several other projects that depend on this library, so that these projects are able to load the library at runtime. An alternative solution that would be acceptable would be to be able to create a custom target that does the copying, so that the other projects can depend on this project, which in turn depends on the library.</p>