diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-06-25 18:02:52 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-06-29 17:34:22 +0200 |
commit | f3c7d22dd04afe8d889585fb5d6426f3d4591e74 (patch) | |
tree | 68cfb3c9a36d7873304ec6d9947129ef36131128 /cmake/QtPostProcess.cmake | |
parent | 45c0f45e04f4c8431c2744dd52d334ee2e127019 (diff) |
CMake: Don't use libraries in /usr/local by default on macOS
qmake builds of Qt don't use libraries in /usr/local because the
path is not considered a system path. Only the SDK path should be
used as a source of system libraries.
We should do the same for the CMake builds, which involves a couple of
things.
Tell CMake not to consider /usr/local (and a bunch of other
paths) as system prefix paths.
Disable pkg-config usage which by default is not used in qmake
Windows and macOS builds.
If a user wishes to use libraries located in /usr/local on macOS, they
can explicitly enable the behavior via -DFEATURE_pkg_config=ON.
In addition to enabling pkg-config, that will also disable the system
prefix modification described above.
Implementation notes
To disable pkg-config usage, we set an empty path for
PKG_CONFIG_EXECUTABLE, because there is no other good way. The
downside to this is that a lot of warning messages will be printed
that the pkg-config package can not be found.
The pkg-config feature needs to be computed in QtBuildInternals before
qtbase/src/configure.cmake, because it's too late to do it in that
file where a few qt_find_package calls already exist.
The feature value is also saved to QtBuildInternalsExtra, to make sure
that pkg-config is disabled whenever building another repo.
System prefix adjustment is done by removing paths from
CMAKE_SYSTEM_PREFIX_PATH.
Ideally we would remove also /usr as a path, to match what qmake does,
but that breaks find_program() calls for perl, python, etc.
We have to make sure that qt_find_package does not look in
PATH when looking for packages, which is the default behavior, because
PATH on macOS most likely contains /usr/local.
One last curiosity for future generations is that CMake 3.18+ has
merged a change to prioritise SDK locations over regular /usr/lib.
Fixes: QTBUG-85261
Change-Id: I28fe5bae7997507a83b37b4eb1e0188e64062c57
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'cmake/QtPostProcess.cmake')
-rw-r--r-- | cmake/QtPostProcess.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index c6b0dc42e2..a7b56d2e26 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -444,6 +444,14 @@ endif()\n") "set(QT_EXTRA_RPATHS \"${QT_EXTRA_RPATHS}\" CACHE STRING \"\")\n") endif() + # Save pkg-config feature value to be able to query it internally as soon as BuildInternals + # package is loaded. This is to avoid any pkg-config package from being found when + # find_package(Qt6Core) is called in case if the feature was disabled. + string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS " +if(NOT QT_SKIP_BUILD_INTERNALS_PKG_CONFIG_FEATURE) + set(FEATURE_pkg_config \"${FEATURE_pkg_config}\" CACHE STRING \"Using pkg-config\" FORCE) +endif()\n") + # The OpenSSL root dir needs to be saved so that repos other than qtbase (like qtopcua) can # still successfully find_package(WrapOpenSSL) in the CI. # qmake saves any additional include paths passed via the configure like '-I/foo' |