# Why are thirdparty c++ header files being installed with my executable

**URL:** https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354
**Category:** Usage
**Tags:** os:windows
**Created:** [January 8, 2025, 3:22pm UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354 "2025-01-08T15:22:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![usermarqueemark](https://discourse.cmake.org/user_avatar/discourse.cmake.org/usermarqueemark/32/5256_2.png) [@usermarqueemark](https://discourse.cmake.org/u/usermarqueemark)
#### Post date: [January 8, 2025, 3:22pm UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354/1 "2025-01-08T15:22:19Z")

</div>

I am using CMake `FetchContent_MakeAvailable` to build a number of thirdparty depenencies from github, e.g. in the file **PDFHummus.cmake**

```auto
if(NOT PDFHummus_POPULATED)

  Include(FetchContent)
  FetchContent_Declare(
      PDFHummus
      GIT_REPOSITORY ${REPO}
      GIT_TAG v4.6.8
      DOWNLOAD_EXTRACT_TIMESTAMP FALSE
      FIND_PACKAGE_ARGS
  )
  FetchContent_MakeAvailable(PDFHummus)

endif()

```

I later use this via:

```auto

add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})

target_include_directories(${PROJECT_NAME} PRIVATE include)
target_link_libraries(${PROJECT_NAME} PRIVATE PDFHummus::PDFWriter)
link_current_target_statically(${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin)

```

When I build using `cmake --build --preset Debug-Windows --target=Install` my execuatble is corrctecly copied to the `install/windows/bin` directory BUT all of the header files & CMake files for `PDFHummus` are also copied to the `install/windows` directory. This also happend for other thirdparty libraries I am building.

I assume the `install()` targets from the thirdpart libraries are causing the issue and adding additional istall targets to the `build/windows/install_manifest.txt`.

How can I prevent this so that only the targets I specifically name get copied?

Note I already have the following for the one thing I want in the install directory;

```auto
install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin)

```

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [January 8, 2025, 3:59pm UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354/2 "2025-01-08T15:59:34Z")

</div>

I put everything my project wants to install into a separate component and then install only that component.

---

<div class="post-metadata">

### Author: ![usermarqueemark](https://discourse.cmake.org/user_avatar/discourse.cmake.org/usermarqueemark/32/5256_2.png) [@usermarqueemark](https://discourse.cmake.org/u/usermarqueemark)
#### Post date: [January 8, 2025, 4:46pm UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354/3 "2025-01-08T16:46:19Z")

</div>

I already have the following for the only think I want installed

```auto
# Configure installation of the executable -----------------------------------|
install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin)

```

but it hasn’t helped…

I have also tried adding the following but no matter what I try the files are added to the install directory

```auto
set(CMAKE_INSTALL_LOCAL_ONLY ON CACHE BOOL "Limit installation to local targets only" FORCE)

include (PDFHummus)
include (CTRE)

set(PDFHummus_SKIP_INSTALL TRUE CACHE BOOL "Skip PDFHummus installation" FORCE)
set(YAML_CPP_SKIP_INSTALL TRUE CACHE BOOL "Skip yaml-cpp installation" FORCE)
set(CTRE_SKIP_INSTALL TRUE CACHE BOOL "Skip CTRE installation" FORCE)

```

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [January 9, 2025, 7:25am UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354/4 "2025-01-09T07:25:54Z")

</div>

I meant something like:

```auto
# Configure installation of the executable -----------------------------------|
install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin
        COMPONENT MY_SUPER_COMPONENT
)

```

```auto
cmake --install . --component MY_SUPER_COMPONENT

```

---

<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: [January 13, 2025, 9:25pm UTC](https://discourse.cmake.org/t/why-are-thirdparty-c-header-files-being-installed-with-my-executable/13354/5 "2025-01-13T21:25:02Z")

</div>

Does the EXCLUDE\_FROM\_ALL option help ?
