From 4ff64ae3ca14a04c6914c45c48476a061723a872 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 16 Aug 2023 06:38:22 +0000 Subject: [PATCH] cmake: (re-)add aliases for `add_subdirectory()` builds Add internal libssh2 library aliases to make these available for downstream/dependent projects building libssh2 via `add_subdirectory()`: - `libssh2:libssh2_static` - `libssh2:libssh2_shared` - `libssh2:libssh2` (shared, or static when not building shared) - `libssh2` (shared, or static when not building shared) Of these, `libssh2` was present in v1.10.0 and earlier releases, but missing from v1.11.0. Closes #1169 --- src/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2d3c204..83b26e1c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,6 +106,7 @@ endif() if(BUILD_STATIC_LIBS) list(APPEND libssh2_export ${LIB_STATIC}) add_library(${LIB_STATIC} STATIC ${SOURCES}) + add_library(${PROJECT_NAME}::${LIB_STATIC} ALIAS ${LIB_STATIC}) target_compile_definitions(${LIB_STATIC} PRIVATE ${PRIVATE_COMPILE_DEFINITIONS} ${libssh2_DEFINITIONS}) target_link_libraries(${LIB_STATIC} PRIVATE ${LIBRARIES}) set_target_properties(${LIB_STATIC} PROPERTIES @@ -121,6 +122,7 @@ endif() if(BUILD_SHARED_LIBS) list(APPEND libssh2_export ${LIB_SHARED}) add_library(${LIB_SHARED} SHARED ${SOURCES}) + add_library(${PROJECT_NAME}::${LIB_SHARED} ALIAS ${LIB_SHARED}) if(WIN32) set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "libssh2.rc") endif() @@ -139,6 +141,9 @@ if(BUILD_SHARED_LIBS) $/${CMAKE_INSTALL_INCLUDEDIR}>) endif() +add_library(${PROJECT_NAME}::${LIB_NAME} ALIAS ${LIB_SELECTED}) +add_library(${LIB_NAME} ALIAS ${LIB_SELECTED}) + ## Installation install(FILES