Search code examples
c++linuxmakefilecmakebuild-system

make install vs. inplace linking


When building multiply dependant C++ CMake projects (in Linux) in topologically sorted order, we have two possibilities:

Go through every project, and ...

  1. ... "make install" it in some prefix. When building library in project, link to already installed libraries.

  2. ... build it via "make", do not install. When building library in project, link to already builded libraries inplace.

What are pros/cons of those choices? Build performed by homebrew script, which resolves dependencies, builds in right order, etc.


Solution

  • Of course you can do both. But the idea of 'installing' is that libraries, headers, documentation etc. are placed in a well defined directory, that does not depend on the layout of source code trees.

    Separate source, which is most often only interesting go the programmer of that package, and compiled proagrams libraries etc., which are interesting for users andd programmers of other packages.

    Imagine you have to change the directory structure of one subpackage. Without installing you would have to adapt all the other man scripts.

    So:

    Pros of solution 1 (== Cons of solution 2)

    • Better maintainability of the whole package
    • The "expected" way