Skip to content

Commit

Permalink
cmake: enable shared libssh2 library by default
Browse files Browse the repository at this point in the history
This brings default behaviour in sync with autotools, which builds both
lib flavours by default.

(Notice that on Windows, autotools includes the Windows Resource in the
static library, when building both at the same time. CMake doesn't have
this issue.)

Enabling both lib flavours has a side-effect when using non-MinGW
toolchains (e.g. MSVC): to resolve the filename conflict between import
and static libraries, we add a suffix to the static lib, naming it
`libssh2_static.lib`. This can break dependent builds relying on
`libssh2.lib` for linking the static libssh2.

Workarounds:

- disable either shared or static libssh2 via
  `-DBUILD_STATIC_LIBS=OFF` or
  `-DBUILD_SHARED_LIBS=OFF`. This results in a libssh2 library (either
  static or shared) without a prefix: `libssh2.lib`.

- set a custom static library suffix via:
  `-DSTATIC_LIB_SUFFIX=_my_static`. Resulting in
  `libssh2_my_static.lib`, and import library
  `libssh2.lib`.

- set a custom import library suffix via:
  `-DIMPORT_LIB_SUFFIX=_my_implib`. Resulting in
  `libssh2_my_implib.lib` import library, and static library
  `libssh2.lib`.

- customize the default static/import library suffix (incl. extension)
  via
  `-DCMAKE_STATIC_LIBRARY_SUFFIX=_my_static_suffix.lib` or
  `-DCMAKE_IMPORT_LIBRARY_SUFFIX=_my_import_suffix.lib`.

Cherry-picked from libssh2#1036
  • Loading branch information
vszakats committed May 9, 2023
1 parent 837fa4b commit 896154b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ option(BUILD_STATIC_LIBS "Build Static Libraries" ON)
add_feature_info("Static library" BUILD_STATIC_LIBS
"creating libssh2 static library")

option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
add_feature_info("Shared library" BUILD_SHARED_LIBS
"creating libssh2 shared library (.so/.dll)")

Expand Down

0 comments on commit 896154b

Please sign in to comment.