-2

I have a cmake i am copying a dll from one location to another as follows:

set(dllpath "C:/images/own/standard/abc.dll")
STRING(REGEX REPLACE "/" "\\\\" copyDll \"${dllpath }\")
STRING(REGEX REPLACE "/" "\\\\" copyDest \"${CMAKE_BINARY_DIR}/_runtime/bin_${CMAKE_BUILD_TYPE}\")
add_custom_command(TARGET my_test POST_BUILD COMMAND copyDll  ${copyDest})

Then it shows error as:

"C:\images\own\standard\abc.dll\" is not recognized as internal or external command.

If i copy the dll in the following way it open up the dll file and do not copy the dll:

STRING(REGEX REPLACE "/" "\\\\" copyDest \"${CMAKE_BINARY_DIR}/_runtime/bin_${CMAKE_BUILD_TYPE}\")
add_custom_command(TARGET my_test POST_BUILD COMMAND "C:\images\own\standard\abc.dll"${copyDest})

Why the dll file gets open up but not copied?

usr1234567
  • 21,601
  • 16
  • 108
  • 128
Learner
  • 453
  • 13
  • 29
  • Possible duplicate of [Copy target file to another location in a post build step in CMake](http://stackoverflow.com/questions/9994045/copy-target-file-to-another-location-in-a-post-build-step-in-cmake) – usr1234567 May 05 '16 at 11:14
  • 1
    You missed the copy command itself. `COMMAND` expects something that works on the host systems command shell. And that's your third consecutive question about copying a DLL as a post-build step and - I'm sorry I have to say - the quality of your code samples is decreasing. Above all if you are trying the code in an answer from your [last question](http://stackoverflow.com/questions/36981942/how-to-use-add-custom-command-to-copy-dlls-using-generator-expressions), could you please place any problems as a comment there? You could have handled all this in with a single question. – Florian May 06 '16 at 07:05

1 Answers1

1

Try file(COPY ...) for copying file. Using such command after configure is bad style.

If you insist on using add_custom_command, use cmake -E copy, too. Documentation: https://cmake.org/cmake/help/v3.5/manual/cmake.1.html

usr1234567
  • 21,601
  • 16
  • 108
  • 128