I’m writing Vulkan helper library (named vku) with C++20 modules, and it uses /usr/local/include/vulkan/vulkan.cppm
like this:
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:
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?