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

2019-10-08 Thread Cornelis Bockemühl

After stripping down the question to "can I install an imported target"? - with 
the purpose to copy the shared libraries also into the lib directory of the 
importing project - I could actually also use Google and look for an answer 
that somebody else might have been asked.

And indeed: this seems to be a rather common question!

And the "official answer" seems to be something like "this bug is a feature". 
It must have been a change request already years ago, and it was refused with 
different arguments, like:

1) proper RPATH handling is not possible in this case, because CMake cannot 
know the way how the shared library was built initially, so it is not able to 
manipulate it.

At first this looks plausible, but then I was thinking that in Linux you always 
deal with ELF binaries, and there you have tools to manipulate RPATH/RUNPATH 
easily, and in Windows there is nothing similar - and others I don't know...

2) the target is already installed, so it makes no sense to install it again; 
it would only be a waste of disk space.

Well, in my case it would make a lot of sense, and also for any kind of 
packager that might use the install directory it would be much easier if all 
the stuff is already in one location.

3...) maybe others - I did not follow further.

In any case the conclusion is: It's like it is, and all my confusion came 
basically from this strange behaviour - that "install" is not always really 
"install" (but now I know at least when and why!). And the only way around - if 
I want to avoid the configure_file solution - would be to do some proper 
install(FILES...) instead - together with a little hacking regarding what the 
right files actually are.

Best regards, Cornelis
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


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

2019-10-08 Thread Cornelis Bockemühl

Actually I implemented yesterday a way how to copy the shared libs - with 
configure_file() and a lot of frickling around with the lib names myself, like 
finding out the extension on Linux and Windows, etc.

Now I tried to include the following command in the "shlibbiConfig.cmake.in" 
file:

install(TARGETS shlibbi::SHLIBbi
    EXPORT
    shlibbi-targets
    LIBRARY DESTINATION
    ${CMAKE_INSTALL_LIBDIR})

With this, I would expect that I am not "copying files", but "installing 
targets" - so actually a more abstract and powerful level - if it works! Since 
the generated shlibbiConfig.cmake would finally run in the context of the 
importing project, i.e. during a find_package() call, it should actually 
transfer the lib files from that imported target into the CMAKE_INSTALL_LIBDIR 
of the calling project - so exactly what I need.

However, the result is an error message:
 
install TARGETS given target "shlibbi::SHLIBbi" which does not exist.
Well, it exists, because it is generated in the auto-generated 
shlibbiTargets.cmake file like this:

add_library(shlibbi::SHLIBbi SHARED IMPORTED)

and that shlibbiTargets.cmake was called inside shlibbiConfig.cmake BEFORE the 
above install(TARGETS...) call.

Conclusion: "imported targets" are not "fully valid targets", because while I 
can now refer to that imported target, like with an #include ... in my source 
code, or with a successful link to the library, but obviously I cannot 
"install" that target.

So my question can be even more specified now: Is there a way around this 
"install blockage" that would allow me to do the required transfer of the 
shared library into the lib folder of the calling project - and then even 
further also to the caller's calling project? I mean: with the effect of first 
moving libshlibbi.so to the lib directory of the shlibbu project, and then both 
the libshlibbi.so and the libshlibbu.so to the example project - of course 
including the required adaptation of the RPATH

Because that is what I learned: doing the transfer with install() instead of a 
file copy through configure_file gives me not only the more abstract level of 
project organization, but also takes care of the RPATH...

Best regards,
Cornelis

Am Dienstag, Oktober 08, 2019 14:07 CEST, cornelis  
schrieb:
 Thanks for that hint! But for me the RPATH stuff is only a supplement, because 
in the context of a Paraview based project, most of my shared libs are plugins, 
and for these PV comes with its own mechanism to find them. But then all the 
more important is the question about actually copying the libs - to a specific 
location where the plugin finding procedure finds them! Regards, Cornelis
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


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

2019-10-08 Thread Cornelis Bockemühl

One more finding: the "magic" that QtCreator does to start example also without 
any additional fiddling with the RPATH: it already contains a RUNPATH, and this 
points to the shared library libshlibbu.so in it's build tree location, not in 
the installed location - and the same with libshlibbu.so.

And the "install" process indeed handles the RPATH/RUNPATH: it simply removes 
it!

Meaning: it I want to end up what I initially expected, I have to do two 
additional things manually (or maybe there is an automatic way??):

1) copy the shared libraries to the "example" install directory tree
2) add some RPATH or RUNPATH setting to all the binaries that need it

Regards, Cornelis
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


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

2019-10-08 Thread Cornelis Bockemühl

The missing link to my "cmake teacher web page": 
https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/

Regards, Cornelis
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake