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)