# Empty COMPONENT package created with EXCLUDE\_FROM\_ALL

**URL:** https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732
**Category:** Development
**Created:** [September 19, 2024, 9:49pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732 "2024-09-19T21:49:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [September 19, 2024, 9:49pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732/1 "2024-09-19T21:49:33Z")

</div>

If I use add\_subdirectory(foo EXCLUDE\_FROM\_ALL), and do  
install(FILES foo.h COMPONENT Devel), and then do a component-package with the tgz (ARCHIVE)-generator, it creates an empty Foo-Devel.tar.gz.  
It is empty because the directory was added with EXCLUDE\_FROM\_ALL, so foo.h was not installed, that’s Ok.  
But since the component “Devel” is empty, it shouldn’t create an empty package for it.

Where’s the correct place to fix that ?  
In the place where EXCLUDE\_FROM\_ALL is handled, and skip components which are empty ?  
Or in the place where the package is created, to skip installing components which are empty ?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [September 19, 2024, 11:05pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732/2 "2024-09-19T23:05:52Z")

</div>

Honestly, I would try to avoid installing anything from a directory that is excluded from the ALL target. There are holes in the logic around that, and you’ve probably stumbled on one of them. There have been other cases reported where the excluded content isn’t quite fully excluded in all situations, leading to failures because things that were expected to exist or be built, weren’t.

But to answer your question, if you want to avoid packaging an excluded component, you would need to explicitly set the `CPACK_COMPONENTS_ALL` variable to just the components you want to create packages for. You can get the full list of defined components from the `CPACK_COMPONENTS_ALL` pseudo property. For example:

```cmake
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL MyProj_ComponentIDoNotWant)

```

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [September 25, 2024, 9:34pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732/3 "2024-09-25T21:34:05Z")

</div>

Thanks, that works.

I couldn’t find documentation for the COMPONENTS property here: [https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html](https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html)  
Is there a reason for it ?

Thanks

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [September 25, 2024, 10:08pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732/4 "2024-09-25T22:08:02Z")

</div>

I believe it is not a true property, it’s one of those weird pseudo properties that you can only read using `get_cmake_property()`. I don’t think you can retrieve it using `get_property()`. I don’t recall the full list, but I think there are a few pseudo properties like this (but it’s a small list).

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [September 26, 2024, 7:53pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732/5 "2024-09-26T19:53:10Z")

</div>

Right, I found it.  
[https://cmake.org/cmake/help/latest/command/get\_cmake\_property.html](https://cmake.org/cmake/help/latest/command/get_cmake_property.html)  
Would it be ok to add COMPONENTS documentation to the global properties ?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [September 26, 2024, 10:28pm UTC](https://discourse.cmake.org/t/empty-component-package-created-with-exclude-from-all/11732/6 "2024-09-26T22:28:55Z")

</div>

`COMPONENTS` is not a global property, it is a _pseudo property_ that you cannot read with `get_property()`. If we list `COMPONENTS` as a global property, I guarantee people will try to read it with `get_property()` and wonder why they get back an empty string. If we add it to the properties page in the docs, it would need to be in its own new separate section, and it would have to somehow make clear that properties in this new section are special, not global properties.

I agree it’s not very discoverable at the moment. I don’t know that making the pseudo property more visible its current state is a great outcome, it may create as many problems as it solves. Perhaps it would be worth exploring whether `get_property()` can be extended to support reading pseudo properties and we deprecate `cmake_property()`. But I suspect there are negative performance implications if we were to do that. This would be something that’s more @brad.king’s call.
