diff --git a/MyxCMake/lib/AddInterfaceLibrary.cmake b/MyxCMake/lib/AddInterfaceLibrary.cmake index f8eedd3..789cb04 100644 --- a/MyxCMake/lib/AddInterfaceLibrary.cmake +++ b/MyxCMake/lib/AddInterfaceLibrary.cmake @@ -57,17 +57,28 @@ function(myx_add_interface_library TARGET_NAME) endforeach() if(ARG_LINK_LIBRARIES) - target_link_libraries(${TARGET_NAME} INTERFACE ${ARG_LINK_LIBRARIES}) - if(${CMAKE_VERSION} VERSION_GREATER "3.15.0") - foreach(__lib ${ARG_LINK_LIBRARIES}) - if(TARGET ${__lib}) + foreach(__lib ${ARG_LINK_LIBRARIES}) + if(TARGET ${__lib}) + if(${CMAKE_VERSION} VERSION_GREATER "3.15.0") + target_link_libraries(${TARGET_NAME} INTERFACE ${__lib}) install( TARGETS ${__lib} EXPORT ${TARGET_NAME}Targets COMPONENT DEV) + else() + get_target_property(__target_type ${__lib} TYPE) + if(__target_type STREQUAL "OBJECT_LIBRARY") + if(TARGET "${__lib}_static") + target_link_libraries(${TARGET_NAME} INTERFACE "${__lib}_static") + elseif(TARGET "${__lib}_shared") + target_link_libraries(${TARGET_NAME} INTERFACE "${__lib}_shared") + endif() + else() + target_link_libraries(${TARGET_NAME} INTERFACE ${__lib}) + endif() endif() - endforeach() - endif() + endif() + endforeach() endif() # Библиотека, состоящая только из заголовочных файлов не требует сборки.