Skip to content

cmake: add HIDE_SYMBOLS option & do symbol hiding on *nix - #939

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:cmake-hidden-symbols
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:cmake-hidden-symbols

Conversation

@vszakats

@vszakats vszakats commented Apr 9, 2023 •

Copy link
Copy Markdown
Member

Closes #939

@vszakats
vszakats force-pushed the cmake-hidden-symbols branch from b6d99f7 to c4334de Compare April 9, 2023 09:01
@vszakats vszakats changed the title cmake: add HIDE_SYMBOLS option & fix symbol hiding on *nix cmake: add HIDE_SYMBOLS option & fix symbol hiding on *nix Apr 9, 2023
@vszakats vszakats changed the title cmake: add HIDE_SYMBOLS option & fix symbol hiding on *nix cmake: add HIDE_SYMBOLS option & do symbol hiding on *nix Apr 9, 2023
- implement symbol hiding on non-Windows platforms.

  The essence of the detection logic was copied from:
  https://github.com/curl/curl/blob/dfabe8bca218d2524af052bd551aa87e13b8a10b/CMake/CurlSymbolHiding.cmake

  Then simplified and shortened. This method doesn't require a recent
  CMake version, nor an external, auto-generated C header.

  Move `configure_file()` after `set(LIBSSH2_API ...)`, for the config
  file to pick up `LIBSSH2_API`s value.

  Closes libssh2#602

- add CMake option `HIDE_SYMBOLS`.

  This setting means to hide non-public functions from the libssh2
  dynamic library when set to `ON`. The default.

  When set to `OFF`, make all non-static/internal functions visible
  in the dynamic library.

  This setting requires `BUILD_SHARED_LIBS=ON`.

- honor this setting on Windows.

  By setting the `LIBSSH2_EXPORTS` manual macro again, and stop
  recognizing the automatic CMake macro for this purpose:
  `libssh2_shared_EXPORT`.

Closes libssh2#939

only with shared libs enabled
@vszakats
vszakats force-pushed the cmake-hidden-symbols branch from c4334de to 4b7d6c9 Compare April 9, 2023 09:03
@vszakats vszakats closed this in 8017592 Apr 9, 2023
@vszakats
vszakats deleted the cmake-hidden-symbols branch April 9, 2023 10:14
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
- implement symbol hiding on non-Windows platforms.

  The essence of the detection logic was copied from:
  https://github.com/curl/curl/blob/dfabe8bca218d2524af052bd551aa87e13b8a10b/CMake/CurlSymbolHiding.cmake

  Then simplified and shortened. This method doesn't require a recent
  CMake version, nor an external, auto-generated C header.

  Move `configure_file()` after `set(LIBSSH2_API ...)`, for the config
  file to pick up `LIBSSH2_API`s value.

  Closes libssh2#602

- add CMake option `HIDE_SYMBOLS`.

  This setting means to hide non-public functions from the libssh2
  dynamic library when set to `ON`. The default.

  When set to `OFF`, make all non-static/internal functions visible
  in the dynamic library.

  This setting requires `BUILD_SHARED_LIBS=ON`.

- honor this setting on Windows.

  By setting the `LIBSSH2_EXPORTS` manual macro again, and stop
  recognizing the automatic CMake macro for this purpose:
  `libssh2_shared_EXPORT`.

Closes libssh2#939
vszakats added a commit that referenced this pull request Sep 29, 2025
- prefer `set_property()` over `target_compile_options()`, to use
  the modern style.

  Follow-up to 8017592 #939

- prefer to append to compiler/linker options in examples/tests.
  To prevent accidentally overriding a previously set option.

  Follow-up to 14a709a #1686
  Follow-up to 854cfa8 #1524

- replace `LINK_FLAGS` with `LINK_OPTIONS` that superceded it, for
  CMake 3.13+.

  Follow-up to 854cfa8 #1524
  https://cmake.org/cmake/help/v4.1/prop_tgt/LINK_OPTIONS.html

Closes #1690
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant