Files
Matthew Woehlke a5b38fb898 CPS: Implement exporting of file sets
Add (partial) file set export to CPS. For now, only headers ("includes")
are supported, as that is the only overlap with the specification.
(Source file sets are not supported by CPS at this time, and the hope is
that C++ modules will never be supported, as that information should
already be available via the `cpp_module_metadata` information.) CPS
also supports "embeds", but CMake doesn't (yet).

This also introduces our first official use of CPS extensions, used to
record the CMake file set name.
2026-06-30 15:08:02 -04:00

35 lines
762 B
CMake

add_library(foo INTERFACE)
# Primarily this tests for de-duplication of the BASE_DIRS, ensuring DESTINATION
# genex have no effect on build exports is a bonus covering a very unlikely bug
target_sources(foo
INTERFACE
FILE_SET no_genex
TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/foo
FILES
${CMAKE_CURRENT_LIST_DIR}/foo/header1.h
${CMAKE_CURRENT_LIST_DIR}/foo/header2.h
INTERFACE
FILE_SET genex
TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/foo
FILES
${CMAKE_CURRENT_LIST_DIR}/foo/header3.h
)
install(
TARGETS foo
EXPORT foo
DESTINATION .
FILE_SET no_genex
DESTINATION no_genex
FILE_SET genex
DESTINATION $<$<CONFIG:FAKE_CONFIG>:FAKE_DEST>genex
)
export(PACKAGE_INFO foo EXPORT foo)