Skip to content

cmake: allow pkg-config in more envs - #14483

Closed
vszakats wants to merge 4 commits into
curl:masterfrom
vszakats:cm-pkg-config-non-unix
Closed

vszakats wants to merge 4 commits into
curl:masterfrom
vszakats:cm-pkg-config-non-unix

Conversation

@vszakats

@vszakats vszakats commented Aug 10, 2024 •

Copy link
Copy Markdown
Member

Before this patch, pkg-config was used for UNIX builds only (with
a few exceptions like wolfSSL, libssh, gsasl, libuv). This patch extends
pkg-config use to all envs except: MSVC without vcpkg. Meaning MSVC
with vcpkg will now use it. Also mingw on Windows.

Also apply the new condition to options where pkg-config was used
unconditionally (= for all targets). These are:
-DCURL_USE_WOLFSSL=ON, -DCURL_USE_LIBSSH=ON,
-DCURL_USE_GSASL=ON and -DCURL_USE_LIBUV=ON

This patch may still cause regressions for cross-builds (e.g. mingw
cross-build from Unix) and potentially other cases. If that happens, we
recommend using some of these methods to explicitly disable pkg-config
when using CMake:

  • CMake option: -DPKG_CONFIG_EXECUTABLE=
    (or -DPKG_CONFIG_EXECUTABLE=nonexistent or similar)
    This is similar to the (curl-specific) PKG_CONFIG env for autotools.
  • export env: PKG_CONFIG_LIBDIR=
    (or PKG_CONFIG_PATH, PKG_CONFIG_SYSROOT_DIR,
    or the CMake-specific PKG_CONFIG)

We may improve control over this in a future patch, also allowing opting
in MSVC (without vcpkg).

Ref: #14405
Ref: #14408
Ref: #14140
Closes #14483


  • apply to all other case where if(UNIX) is used.
  • apply to CURL_USE_WOLFSSL, CURL_USE_LIBSSH, CURL_USE_GSASL, CURL_USE_LIBUV.
  • replace this condition with an overridable CURL_USE_PKGCONFIG setting. → cmake: add CURL_USE_PKGCONFIG option #14504
  • add initial pkg-config support for deps which don't have it yet.

Without whitespace: https://github.com/curl/curl/pull/14483/files?w=1

@vszakats
vszakats marked this pull request as draft August 10, 2024 07:36
@talregev

talregev commented Aug 10, 2024 •

Copy link
Copy Markdown
Contributor

Why not msvc?

@vszakats

vszakats commented Aug 10, 2024 •

Copy link
Copy Markdown
Member Author

It is MSVC, but only when combined with vcpkg. In other MSVC cases, pkg-config is reported to break builds: #14405 #14365. Also outside vcpkg, pkg-config means mingw-specific options and libs.

Or, is there any raw/other MSVC env out there that supports pkg-config?

@vszakats
vszakats force-pushed the cm-pkg-config-non-unix branch from 17bc50c to a1b4ab1 Compare August 10, 2024 08:16
@talregev

Copy link
Copy Markdown
Contributor

Or, is there any raw/other MSVC env out there that supports pkg-config?

I don't familiar with more.
Thank you for the detailed answer.

@vszakats
vszakats marked this pull request as ready for review August 12, 2024 12:25
@vszakats vszakats closed this in 9dfdc6f Aug 12, 2024
@vszakats
vszakats deleted the cm-pkg-config-non-unix branch August 12, 2024 12:59
vszakats added a commit to vszakats/curl that referenced this pull request Aug 12, 2024
Add option to control whether to use `pkg-config` to detect
dependencies. Curl's CMake uses `pkg-config` by default for all targets
except for MSVC without vcpkg.

With the CMake option `-DCURL_USE_PKGCONFIG=ON` you can override it to
use `pkg-config` always.

If `pkg-config` is causing issues, e.g. in cross-builds or other cases,
`-DCURL_USE_PKGCONFIG=OFF` disables all use of `pkg-config`.

Follow-up to 9dfdc6f curl#14483
Closes #xxxxx
vszakats added a commit that referenced this pull request Aug 13, 2024
Add option to control whether to use `pkg-config` to detect
dependencies. Curl's CMake uses `pkg-config` by default for all targets
except for MSVC without vcpkg.

With the CMake option `-DCURL_USE_PKGCONFIG=ON` you can override it to
use `pkg-config` always.

If `pkg-config` is causing issues, e.g. in cross-builds or other cases,
`-DCURL_USE_PKGCONFIG=OFF` disables all use of `pkg-config`.

Also add it to `curl-config.cmake`. Not yet used, but will be once curl
starts referencing any curl-specific `Find*` module from this public
script.

Follow-up to 9dfdc6f #14483
Closes #14504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants