# Preventing installing \`FILE\_SET\` headers from a dependent static library target

**URL:** https://discourse.cmake.org/t/preventing-installing-file-set-headers-from-a-dependent-static-library-target/13400
**Category:** Usage
**Created:** [January 15, 2025, 10:57am UTC](https://discourse.cmake.org/t/preventing-installing-file-set-headers-from-a-dependent-static-library-target/13400 "2025-01-15T10:57:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tonh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/3bc359/32.png) [@tonh](https://discourse.cmake.org/u/tonh)
#### Post date: [January 15, 2025, 10:57am UTC](https://discourse.cmake.org/t/preventing-installing-file-set-headers-from-a-dependent-static-library-target/13400/1 "2025-01-15T10:57:20Z")

</div>

I have some top-level static library `foo` which in turn depends on another static library `foo-dep` which is included in the build using `FetchContent`.

`foo-dep` needs to be installed as part of the installation of `foo`, except for the headers of `foo-dep`. I handle this in the `CMakeLists.txt` of `foo-dep` as follows:

```auto
if(PROJECT_IS_TOPLEVEL)
  install(
    TARGETS foo-dep-static
    FILE_SET HEADERS
  )
endif()

```

However, this results in the following CMake error when building the top-level `foo` project:

```auto
CMake Error at foo-dep/CMakeLists.txt (install):
  install TARGETS target foo-dep-static is exported but not all of its interface
  file sets are installed

```

I found some other topics requesting information on this problem, and it seems CMake does currently not support this use case (which I think is a problem). Assuming this is still a limitation, what would be an acceptable work-around such that the resulting CMake logic will be as idiomatic as possible?

---

<div class="post-metadata">

### Author: ![tonh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/3bc359/32.png) [@tonh](https://discourse.cmake.org/u/tonh)
#### Post date: [January 15, 2025, 11:01am UTC](https://discourse.cmake.org/t/preventing-installing-file-set-headers-from-a-dependent-static-library-target/13400/2 "2025-01-15T11:01:51Z")

</div>

Replying to my own topic 😛

It seems influencing the visibility of the `FILE_SET` depending on `PROJECT_IS_TOPLEVEL` may be a viable solution.
