[CMake] Build, Make Install for multiple machines - Guidelines for Success

Roger Leigh rleigh at codelibre.net
Tue Jun 7 17:27:58 EDT 2016


On 07/06/2016 12:10, B00083603 Michael O Brien wrote:
> Hi all,
>
> I have to build OpenCV on multiple machines and I was wondering if the
> following was possible and advisable or should I use a different method?
> I'm still learning about the cmake,make, make install way of software
> installation
>
> *Environment*
>
> All the machines (vms) have access to the same shared storage and are
> all are Ubuntu 14.04
>
> *On vm1:* run "cmake" on the files stored on the shared storage with the
> configuration I need then run "make -j$(nproc)" before using "make
> install" to install OpenCV
>
> *On vm 2 to vm n*: Can I just run make install (assuming all the
> required software is already installed) or would I be advised to run
> "cmake" and "make -j" commands again?
>
>
> Also is there any issues (file locks for example) about running the
> required commands in parallel on multple vms pointing to the same source
> or would I be advised to run the commands in serial (vm by vm)?
>
> Finally can I point "make install" to the directory where cmake created
> the makefile (apologies if this isn't the correct term, but where cmake
> did its work) so I can script the" make install" from outside the build
> directory for a slightly cleaner script

So, I also use NFS (v4) mounted storage with all the sources on there, 
be it git repositories, unpacked source archives etc.  However, the 
difference is that I don't *build* on NFS.  I do it in /tmp, or some 
other local scratch space:

cd /tmp
mkdir build
cd build
cmake [options] /path/to/sources
make
[sudo] make install

This will have the following benefits:
- solves all your root-on-nfs permissions issues
- the builds will be vastly faster
- there won't be any timestamp clock skew issues to confound make
- there won't be any NFSv3 locking issues
- you can have a separate build tree per VM, so the source tree stays 
nice and pristine while you build on as many platforms as you desire; I 
do this with Linux, BSD and Windows VMs all building the same git repo 
branches

For the install, can't you just
   (cd "$builddir" && make install)
i.e. in a subshell?  Or
   cmake --build "$builddir" --target install
to be generator-agnostic?


Regards,
Roger


More information about the CMake mailing list