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

2019-10-08 Thread cornelis
  
  
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
  

  
  

  
  
  
  
  
>   
> On 08.10.2019 at 13:10, Eric Noulardwrote:
>   
>   
>   
>
>   
>   
>   
> Le   mar. 8 oct. 2019 à   12:52, Cornelis Bockemühl   
>  a écrit   :
>   
> >  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
>   
>
>   
> You should read how RPATH handling is done with CMake.
>   
> see:   
> https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
>   
>
>   
> As you already noted there is a build RPATH and an install RPATH.
>   
> The first is used when building the second replace the first after 
> installation takes place.
>   
>   
>
>  --
>   
>   
>   
>   
>   
> Eric
> 
 -- 

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] ?= Looking for an explanation: What exactly means "install" in cmake language

2019-10-08 Thread Eric Noulard
Le mar. 8 oct. 2019 à 12:52, Cornelis Bockemühl  a
écrit :

> 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
>

You should read how RPATH handling is done with CMake.
see:
https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling

As you already noted there is a build RPATH and an install RPATH.
The first is used when building the second replace the first after
installation takes place.

-- 
Eric
-- 

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] Looking for an explanation: What exactly means "install" in cmake language?

2019-10-07 Thread Fred Baksik

On Mon, Oct 7, 2019, at 11:25 AM, Eric Noulard wrote:
> 
> 
> Le lun. 7 oct. 2019 à 16:49, Cornelis Bockemühl  a 
> écrit :
>> Thanks to both you and J Decker: I would say that this is still the part 
>> that I understood! So basically the word "install" in cmake language could 
>> be replaced by "copy" more or less in common human language - right?
> 
> Nope I oversimplified.
> This is not a bare copy, e.g. the runtime path (a.k.a. RPATH or RUNPATH) is 
> updated as well.
> 

File permissions are also set according to what was specified in install() via 
`PERMISSIONS which can be different from the file permissions of the file in 
the build directory.`
`I think I saw that there was even a "make install/strip" feature that also 
stripped targets during installation.`

`I think that the word install is used consistently between GNU autotools and 
CMake:`
*2. * (Computer Science) to transfer (computer software) from a distribution 
file to a permanent location on disk, and prepare it for its particular 
environment and application.

It's that "prepare it for..." clause that makes it different from a straight up 
copy.

I don't know what may be causing your issues. I do know that at least one 
person felt that CMake installation is too aggressive in that it is always 
installing files that it doesn't need to during the installation step.

https://stackoverflow.com/questions/58069372/does-cmake-always-evaluate-install-rules-even-for-up-to-date-targets#comment102540437_58069372

--
Fred-- 

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] Looking for an explanation: What exactly means "install" in cmake language?

2019-10-07 Thread Eric Noulard
Le lun. 7 oct. 2019 à 16:49, Cornelis Bockemühl  a
écrit :

> Thanks to both you and J Decker: I would say that this is still the part
> that I understood! So basically the word "install" in cmake language could
> be replaced by "copy" more or less in common human language - right?
>

Nope I oversimplified.
This is not a bare copy, e.g. the runtime path (a.k.a. RPATH or RUNPATH) is
updated as well.

But then, if it is about "installing" a "target", which is libraries in my
> case, I would expect the shared libraries to be copied - no?
>

Yes the shared lib should be coped and its RPATH updated.


> And this is exactly what does not happen - for no obvious reason! Because
> some days ago it even happened in my project ONCE - and then not any more.
> But debugging is not easy because since that moment I changed many things,
> and basically the reason for my question is that I have no clear idea what
> EXACTLY should happen if I put a
>
> install(TARGETS mylibrary)
>
> into my CMakeLists.txt. Well, like you explained, and like what I also
> thought I had understood: nothing should happen during the configure and
> generate runs of cmake, and also not during the "ninja all" build run, but
> only during the "ninja install". or else cmake --build . --target install
> (which in turn calls ninja in my case). Indeed I observed that it does a
> build for "all" first if the initial project is not up to date.
>
> But then it tells me that it is successfully "installing" mylibrary, but I
> see no shared library appearing in the install tree! Or rather: it happened
> once, but not any more - and I should find out what is missing...
>

