Skip to content

Commit d58fdba

Browse files
committed
move add_interface_library_before inside generate_data_descriptors
1 parent 8f13833 commit d58fdba

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/coreclr/clrdatadescriptors.cmake

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ function(generate_data_descriptors)
66
set(multiValueArgs "")
77
cmake_parse_arguments(DATA_DESCRIPTORS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV})
88

9+
# Helper Function
10+
# Links in an interface to a target with the interface include directories included
11+
# before the targets include directories.
12+
function(add_interface_library_before target_name interface_name)
13+
get_target_property(target_includes ${target_name} INCLUDE_DIRECTORIES)
14+
target_link_libraries(${target_name} PRIVATE ${interface_name})
15+
set_target_properties(${target_name} PROPERTIES INCLUDE_DIRECTORIES "${target_includes}")
16+
17+
get_target_property(interface_includes ${interface_name} INTERFACE_INCLUDE_DIRECTORIES)
18+
target_include_directories(${target_name} BEFORE PRIVATE ${interface_includes})
19+
endfunction(add_interface_library_before)
20+
921
# INTERMEDIARY_LIBRARY is used as part of the build and not linked into the final product.
1022
set(INTERMEDIARY_LIBRARY ${DATA_DESCRIPTORS_LIBRARY_NAME}_temp)
1123
set(LIBRARY ${DATA_DESCRIPTORS_LIBRARY_NAME})
@@ -49,7 +61,7 @@ function(generate_data_descriptors)
4961
endif()
5062

5163
# inherit definitions, include directories, and dependencies from the INTERFACE target
52-
add_interface_library(${INTERMEDIARY_LIBRARY} ${DATA_DESCRIPTORS_INTERFACE_TARGET})
64+
add_interface_library_before(${INTERMEDIARY_LIBRARY} ${DATA_DESCRIPTORS_INTERFACE_TARGET})
5365

5466
set(CONTRACT_BASELINE_DIR "${CLR_REPO_ROOT_DIR}/docs/design/datacontracts/data")
5567
set(CONTRACT_DESCRIPTOR_INPUT "${DATA_DESCRIPTOR_SHARED_SOURCE_DIR}/contract-descriptor.c.in")
@@ -81,17 +93,7 @@ function(generate_data_descriptors)
8193
)
8294

8395
# inherit definitions, include directories, and dependencies from the INTERFACE target
84-
add_interface_library(${LIBRARY} ${DATA_DESCRIPTORS_INTERFACE_TARGET})
96+
add_interface_library_before(${LIBRARY} ${DATA_DESCRIPTORS_INTERFACE_TARGET})
8597
endif()
8698
endfunction(generate_data_descriptors)
8799

88-
# Links in an interface to a target with the interface include directories included
89-
# before the targets include directories.
90-
function(add_interface_library target_name interface_name)
91-
get_target_property(target_includes ${target_name} INCLUDE_DIRECTORIES)
92-
target_link_libraries(${target_name} PRIVATE ${interface_name})
93-
set_target_properties(${target_name} PROPERTIES INCLUDE_DIRECTORIES "${target_includes}")
94-
95-
get_target_property(interface_includes ${interface_name} INTERFACE_INCLUDE_DIRECTORIES)
96-
target_include_directories(${target_name} BEFORE PRIVATE ${interface_includes})
97-
endfunction(add_interface_library)

0 commit comments

Comments
 (0)