2

I need to set this post-build event in cmake

how to do this?

I am using below command in my vs project, but I need to add it during CMake build in Cmakelists.txt

xcopy /y /d "$(TargetPath)" "$(ProjectDir)$(Platform)\$(Configuration)" 

I tried following but they didn't work for me VS cannot find the path

How to copy DLL files into the same folder as the executable using CMake?

CMake post-build-event: copy compiled libraries

add_custom_command(
    TARGET my 
    POST_BUILD        
    COMMAND ${CMAKE_COMMAND} xcopy /y /d "$(TargetPath)" "$(ProjectDir)$(Platform)\$(Configuration)" 
) 

error --> this $(ProjectDir)$(Platform)$(Configuration) not giving right path it shows x64Debug not x64\Debug

kobi89
  • 152
  • 9
  • So, you have tried to put your command into `add_custom_command(POST_BUILD)` event, haven't you? Please, show (add to the question post) what exactly have you tried. If that attempt results with an error, then show that error too. – Tsyvarev Mar 26 '21 at 16:17
  • @Tsyvarev i have updated – kobi89 Mar 26 '21 at 16:27
  • 1
    The backslash should escaped: ``\\``. – Tsyvarev Mar 26 '21 at 16:35

1 Answers1

1

It works as explained in the above comment

backslash should escaped: \\ 

add_custom_command(TARGET my POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy
    "$(TargetPath)"
    "$(ProjectDir)$(Platform)\\$(Configuration)" 
)
kobi89
  • 152
  • 9