CPack installs project

Hi,

I very unsure right now, but I think cpack used to only generate the packages and not install the Project itself.
But currently when running “cpack .” or “cmake … --target package” it attempts to install the project and obviously fails, because it does not have the rights to install things on my system.

Is this intentional? Was this the same behaviour in the past?

CPack always DOES install but to the staging area and then package the result. I vaguely remember thing may go south if you have hardcoded absolute paths as your install destinations.

1 Like

I think you’re right, there are a couple of problems in Fetched Dependencies I didn’t have before, because these dependencies are new.

Now the question ist: How is this best solved (except from fixing everything upstream, don’t have time for that)?

My First approach was to set set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL YES) for every FetchContent Dependency.
This helps already.

I also have on my own install rules a Component specified. Can I tell cpack to only use my Component?

What is the recommend way here`

That’s exactly what I have started doing because some of my dependencies do not behave…
This is example of what I do (in this case I want my program as the only thing in the .tar.gz archive):

#somewhere
install(TARGETS myExe RUNTIME DESTINATION . COMPONENT myComponent)
# near packaging code
set(CPACK_COMPONENTS_ALL myComponent)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_GENERATOR "TGZ")
set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE")

If myComponent is unique enough, I can stop carrying about the third party stuff :wink:

1 Like

I was doing already similary, but I missed

set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)

So adding that fixed the issue for me as well!

(Although I wonder why, shouldn’t CPACK_COMPONENTS_ALL be enough?)