Skip to content

Commit 8d468c1

Browse files
authored
NFC: Make clang resource headers an interface library (llvm#88317)
Making the clang resource headers into an interface library instead of a custom target means that we can attach the header search paths to the library. Targets that "link" against this library will automatically have the appropriate paths added to their header search paths to find them. Then downstream projects that embed a copy of clang can query the generated `ClangTargets.cmake` file for the header location instead of attempting to compute them.
1 parent b794dc2 commit 8d468c1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

clang/lib/Headers/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,14 @@ foreach( f ${generated_files} )
437437
endforeach( f )
438438

439439
function(add_header_target target_name file_list)
440-
add_custom_target(${target_name} DEPENDS ${file_list})
440+
add_library(${target_name} INTERFACE ${file_list})
441441
set_target_properties(${target_name} PROPERTIES
442442
FOLDER "Misc"
443443
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
444444
endfunction()
445445

446446
# The catch-all clang-resource-headers target
447-
add_custom_target("clang-resource-headers" ALL DEPENDS ${out_files})
447+
add_library(clang-resource-headers INTERFACE ${out_files})
448448
set_target_properties("clang-resource-headers" PROPERTIES
449449
FOLDER "Misc"
450450
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
@@ -501,6 +501,10 @@ add_header_target("windows-resource-headers" ${windows_only_files})
501501
add_header_target("utility-resource-headers" ${utility_files})
502502

503503
get_clang_resource_dir(header_install_dir SUBDIR include)
504+
target_include_directories(clang-resource-headers INTERFACE
505+
$<BUILD_INTERFACE:${output_dir}>
506+
$<INSTALL_INTERFACE:${header_install_dir}>)
507+
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS clang-resource-headers)
504508

505509
#############################################################
506510
# Install rules for the catch-all clang-resource-headers target

0 commit comments

Comments
 (0)