From 2077833259f5e9d9dee1b72d3f86ac3d047e6336 Mon Sep 17 00:00:00 2001 From: Andrei Astafev Date: Tue, 12 Mar 2024 16:23:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BB=D1=83=D1=88=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20CMake=20<=203.13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MyxCMake/lib/AddInterfaceLibrary.cmake | 29 +++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/MyxCMake/lib/AddInterfaceLibrary.cmake b/MyxCMake/lib/AddInterfaceLibrary.cmake index a867446..f8816a5 100644 --- a/MyxCMake/lib/AddInterfaceLibrary.cmake +++ b/MyxCMake/lib/AddInterfaceLibrary.cmake @@ -60,8 +60,12 @@ function(myx_add_interface_library TARGET_NAME) foreach(__lib ${ARG_LINK_LIBRARIES}) if(TARGET ${__lib}) set(__exlib ${__lib}) - if(${CMAKE_VERSION} VERSION_LESS "3.15.0") + if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") + install(TARGETS ${__lib} + EXPORT ${TARGET_NAME}Targets + COMPONENT DEV) get_target_property(__target_type ${__lib} TYPE) + else() if(__target_type STREQUAL "OBJECT_LIBRARY") if(TARGET "${__lib}_static") set(__exlib "${__lib}_static") @@ -69,10 +73,6 @@ function(myx_add_interface_library TARGET_NAME) set(__exlib "${__lib}_shared") endif() endif() - else() - install(TARGETS ${__lib} - EXPORT ${TARGET_NAME}Targets - COMPONENT DEV) endif() target_link_libraries(${TARGET_NAME} INTERFACE ${__exlib}) endif() @@ -116,9 +116,12 @@ function(myx_add_interface_library TARGET_NAME) NO_CHECK_REQUIRED_COMPONENTS_MACRO ) - install(EXPORT ${TARGET_NAME}Targets - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME} - COMPONENT DEV) + if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") + install( + EXPORT ${TARGET_NAME}Targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME} + COMPONENT DEV) + endif() install( FILES @@ -148,10 +151,12 @@ function(myx_add_interface_library TARGET_NAME) # Установка библиотеки из заголовочных файлов target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $) - install( - TARGETS ${TARGET_NAME} - EXPORT ${TARGET_NAME}Targets - COMPONENT DEV) + if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") + install( + TARGETS ${TARGET_NAME} + EXPORT ${TARGET_NAME}Targets + COMPONENT DEV) + endif() # Установка публичных заголовочных файлов if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS)