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/<somefile>" - but I never find then 
<somefile> 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 <Project>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

Reply via email to