.
Are building out-of-tree? (Are your source tree and build tree separate
dir?)
If so, did you try removing the entire build tree and try again ?


May be there is probably some mixup with your install DESTINATION in your
install command.

>
> My current workaround is indeed that I am trying to avoid the install step
> altogether and build a crazy construction with configure_file stuff in
> order to get the libraries to the right place - and I know pretty well that
> this is NOT the way how things should be done properly. But I am afraid I
> will be ready with this workaround way faster than I will understand what
> is going on during this miraculous "install" process!


Provide us with a stripped down non-working example and we may dig into it.
Otherwise it is very difficult to guess what is happening in your
particular case.


-- 
Eric
-- 

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] Looking for an explanation: What exactly means "install" in cmake language?

2019-10-07 Thread Eric Noulard
I'll try some answer.
In order to illustrate my words have a look at this figure:
https://raw.githubusercontent.com/dev-cafe/cmake-cookbook/master/figures/cmake-times/cmake-times.jpg

1) When cmake "runs" (both cmake and generation times) you get your build
tree configured and populated
2) At build times all build artefact are constructed *in the build tree*
somewhere
3) Then when you *install* you copy files/targetd/... from the build tree
down to the "install location".

The fact that CMake install command are "processed" during 1) does not copy
anything before actual [generated] install command are executed during 3).

Le lun. 7 oct. 2019 à 15:44, Cornelis Bockemühl  a
écrit :

> Constantly I am stumbling over the word "install" in the context of cmake
> scripts - while it is pretty clear that the word cannot mean what nowadays
> people would understand by that term! But even reading the docs forwards
> and backwards, studying examples and some generic cmake tutorials I still
> do hot have a PRECISE idea about what it is actually doing and what the
> purpose is. Well, I can see everywhere HOW it is done - but it is sometimes
> an advantage if you also know WHAT!
>
> I know that this question is probably so stupid that I do not really
> expect anybody to answer it here in the mailing list, but maybe somebody
> can point me to a resource that explains it in a language that a "mere
> mortal programmer" can follow?
>
> So far I have a certain kind of understanding, and sometimes it looks like
> this is correct, but then again I have my certain doubts. I am using
> install(TARGETS), install(FILES) and install(EXPORT) so far, and the way I
> am doing it I mostly picked from some general intros and tutorials. And
> from what I understand, this is what I expect to happen:
>
> install(FILES): some files are copied from some location in the build tree
> to some installation location
> install(EXPORT): some cmake script is written that a "derived" project can
> call (through find_package) in order to get knowledge about my project
> install(TARGET): not really an idea what should happen: also some copying
> from build tree to installation tree I suppose
>
> Now I also learned that the install step does not happen during a normal
> build "all" - like "ninja all", but requires an extra "ninja install" step.
> And also I saw that you can adapt the target of the installation process
> like this in your project - if you never ever expect the build to be
> "installed" anywhere else:
>
> set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../install CACHE PATH
> "" FORCE)
>
> With this I would expect to generate an install folder in parallel to the
> bin, lib64 and other folders in the build tree, collecting there all the
> "products" of the build for further processing by a derived project.
>

Nope. CMake will be using the declarative install(...) command
and CMAKE_INSTALL_xxx variables values *at CMake times* in order to
generate scripts
that will be run when you do "ninja install" / "make install".



> But what I see is actually - almost nothing!
>
> Well, the install(FILES) actually copies a file, and the install(EXPORT)
> indeed generates a cmake script, but from the install(TARGET) I see no
> effect: the install folder remains completely empty! Still I see in the log
> many things like "Installing: /.../install/bin/" - but I never
> find then  in that indicated location. But yes, it said
> "installing", not "copying" - so I am back to my initial question: what the
> hell is "installing" in cmake language?
>

Copying some build tree artefact to the specified install location.


> So basically my problem is: I cannot judge whether my script is working
> because I simply do not know what SHOULD be the effect of install(TARGET)!
>
> Ah yes, my build tree is after a "normal build" ("all", not "install")
> full of cmake_install.cmake files that would probably have something to do
> with that "installation" process, but what? Am I supposed to call them on
> any occasion or are they supposed to be called automatically at some moment?
>

