Proper cmake/git usage when recompiling root or installing it to multiple machines

I would like to ask for the proper usage of cmake and git to recompile/reinstall root in the following two scenarios:

SCENARIO A)
Typically after a pull of master from origin or the selection of a different tag, I want to recompile root and install to a different directory. Since I have still the previous build dir, in principle I should not need to recompile everything from scratch… that is all the point about makefiles … isn’t?
But how should I specify the new target directory? From googling I learn that I can change the CMAKE_INSTALL_PREFIX but if I try:

cmake -DCMAKE_INSTALL_PREFIX=/path/to/new/directory --build . --target install

it does not work. Another option found is to directly call make install DESTDIR=/path/to/new/directory but there are also some warning related to this DESTDIR option of Makefiles.

SCENARIO B)
I want to install the same version of root on multiple machines, exploiting the fact that all the machines are clones of the same Debian 9 installation, and are kept up-to-date centrally (or in any case I can make sure that they all have the required packages installed).
So I would like to compile it only once, on one of these machines, and then install on all the others. Via sshfs I can mount the remote target directories on the machine where I have already compiled, to avoid to scp around the build directory (which btw would not work because cmake discovers that the build directory has been relocated…).
But again how can I change the CMAKE_INSTALL_PREFIX?

Thanks in advance for the hints,
Matteo


ROOT Version: any
Platform: Debian 9
Compiler: gcc


Scenario A)

$ cmake . -DCMAKE_INSTALL_PREFIX=/path/to/new/directory
$ cmake --build .
$ cmake --build . --target install

Do not use DESTDIR, it’s meant only for installing into a temporary location to create a tarball for distribution (and to be unpacked into the original CMAKE_INSTALL_PREFIX).

Scenario B)
This is the case for using DESTDIR. After building ROOT configured for the prefix you want (e.g. /opt/ROOT/6.16.00), you can do:

$ env DESTDIR=${PWD}/install cmake --build . --target install
$ cd ${PWD}/install
$ tar czvf ../root-image.tar.gz .

then on each machine where you want to install:

$ tar xzvf root-image.tar.gz -C /

Alternatively, you can use cmake --build . --target dist, which will create a tarball that you can also unpack on other compatible machines, although you will need to tweak the installation by removing the root/ prefix and unpacking to the right place as well.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.