[CMake] [CPack] Avoiding packaging (some) dependencies

Drago Trusk drago.trusk at gmail.com
Thu May 17 17:21:28 EDT 2018


Thank you for your answer!

I was afraid there was no other option.
Problem is that "Ignorable" is a transient dependency of a target which I
need (both don't specify components) and therefore both are somewhat out of
my control, but I guess modification to them will be necessary.

I wasn't aware of REMOVE_ITEM CPACK_COMPONENTS_ALL and hint is much
appreciated (though sadly I cannot use it). Good to know ;)

On Wed, May 16, 2018 at 10:37 AM Eric Noulard <eric.noulard at gmail.com>
wrote:

>
>
> 2018-05-16 9:33 GMT+02:00 Drago Trusk <drago.trusk at gmail.com>:
>
>> Hi everyone,
>>
>> I have particular problem which I'm unable to solve.
>>
>> Lets say there are following components:
>>  - Main: library/executable
>>  - Ignorable: Main requires it to build, but not for packaging
>>
>> Main simply defines:
>> add_dependencies(Main Ignorable)
>>
>> FindIgnorable.cmake contains something like:
>> add_custom_target(Ignorable
>>   COMMAND ... ... && cmake --build --target install .
>>   # ...
>> )
>>
>> Problem is that deb cpack generator picks this from install tree (tar/zip
>> doesn't contain Ignorable). So deb ends up with:
>> # ... correct fs hierarchy
>> /home/saduser/projects/ignorableinstall
>>
>> I need to avoid dependency used only for building artifacts.
>>
>> What I found:
>> - Remove add_dependency
>> ---- Problem: have to build dependencies manually and will break CI and
>> other people builds
>> - Disable automatic packaging of everything and specify custom components
>> to package
>> ---- Problem: Dependency tree which might be bigger and requires to know
>> too many details. In addition requires for outside  changes so that all
>> targets have (appropriate)  install conponents.
>>
>> I tried everything else that is possible. Am i missing something or are
>> those two only viable options?
>>
>
> I think the second option should be ok and not that complicated.
> Put the "Ignorable" in an "IgnoredComp" install component and remove this
> component from the list of installed components.
>
> get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
> list(REMOVE_ITEM CPACK_COMPONENTS_ALL """)
>
> see: https://cmake.org/cmake/help/v3.11/module/CPackComponent.html
>
> AFAIR you don't need to defined a component for every install because
> CPack already does that for you.
> I think that every bits installed without component specification ends-up
> in the trap-them-all
> "Unspecified" component which is automatically created by CPack.
>
> see:
> https://cmake.org/cmake/help/v3.11/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME.html
>
> Another way to do that even more simply (**if you are sure no component
> are defined**)
> would be to:
>
> 1) install ignorable in "IgnoredComp" component
> 2) let all other be in your default component
> set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "InstallThatOnly")
> 3) only install your default component
> set(CPACK_COMPONENTS_ALL "InstallThatOnly")
>
>
> --
> Eric
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180517/b1277fe6/attachment.html>


More information about the CMake mailing list