cmake_install.cmake are cmake scripts that are executed when you do
"ninja install" i.e. when you build the pseudo target "install".


> Finally, I managed to get also some find_package() working for my project.
> The "heart" of this is a Config.cmake script that I am generating
> during the project build, and which I can write in whatever way I want. For
> example, I am reading everywhere that I am supposed to do an
> install(EXPORT) in order to make that find_package() happen, but since I do
> not really understand what it is supposed to do, and I also see that I can
> simply write that Config file in such a way that it picks things from where
> the build process puts them, I do not really see the point.
>
> In other words: I tend to simply write config scripts for the import that
> rely on the build tree and simply skip that install step - because getting
> this to work is so 

Re: [CMake] Looking for an explanation: What exactly means "install" in cmake language?

2019-10-07 Thread J Decker
Install steps are done with `cmake --build . --target install`  (or
--target INSTALL on some generators)
It's done after the build is complete, if the build step fails, it will not
install.  (Install depends on build automatically)

The install steps can also be used by --target package - which you can use
a packager to .tar.gz or NSIS(?) Executable or.  It needs some CPACK
instructions set.


On Mon, Oct 7, 2019 at 6:44 AM Cornelis Bockemühl 
wrote:

> Constantly I am stumbling over the word "install" in the context of cmake
> scripts - while it is pretty clear that the word cannot mean what nowadays
> people would understand by that term! But even reading the docs forwards
> and backwards, studying examples and some generic cmake tutorials I still
> do hot have a PRECISE idea about what it is actually doing and what the
> purpose is. Well, I can see everywhere HOW it is done - but it is sometimes
> an advantage if you also know WHAT!
>
> I know that this question is probably so stupid that I do not really
> expect anybody to answer it here in the mailing list, but maybe somebody
> can point me to a resource that explains it in a language that a "mere
> mortal programmer" can follow?
>
> So far I have a certain kind of understanding, and sometimes it looks like
> this is correct, but then again I have my certain doubts. I am using
> install(TARGETS), install(FILES) and install(EXPORT) so far, and the way I
> am doing it I mostly picked from some general intros and tutorials. And
> from what I understand, this is what I expect to happen:
>
> install(FILES): some files are copied from some location in the build tree
> to some installation location
> install(EXPORT): some cmake script is written that a "derived" project can
> call (through find_package) in order to get knowledge about my project
> install(TARGET): not really an idea what should happen: also some copying
> from build tree to installation tree I suppose
>
> Now I also learned that the install step does not happen during a normal
> build "all" - like "ninja all", but requires an extra "ninja install" step.
> And also I saw that you can adapt the target of the installation process
> like this in your project - if you never ever expect the build to be
> "installed" anywhere else:
>
> set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../install CACHE PATH
> "" FORCE)
>
> With this I would expect to generate an install folder in parallel to the
> bin, lib64 and other folders in the build tree, collecting there all the
> "products" of the build for further processing by a derived project.
>
> But what I see is actually - almost nothing!
>
> Well, the install(FILES) actually copies a file, and the install(EXPORT)
> indeed generates a cmake script, but from the install(TARGET) I see no
> effect: the install folder remains completely empty! Still I see in the log
> many things like "Installing: /.../install/bin/" - but I never
> find then  in that indicated location. But yes, it said
> "installing", not "copying" - so I am back to my initial question: what the
> hell is "installing" in cmake language?
>
> So basically my problem is: I cannot judge whether my script is working
> because I simply do not know what SHOULD be the effect of install(TARGET)!
>
> Ah yes, my build tree is after a "normal build" ("all", not "install")
> full of cmake_install.cmake files that would probably have something to do
> with that "installation" process, but what? Am I supposed to call them on
> any occasion or are they supposed to be called automatically at some moment?
>
> Finally, I managed to get also some find_package() working for my project.
> The "heart" of this is a Config.cmake script that I am generating
> during the project build, and which I can write in whatever way I want. For
> example, I am reading everywhere that I am supposed to do an
> install(EXPORT) in order to make that find_package() happen, but since I do
> not really understand what it is supposed to do, and I also see that I can
> simply write that Config file in such a way that it picks things from where
> the build process puts them, I do not really see the point.
>
> In other words: I tend to simply write config scripts for the import that
> rely on the build tree and simply skip that install step - because getting
> this to work is so difficult if you never know what is supposed to happen
> how and at what stage of the process and under which conditions!
>
> But then I see that others are still using the install() steps, so there
> is probably still some meaning in it...
>
> So IF such a thing exists, like a comprehensive explanation about what
> "install" actually means and what it is supposed to do at what stage of the
> process, I would be very happy and thankful!
>
> 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] Looking for an explanation: What exactly means "install" in cmake language?

