CMake: Transfer target_link_options from component libs to metalibs

This commit is contained in:
rdb 2022-03-09 14:41:48 +01:00
parent 264747d213
commit e8f3565af2

View File

@ -228,6 +228,7 @@ function(add_metalib target_name)
set(interface_defines) set(interface_defines)
set(includes) set(includes)
set(libs) set(libs)
set(link_options)
set(component_init_funcs "") set(component_init_funcs "")
foreach(component ${components}) foreach(component ${components})
if(NOT TARGET "${component}") if(NOT TARGET "${component}")
@ -315,6 +316,16 @@ function(add_metalib target_name)
endif() endif()
endforeach(component_library) endforeach(component_library)
# All the linker options applied to an individual component get applied
# when building the metalib (for things like --exclude-libs).
get_target_property(component_link_options "${component}" LINK_OPTIONS)
foreach(component_link_option ${component_link_options})
if(component_link_option)
list(APPEND link_options "${component_link_option}")
endif()
endforeach(component_link_option)
# Consume this component's objects # Consume this component's objects
list(APPEND sources "$<TARGET_OBJECTS:${component}>") list(APPEND sources "$<TARGET_OBJECTS:${component}>")
@ -342,6 +353,7 @@ function(add_metalib target_name)
PRIVATE ${private_defines} PRIVATE ${private_defines}
INTERFACE ${interface_defines}) INTERFACE ${interface_defines})
target_link_libraries("${target_name}" ${libs}) target_link_libraries("${target_name}" ${libs})
target_link_options("${target_name}" PRIVATE ${link_options})
target_include_directories("${target_name}" target_include_directories("${target_name}"
PUBLIC ${includes} PUBLIC ${includes}
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/panda3d>") INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/panda3d>")