Cmake "install" to a remote machine?

With make install I can copy my executable files, configs. etcetera to the destination folder to execute.

Now I have the following situation: we have the virtual machine installed as the host assembly , and the other real Linux machine as the target platform .

I would like to have make install copy files directly to a folder on my remote computer (via scp or the like). How can i achieve this?

+7
source share
5 answers

You could often do

  make install DESTDIR=/tmp/mydest/ 

then archive this target directory

  tar czvf /tmp/mydest.tgz -C /tmp mydest 

then copy this archive to a remote location

  scp /tmp/mydest.tgz remote:tmp/ 

finally, unzip the archive on the remote control and copy it to the desired location

+6
source

make can work with a special prefix during installation:

  make prefix=$dest/usr install 

The solution to your problem is

  • Mount the file system of the target machine on your build machine. This can be done via nfs (persistent) or via sshfs (easier),
  • set $ dest to the mount point and run the command above
+2
source

Using cmake 2.8.14, you can also use the add_custom_command command in CMakeLists.txt:

 add_custom_command(TARGET my_target POST_BUILD COMMAND scp $<TARGET_FILE:my_target> user@remote _host:dest_dir_path ) 

Advantage: challenge only when restoring the target.

+2
source

For user userprofile on the remote computer and the ssh key is pre-configured:

  install(CODE "execute_process(COMMAND /usr/bin/rsync -avh ${INSTALL_DIR} user@remote :/home/user/)") 

It only copies the locally installed binaries to the remote computer when make install is run.

0
source

I am using this solution:

 install (CODE "execute_process(COMMAND scp -r -i /home/user/.ssh/id_rsa ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/. user@remote :/path/to/copy/)") 

Then I run the make install command and it works

I know that $ {CMAKE_RUNTIME_OUTPUT_DIRECTORY} is not the best variable for it, but for me it's good

0
source

Source: https://habr.com/ru/post/906651/


All Articles