Skip to content

cmake: enable pkg-config to search for Libgcrypt, mbedTLS, wolfSSL - #1420

Closed
vszakats wants to merge 44 commits into
libssh2:masterfrom
vszakats:cmake-enable-pkgconfig
Closed

vszakats wants to merge 44 commits into
libssh2:masterfrom
vszakats:cmake-enable-pkgconfig

Conversation

@vszakats

@vszakats vszakats commented Jul 9, 2024 •

Copy link
Copy Markdown
Member

Also:

  • set MBEDTLS_INCLUDE_DIRS for mbedTLS.
  • stop marking MBEDTLS_LIBRARIES as advanced.
  • sync up the content of the three custom Find* detection modules.
  • formatting in Findwolfssl.cmake.

Closes #1420

@vszakats vszakats added the build label Jul 9, 2024
@vszakats vszakats changed the title cmake: enable pkg-config to search for libgcrypt, mbedTLS, wolfSSL cmake: enable pkg-config to search for Libgcrypt, mbedTLS, wolfSSL Jul 9, 2024
@vszakats

vszakats commented Jul 9, 2024 •

Copy link
Copy Markdown
Member Author

Not a clear win. pkg-config finds stuff that's not actually useful:

@vszakats
vszakats force-pushed the cmake-enable-pkgconfig branch from 1b334ba to 404e4a5 Compare July 9, 2024 23:39
@vszakats
vszakats marked this pull request as draft July 10, 2024 00:21
@vszakats
vszakats marked this pull request as ready for review July 10, 2024 08:53
@vszakats
vszakats force-pushed the cmake-enable-pkgconfig branch from 0ba19a8 to 5c7dff3 Compare July 13, 2024 07:57
@vszakats
vszakats force-pushed the cmake-enable-pkgconfig branch from 6614f3b to 8d1933a Compare July 30, 2024 13:21
@vszakats
vszakats marked this pull request as draft July 30, 2024 23:09
@vszakats

Copy link
Copy Markdown
Member Author

It's complicated:

The common CMake pattern is to use pkg-config input as a path hint for CMake's native dependency lookup functions. This works for simple cases, but breaks when the .pc file contains extra/irregular stuff necessary for the dependency. Such case is Libgcrypt which has public headers depending on a header (gpg-error.h) from another project.

To better use pkg-config info, we'd need to use its output directly, instead of just using it as a path hint.

To do this we must decide if we want to check pkg-config first, or use it as a fallback.

Using it first most likely breaks manual configuration via -DMBEDTLS_INCLUDE_DIR= / -DMBEDCRYPTO_LIBRARY= (and similar) settings, because the detection will pick up any pkg-config hits first and never use the manual settings. (Unless force-disabling pkg-config at the same time)

Using it second bumps into a bunch of other issues that I haven't figured out yet.

All these methods steer the logic away from the "common" way, which might potentially cause more harm than good. Unless understanding all the possible angles in advance.

An extra complication is pkg-configs simplistic behaviour in cross-builds. Should we detect the problematic cases and skip using it automatically? Should we not? If we should, what would be the logic to detect the problematic (cross-build) cases?

@vszakats vszakats closed this Aug 3, 2024
@vszakats
vszakats deleted the cmake-enable-pkgconfig branch August 3, 2024 18:36
vszakats added a commit that referenced this pull request Oct 5, 2024
- sync code between Find modules.
- wolfssl: replace `pkg-config` hints with native detection.
- libgcrypt, mbedtls: add `pkg-config`-based native detection.
- libgcrypt: add version detection.
- limit `pkg-config` use for `UNIX`, vcpkg, and non-cross MinGW builds,
  and builds with no manual customization via `*_INCLUDE_DIR` or
  `*_LIBRARY`.
- replace and sync Find module header comments.
- ci: delete manual mbedTLS config that's now redundant.

Based on similar work done in curl.

Second attempt at #1420
Closes #1445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant