Files
CMake/Tests/RunCMake/target_sources/FileSetGeneratedDependency.cmake
Kyle Edwards d0d09aa29f FILE_SET: Make INTERFACE libraries with HEADER_SETS participate in buildsystem
If an INTERFACE library has HEADER_SETS, and its header sets contain
files generated by a custom command, the library needs to participate in
the buildsystem so that the files will be generated.

Fixes: #23422
2022-04-14 09:17:54 -04:00

13 lines
470 B
CMake

enable_language(C)
add_library(lib INTERFACE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dependency.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/FileSetGeneratedDependency.h.in ${CMAKE_CURRENT_BINARY_DIR}/dependency.h
VERBATIM
)
target_sources(lib PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR} FILES ${CMAKE_CURRENT_BINARY_DIR}/dependency.h)
add_executable(exe dependency.c)
target_link_libraries(exe PRIVATE lib)