Issue
Some context: I'm compiling a legacy CMake project using Visual Studio 2019 on a Windows 10 host, but targeting a remote aarch64 Ubuntu16.04 machine. To do so, I added a debug configuration for "Linux-Debug" to point at the machine's IP address (this part works, as I can build, and debug with breakpoints).
The Problem: I have the following add_custom_command inside my CMakeLists.txt
# Create the executable
add_executable( imageCaptureAEv1 ${SOURCES})
#copy it to the home directory
add_custom_command(TARGET imageCaptureAEv1 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:imageCaptureAEv1> /home/nvidia)
Where /home/nvidia is the directory I want to copy the executable to after I build it (POST_BUILD), and imageCaptureAEv1 is the name of the executable.
I believe this copy never happens, as the file never shows up in /home/nvidia when I ssh into the Ubuntu machine. All I want to do is copy the executable to an easier to find directory (visual studio prepends the build directory with a crazy long hash that I could get rid of, but I'd rather keep the build directory separate from where I'm copying it).
Is there an easier way? Or, am I missing something with my command?
Solution
The above cmake code DOES copy the executable, I just need to make sure a run a rebuild or clean then build in my particular environment, otherwise the executable doesn't get overwritten.
Answered By - Pawlos Campbell