Question

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.

Was it helpful?

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

OTHER TIPS

make and make install are expected to perform two conceptually different things. There is no better or worse of them. I will explain by describing usual sequence of program installation using make (from "Art of Unix Programming"):

  • make (all) - Your all production should make every executable of your project. Usually the all production doesn’t have an explicit rule; instead it refers to all of your project’s top-level targets (and, not accidentally, documents what those are). Conventionally, this should be the first production in your makefile, so it will be the one executed when the developer types make with no argument.

  • make test - Run the program’s automated test suite, typically consisting of a set of unit tests to find regressions, bugs, or other deviations from expected behavior during the development process. The ‘test’ production can also be used by end-users of the software to ensure that their installation is functioning correctly.

  • make install - Install the project’s executables and documentation in system directories so they will be accessible to general users (this typically requires root privileges). Initialize or update any databases or libraries that the executables require in order to function.

Credits go to Eric Steven Raymond for this answer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top