# How to exclude the system dependency source file from installation?

**URL:** <https://discourse.cmake.org/t/how-to-exclude-the-system-dependency-source-file-from-installation/13427>\
**Category:** Code\
**Created:** [January 18, 2025, 8:35am UTC](https://discourse.cmake.org/t/how-to-exclude-the-system-dependency-source-file-from-installation/13427 "2025-01-18T08:35:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stripe2933](https://discourse.cmake.org/user_avatar/discourse.cmake.org/stripe2933/32/5290_2.png) [@stripe2933](https://discourse.cmake.org/u/stripe2933)\
**Post date:** [January 18, 2025, 8:35am UTC](https://discourse.cmake.org/t/how-to-exclude-the-system-dependency-source-file-from-installation/13427/1 "2025-01-18T08:35:50Z")

</div>

I’m writing Vulkan helper library (named _vku_) with C++20 modules, and it uses `/usr/local/include/vulkan/vulkan.cppm` like this:

```cmake
add_library(vku)
target_sources(vku PUBLIC
    FILE_SET CXX_MODULES
    BASE_DIRS ${Vulkan_INCLUDE_DIRS}/vulkan
    FILES ${Vulkan_INCLUDE_DIRS}/vulkan/vulkan.cppm
    .... # and other module partition sources
)

```

and export the configuration like:

```cmake
include(GNUInstallDirs)
install(
    TARGETS vku
    EXPORT "${PROJECT_NAME}Targets"
    FILE_SET CXX_MODULES DESTINATION module/${PROJECT_NAME}
)
install(
    EXPORT "${PROJECT_NAME}Targets"
    DESTINATION cmake/${PROJECT_NAME}
    NAMESPACE ${PROJECT_NAME}::
    CXX_MODULES_DIRECTORY module/${PROJECT_NAME}
)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
    VERSION ${PROJECT_VERSION}
    COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
    cmake/config.cmake.in
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    INSTALL_DESTINATION cmake/${PROJECT_NAME}
)
install(FILES
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
    DESTINATION cmake/${PROJECT_NAME}
)

```

so make it could be usable with `find_package(vku CONFIG REQUIRED)` syntax.

It install the `vulkan.cppm` file into the installation directory, which makes the problem when `vulkan.cppm` file is updated (by updating the Vulkan SDK). The incompatibility between the included Vulkan headers and module export file triggers the compiler error.

Therefore, I want CMake to not install the `vulkan.cppm` file, and use the system provided one when my library is used by `find_package`. How should I do?
