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

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

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:


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;

install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin)

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

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

# 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

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)

I meant something like:

# Configure installation of the executable -----------------------------------|
install(TARGETS ${PROJECT_NAME}
        RUNTIME DESTINATION bin
        COMPONENT MY_SUPER_COMPONENT
)
cmake --install . --component MY_SUPER_COMPONENT
1 Like

Does the EXCLUDE_FROM_ALL option help ?