[CMake] ?==?utf-8?q? ?==?utf-8?q? ?= Looking for an explanation: What exactly means "install" in cmake language

Cornelis Bockemühl cornelis at bockemuehl.ch
Tue Oct 8 06:36:24 EDT 2019


Dear all those wo answered on this thread: many thanks first of all!

When I was starting this thread I was really a bit desperate - because things did not do what I expected, I felt like in the middle of a "cmake jungle" - and I doubted everything that I ever meant to have understood about cmake, mostly regarding that "install" and "export" business...

The first thing I learned was thus one first certainty about the entire install process: "install" is indeed kind of "copy with a plus". Already very good to know to start with!

Then there was the question if I could provide a strip down version of my project - and my problem was that "stripping down Paraview" is not so simple...

However, I went back to one of my "teachers" - which is this web page -, and started to build a really extremely trivial example that includes the following points:

- a first shared library "shlibbi" that has an exported header, uses an internal class and boost::regex - to have something "completely external".
- a second shared library "shlibbu" that depends on "shlibbi"
- and finally an "example" that depends on "shlibbu"

And indeed - it works! At least in the sense that I can

- build and "install" first "shlibbi"
- then build and "install" "shlibbu", importing "shiibbi" with a find_package(shlibbi...) call
- and finally build "example", importing "shlibbu" again with find_package(shlibbu...) and assuming that it would take care of "shlibbi" automatically

And if I start now example, it does what it is supposed to do! At least if I do it inside the QtCreator that I am using as my development environment. And it does so even if the copy process that I would have expected did STILL not happen - like in my initial problem that was drving me mad.

What I thought SHOULD happen is: if I "import" shlibbi into shlibbu, then "installing" shlibbu should also bring libshlibbi.so into the target library directory. And finally, if I "install" also the "example" main project, I would expect also both libshlibbi.so and libshlibbu.so in some location inside the install directory tree of "example".

Instead, all the 3 binaries (shlibbi.so, shlibbu.so and example) remain in their "install" target trees. And "somehow" within QtCreator, the shared libraries are found if I start example. However, if I open a terminal in in the .../example/release/install/bin folder and type ./example there, it only complains about not finding libshlibbu.so.

And if I manually copy libshlibbi.so and libshlibbu.so to that directory, I am STILL getting that same error message: it does not find the two libraries

patchelf --set-rpath '$ORIGIN/.' example
patchelf --set-rpath '$ORIGIN/.' libshlibbu.so

Only if I added a RPATH to both example and libshlibbu.so, the start from the terminal also succeeded in the install target (bin) directory.

So my initially very unspecific (and a bit desperate...) question is now much more precise: How can I get the *.so shared libraries into the same directory as the example (or else in a "parallel" lib64 library) - together with the correct RPATH settings? Because this I also learned from your answers: part of the "copy plus" is handling the RPATH properly!

And this time I also have a stripped down example that does almost nothing (add 3 + 1) in a relatively complicated way (that even includes some regex pattern matching...)

Thanks and regards,
Cornelis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191008/40a2f894/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExportExample.zip
Type: application/zip
Size: 293685 bytes
Desc: not available
URL: <https://cmake.org/pipermail/cmake/attachments/20191008/40a2f894/attachment-0001.zip>


More information about the CMake mailing list