Заглушка для CMake < 3.13

This commit is contained in:
Andrei Astafev 2024-03-12 16:23:02 +03:00
parent cbaf609100
commit 2077833259

View File

@ -60,8 +60,12 @@ function(myx_add_interface_library TARGET_NAME)
foreach(__lib ${ARG_LINK_LIBRARIES}) foreach(__lib ${ARG_LINK_LIBRARIES})
if(TARGET ${__lib}) if(TARGET ${__lib})
set(__exlib ${__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) get_target_property(__target_type ${__lib} TYPE)
else()
if(__target_type STREQUAL "OBJECT_LIBRARY") if(__target_type STREQUAL "OBJECT_LIBRARY")
if(TARGET "${__lib}_static") if(TARGET "${__lib}_static")
set(__exlib "${__lib}_static") set(__exlib "${__lib}_static")
@ -69,10 +73,6 @@ function(myx_add_interface_library TARGET_NAME)
set(__exlib "${__lib}_shared") set(__exlib "${__lib}_shared")
endif() endif()
endif() endif()
else()
install(TARGETS ${__lib}
EXPORT ${TARGET_NAME}Targets
COMPONENT DEV)
endif() endif()
target_link_libraries(${TARGET_NAME} INTERFACE ${__exlib}) target_link_libraries(${TARGET_NAME} INTERFACE ${__exlib})
endif() endif()
@ -116,9 +116,12 @@ function(myx_add_interface_library TARGET_NAME)
NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO
) )
install(EXPORT ${TARGET_NAME}Targets if(${CMAKE_VERSION} VERSION_GREATER "3.13.0")
install(
EXPORT ${TARGET_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
COMPONENT DEV) COMPONENT DEV)
endif()
install( install(
FILES FILES
@ -148,10 +151,12 @@ function(myx_add_interface_library TARGET_NAME)
# Установка библиотеки из заголовочных файлов # Установка библиотеки из заголовочных файлов
target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
if(${CMAKE_VERSION} VERSION_GREATER "3.13.0")
install( install(
TARGETS ${TARGET_NAME} TARGETS ${TARGET_NAME}
EXPORT ${TARGET_NAME}Targets EXPORT ${TARGET_NAME}Targets
COMPONENT DEV) COMPONENT DEV)
endif()
# Установка публичных заголовочных файлов # Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS) if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS)