@@ -77,6 +77,11 @@ function(exp_process_runtime_dependencies)
7777 )
7878 foreach (d ${arg_DEP_TARGET} )
7979 list (APPEND runtime_deps $<TARGET_FILE :${d} >)
80+ exp_gather_target_runtime_dependencies_recurse (
81+ NAME ${d}
82+ OUT_RUNTIME_DEP dep_target_runtime_deps
83+ )
84+ list (APPEND runtime_deps ${dep_target_runtime_deps} )
8085 endforeach ()
8186 foreach (r ${runtime_deps} )
8287 add_custom_command (
@@ -135,32 +140,32 @@ function(exp_add_resources_copy_command)
135140 add_dependencies (${arg_NAME} ${copy_res_target_name} )
136141endfunction ()
137142
138- function (exp_gather_target_include_dirs )
143+ function (exp_gather_target_libs )
139144 set (options "" )
140145 set (singleValueArgs NAME OUTPUT)
141146 set (multiValueArgs "" )
142147 cmake_parse_arguments (arg "${options} " "${singleValueArgs} " "${multiValueArgs} " ${ARGN} )
143148
144- if (NOT (TARGET ${arg_NAME} ))
145- return ()
146- endif ()
147-
148- get_target_property (target_incs ${arg_NAME} INTERFACE_INCLUDE_DIRECTORIES )
149- if (NOT ("${target_incs} " STREQUAL "target_incs-NOTFOUND" ))
150- foreach (target_inc ${target_incs} )
151- list (APPEND result ${target_inc} )
152- endforeach ()
153- endif ()
149+ string (REGEX MATCH "\\ $\\ <BUILD_INTERFACE.+\\ >" match ${arg_NAME} )
150+ if (match)
151+ set (${arg_OUTPUT} "" PARENT_SCOPE )
152+ endif ()
154153
155154 get_target_property (target_libs ${arg_NAME} LINK_LIBRARIES )
156155 if (NOT ("${target_libs} " STREQUAL "target_libs-NOTFOUND" ))
157156 foreach (target_lib ${target_libs} )
158- exp_gather_target_include_dirs (
157+ string (REGEX MATCH "\\ $\\ <BUILD_INTERFACE.+\\ >" match ${target_lib} )
158+ if (match)
159+ continue ()
160+ endif ()
161+
162+ list (APPEND result ${target_lib} )
163+ exp_gather_target_libs (
159164 NAME ${target_lib}
160- OUTPUT lib_incs
165+ OUTPUT libs
161166 )
162- foreach (lib_inc ${lib_incs } )
163- list (APPEND result ${lib_inc } )
167+ foreach (lib ${libs } )
168+ list (APPEND result ${lib } )
164169 endforeach ()
165170 endforeach ()
166171 endif ()
@@ -189,20 +194,21 @@ function(exp_add_mirror_info_source_generation_target)
189194 endif ()
190195 if (DEFINED arg_LIB)
191196 foreach (l ${arg_LIB} )
192- exp_gather_target_include_dirs (
197+ list (APPEND inc $<TARGET_PROPERTY :${l} ,INTERFACE_INCLUDE_DIRECTORIES >)
198+ exp_gather_target_libs (
193199 NAME ${l}
194- OUTPUT target_incs
200+ OUTPUT target_libs
195201 )
196- foreach (i ${target_incs } )
197- list (APPEND inc ${i} )
202+ foreach (tl ${target_libs } )
203+ list (APPEND inc $< TARGET_PROPERTY : ${tl} , INTERFACE_INCLUDE_DIRECTORIES > )
198204 endforeach ()
199205 endforeach ()
200206 endif ()
201207 list (REMOVE_DUPLICATES inc)
202208
203209 list (APPEND inc_args "-I" )
204210 foreach (i ${inc} )
205- list (APPEND inc_args ${i} )
211+ list (APPEND inc_args \ " ${i} \" )
206212 endforeach()
207213
208214 if (DEFINED arg_FRAMEWORK_DIR)
@@ -336,6 +342,11 @@ function(exp_add_executable)
336342 EXPORT ${SUB_PROJECT_NAME} Targets
337343 RUNTIME DESTINATION ${SUB_PROJECT_NAME} /Binaries
338344 )
345+ export(
346+ TARGETS ${arg_NAME}
347+ NAMESPACE ${SUB_PROJECT_NAME} ::
348+ APPEND FILE ${CMAKE_BINARY_DIR} /${SUB_PROJECT_NAME} Targets.cmake
349+ )
339350
340351 if (${CMAKE_SYSTEM_NAME} STREQUAL " Darwin")
341352 install(CODE " execute_process(COMMAND install_name_tool -add_rpath @executable_path ${CMAKE_INSTALL_PREFIX} /${SUB_PROJECT_NAME} /Binaries/$<TARGET_FILE_NAME :${arg_NAME} >)")
@@ -400,18 +411,18 @@ function(exp_add_library)
400411 endforeach ()
401412 foreach (lib ${arg_PUBLIC_MERGE_LIB} )
402413 if (TARGET ${lib} )
403- get_target_property (target_incs ${lib} INTERFACE_INCLUDE_DIRECTORIES )
404- if (NOT ("${target_incs} " STREQUAL "target_incs-NOTFOUND" ))
405- foreach (target_inc ${target_incs} )
406- list (APPEND public_inc ${target_inc} )
407- endforeach ()
408- endif ()
414+ list(APPEND public_inc $<TARGET_PROPERTY :${lib} ,INTERFACE_INCLUDE_DIRECTORIES >)
409415 endif ()
410416 endforeach ()
411417
412418 foreach (inc ${public_inc} )
413- get_filename_component (absolute_inc ${inc} ABSOLUTE )
414- list (APPEND public_build_inc $<BUILD_INTERFACE :${absolute_inc} >)
419+ string(REGEX MATCH " \\$\\<.+\\>" match ${inc} )
420+ if (match)
421+ list(APPEND public_build_inc $<BUILD_INTERFACE :${inc} >)
422+ else ()
423+ get_filename_component(absolute_inc ${inc} ABSOLUTE)
424+ list(APPEND public_build_inc $<BUILD_INTERFACE :${absolute_inc} >)
425+ endif ()
415426 endforeach ()
416427 target_include_directories(
417428 ${arg_NAME}
@@ -468,13 +479,6 @@ function(exp_add_library)
468479 )
469480 endif ()
470481
471- if (${MSVC} )
472- target_compile_options (
473- ${arg_NAME}
474- PRIVATE /MD$<$<CONFIG:Debug>:d>
475- )
476- endif ()
477-
478482 if (" ${arg_TYPE} " STREQUAL " SHARED")
479483 string(TOUPPER ${arg_NAME} _API api_name)
480484 string(REPLACE " -" " /" api_dir ${arg_NAME} )
@@ -513,6 +517,11 @@ function(exp_add_library)
513517 LIBRARY DESTINATION ${SUB_PROJECT_NAME} /Target/${arg_NAME} /Lib
514518 RUNTIME DESTINATION ${SUB_PROJECT_NAME} /Binaries
515519 )
520+ export(
521+ TARGETS ${arg_NAME}
522+ NAMESPACE ${SUB_PROJECT_NAME} ::
523+ APPEND FILE ${CMAKE_BINARY_DIR} /${SUB_PROJECT_NAME} Targets.cmake
524+ )
516525 if (" ${arg_TYPE} " STREQUAL " SHARED")
517526 install(
518527 FILES $<TARGET_FILE :${arg_NAME} >
0 commit comments