Skip to content

[suggest] Change the IMPORTED target name to libssh2::libssh2 or Libssh2::Libssh2. #731

Closed

Description

@hwhsu1231

If the IMPORTED target name is provided in form of <pkg>::<pkg>, I think it is better to keep the case of letters <pkg> the SAME, which means libssh2::libssh2 or Libssh2::Libssh2.

For example:

Therefore,

How about that?

Activity

  1. changed the title [-][suggest] Change the IMPORTED target name to `libssh2::libssh2`.[/-] [+][suggest] Change the IMPORTED target name to `libssh2::libssh2` or `Libssh2::Libssh2`.[/+] on Aug 4, 2022
  2. willco007 commented on Nov 3, 2022

    @willco007
    Member

    I'd probably vote for lower case; how does this impact folks using a pre-build library?

  3. jzakrzewski commented on Nov 16, 2022

    @jzakrzewski

    @hwhsu1231 shouldn't the line 406 also be changed to lower case? Also, if upper casing, the output file would probably have to be renamed, otherwise you'll get "Libssh2.so", which would wreak havoc.

    @willco007 the changes will only impact CMake users that previously used "Libssh2::libssh2" imported target.

  4. willco007 commented on Nov 16, 2022

    @willco007
    Member

    @bagder What do you think about this change?

  5. hwhsu1231 commented on Jan 10, 2023

    @hwhsu1231
    Author

    @jzakrzewski

    shouldn't the line 406 also be changed to lower case? Also, if upper casing, the output file would probably have to be renamed, otherwise you'll get "Libssh2.so", which would wreak havoc.

    Yes, I think so if the schema 1 is adopted.

    the changes will only impact CMake users that previously used "Libssh2::libssh2" imported target.

    How about prepare the old target and the new one simultaneously for a while? And then, add some comments in the source code to tell users that the old one will be deprecated in the future?

  6. hwhsu1231 commented on Jan 10, 2023

    @hwhsu1231
    Author

    However, considering the backward compatibility, maybe it's better to keep the current imported target name.

  7. vszakats commented on Mar 23, 2023

    @vszakats
    Member

    Here's a patch proposal for the current master, in case we want to pursue this:

    diff --git a/docs/INSTALL_CMAKE.md b/docs/INSTALL_CMAKE.md
    index fe203068..47ca7318 100644
    --- a/docs/INSTALL_CMAKE.md
    +++ b/docs/INSTALL_CMAKE.md
    @@ -168,8 +168,8 @@ setting it up with libssh2's location.  Just add just the following
     lines and CMake will find libssh2 on your system, set up the necessary
     paths and link the library with your binary.
     
    -    find_package(Libssh2 REQUIRED CONFIG)
    -    target_link_libraries(my_project_target Libssh2::libssh2)
    +    find_package(libssh2 REQUIRED CONFIG)
    +    target_link_libraries(my_project_target libssh2::libssh2)
     
     Of course, you still have to make libssh2 available on your system
     first.  You can install it in the traditional way shown above, but you
    @@ -184,13 +184,13 @@ builds your project:
         include(ExternalProject)
     
         ExternalProject_Add(
    -        Libssh2
    +        libssh2
             URL <libssh2 download location>
             URL_HASH SHA1=<libssh2 archive SHA1>
             INSTALL_COMMAND "")
     
         ExternalProject_Add(
    -        MyProject DEPENDS Libssh2
    +        MyProject DEPENDS libssh2
             SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
             INSTALL_COMMAND "")
     
    diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
    index c35237c8..8ebdad94 100644
    --- a/src/CMakeLists.txt
    +++ b/src/CMakeLists.txt
    @@ -457,13 +457,13 @@ set(RUNTIME_DEPENDENCIES ${_RUNTIME_DEPENDENCIES} CACHE INTERNAL
     
     ## During package installation, install Libssh2Config.cmake
     install(EXPORT Libssh2Config
    -  NAMESPACE Libssh2::
    +  NAMESPACE libssh2::
       DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libssh2)
     
     ## During build, register directly from build tree
     # create Libssh2Config.cmake
    -export(TARGETS ${libssh2_export} NAMESPACE Libssh2:: FILE Libssh2Config.cmake)
    -export(PACKAGE Libssh2) # register it
    +export(TARGETS ${libssh2_export} NAMESPACE libssh2:: FILE Libssh2Config.cmake)
    +export(PACKAGE libssh2)  # register it
     
     ## Export a .pc file for client projects not using CMaek
     if(PC_REQUIRES_PRIVATE)
  8. vszakats commented on Apr 20, 2023

    @vszakats
    Member

    We won't do this now to retain compatibility, but would welcome a patch that would be exporting both names simultaneously, as suggested here.

  9. added 2 commits that reference this issue on Jun 23, 2023
    51045ad
    2da13c1
  10. vszakats commented on Jun 25, 2023

    @vszakats
    Member

    This was implemented in 2da13c1 while also keeping compatibility. ('Restoring' would be more precise as compatibility broke in v1.11.0 due to other changes).

  11. added a commit that references this issue on Jul 16, 2023
    de1160a
  12. added a commit that references this issue on Jul 14, 2024
    5c57002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions