From 9333a7adfa7abf2a2310b7b259ea797a3be0f7bf Mon Sep 17 00:00:00 2001 From: Andrei Astafev Date: Mon, 11 Mar 2024 17:26:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81?= =?UTF-8?q?=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9=20=D0=B2=20=D1=81=D1=82=D0=B0=D1=80=D1=8B?= =?UTF-8?q?=D1=85=20CMake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyxCMake/lib/AddInterfaceLibrary.cmake | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) 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() # Библиотека, состоящая только из заголовочных файлов не требует сборки.