2019-10-07 Thread Cornelis Bockemühl

Constantly I am stumbling over the word "install" in the context of cmake 
scripts - while it is pretty clear that the word cannot mean what nowadays 
people would understand by that term! But even reading the docs forwards and 
backwards, studying examples and some generic cmake tutorials I still do hot 
have a PRECISE idea about what it is actually doing and what the purpose is. 
Well, I can see everywhere HOW it is done - but it is sometimes an advantage if 
you also know WHAT!

I know that this question is probably so stupid that I do not really expect 
anybody to answer it here in the mailing list, but maybe somebody can point me 
to a resource that explains it in a language that a "mere mortal programmer" 
can follow?

So far I have a certain kind of understanding, and sometimes it looks like this 
is correct, but then again I have my certain doubts. I am using 
install(TARGETS), install(FILES) and install(EXPORT) so far, and the way I am 
doing it I mostly picked from some general intros and tutorials. And from what 
I understand, this is what I expect to happen:

install(FILES): some files are copied from some location in the build tree to 
some installation location
install(EXPORT): some cmake script is written that a "derived" project can call 
(through find_package) in order to get knowledge about my project
install(TARGET): not really an idea what should happen: also some copying from 
build tree to installation tree I suppose

Now I also learned that the install step does not happen during a normal build 
"all" - like "ninja all", but requires an extra "ninja install" step. And also 
I saw that you can adapt the target of the installation process like this in 
your project - if you never ever expect the build to be "installed" anywhere 
else:

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../install CACHE PATH "" 
FORCE)

With this I would expect to generate an install folder in parallel to the bin, 
lib64 and other folders in the build tree, collecting there all the "products" 
of the build for further processing by a derived project.

But what I see is actually - almost nothing!

Well, the install(FILES) actually copies a file, and the install(EXPORT) indeed 
generates a cmake script, but from the install(TARGET) I see no effect: the 
install folder remains completely empty! Still I see in the log many things 
like "Installing: /.../install/bin/" - but I never find then 
 in that indicated location. But yes, it said "installing", not 
"copying" - so I am back to my initial question: what the hell is "installing" 
in cmake language?

So basically my problem is: I cannot judge whether my script is working because 
I simply do not know what SHOULD be the effect of install(TARGET)!

Ah yes, my build tree is after a "normal build" ("all", not "install") full of 
cmake_install.cmake files that would probably have something to do with that 
"installation" process, but what? Am I supposed to call them on any occasion or 
are they supposed to be called automatically at some moment?

Finally, I managed to get also some find_package() working for my project. The 
"heart" of this is a Config.cmake script that I am generating during 
the project build, and which I can write in whatever way I want. For example, I 
am reading everywhere that I am supposed to do an install(EXPORT) in order to 
make that find_package() happen, but since I do not really understand what it 
is supposed to do, and I also see that I can simply write that Config file in 
such a way that it picks things from where the build process puts them, I do 
not really see the point.

In other words: I tend to simply write config scripts for the import that rely 
on the build tree and simply skip that install step - because getting this to 
work is so difficult if you never know what is supposed to happen how and at 
what stage of the process and under which conditions!

But then I see that others are still using the install() steps, so there is 
probably still some meaning in it...

So IF such a thing exists, like a comprehensive explanation about what 
"install" actually means and what it is supposed to do at what stage of the 
process, I would be very happy and thankful!

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