# Headers not found in coremodel\_v2 (2.6) when installed with library

**URL:** https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591
**Category:** Code
**Created:** [April 5, 2024, 5:01pm UTC](https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591 "2024-04-05T17:01:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MementoRC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mementorc/32/4470_2.png) [@MementoRC](https://discourse.cmake.org/u/MementoRC)
#### Post date: [April 5, 2024, 5:01pm UTC](https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591/1 "2024-04-05T17:01:36Z")

</div>

Using this syntax:

```auto
install(TARGETS _core_lib
    LIBRARY DESTINATION lib
    FILE_SET HEADERS DESTINATION include
)

```

The headers in the FILE\_SET are installed correctly, however they do not appear in the coremodel\_v2 (2.6) reply

The intent is to use a large third-party project (multiple libraries with various headers) and reconstruct the artifacts from a subset of targets  
The artifacts are found, but not their respective headers

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 11, 2024, 4:47pm UTC](https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591/2 "2024-04-11T16:47:06Z")

</div>

Could you please provide a small example project showing the problem?

Cc: @brad.king

---

<div class="post-metadata">

### Author: ![MementoRC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mementorc/32/4470_2.png) [@MementoRC](https://discourse.cmake.org/u/MementoRC)
#### Post date: [April 11, 2024, 6:39pm UTC](https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591/3 "2024-04-11T18:39:31Z")

</div>

So, since then I learned a bit more about CMake syntax. Here is the project I use in my tests:

```auto
cmake_minimum_required(VERSION 3.28)
project(sckit_build_core_plugin LANGUAGES C)

add_executable(_core src/example.c)
add_library(_library STATIC src/example_lib.c)
target_sources(_library PUBLIC FILE_SET HEADERS BASE_DIRS include FILES include/example1.h include/example2.h)

install(TARGETS _core RUNTIME DESTINATION bin)
install(TARGETS _library
    ARCHIVE DESTINATION lib
    FILE_SET HEADERS DESTINATION include
)

```

I anticipated that the `coremodel_v2` would list 2 targets (it does) and that the `HEADERS` fileset would be listed in the `_library` target, as per the definition of the target in the CMakeLists.txt, they are not, in fact `example?.h` are not found in the coremodel\_v2, at all

The end goal was to identify the targets in a external project and configure which targets I wanted installed … right, this is not a thing I discovered, CMake does not install targets, please correct me.

So since then I moved onto defining `COMPONENTS`, which can be independently installed, but not all projects will associate their TARGETS with COMPONENTS, and if I only build part of the TARGETS, CMake will fail trying to install the non-built TARGETS.

I guess, I segway’d into my real problem as a ‘bonus’ question - though it is normal that the HEADERS are not found in the coremodel\_v2?

For completeness, the rest of the test that selects TARGETS & COMPONENTS:

```auto
cmake_minimum_required(VERSION 3.28)
project(sckit_build_core_plugin LANGUAGES C)

add_executable(_core src/example.c)
add_library(_library STATIC src/example_lib.c)
target_sources(_library PUBLIC FILE_SET HEADERS BASE_DIRS include FILES include/example1.h include/example2.h)

install(TARGETS _core RUNTIME DESTINATION bin COMPONENT executables)
install(TARGETS _library
    ARCHIVE DESTINATION lib
    COMPONENT libraries
    FILE_SET HEADERS DESTINATION include
    COMPONENT headers
)

```

So, I also discovered the `directory-...` dataset. So, I first discover the TARGETS, build the ones I want, then look in the `directory-...` which COMPONENTS they belong to and if I find one `Unspecified`, then I rebuild all the targets and install all, because I would not know how the project intended to build/install the TARGETS. Hope this is not too confusing  
Thank you
