aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-27 17:04:07 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-27 16:36:49 +0000
commitb8699b6361b3658fc90226a239d24e0a602dc4bd (patch)
tree335de749a94364b52cd7ef417878958d5f2f8d66 /sources
parent7de5a61f076e90a7ccd39475f9097c1933f02a56 (diff)
CMake: Don't use pkg-config by default when building for macOS
Certain CMake Find modules use pkg-config to try and find libraries. The libxml2 and libxslt libraries that shiboken needs are provided by both Homebrew and the macOS SDK. Homebrew ships two sets of .pc files for xml and xslt: - one set pointing to the Homebrew libs which are NOT symlinked into /usr/local by default, and are thus not found by default - another set pointing to the Xcode command line tools files which are symlinked into /usr/local by default. Note these point to the command line tools SDK, not the macOS SDK, which is an important distinction. Unfortunately the latter can cause issues when building shiboken, because CMake's find_package() uses FindPkgConfig and the Command Line Tools libxml2.pc file is found. CMake then adds the CLT include paths in addition to the default macOS SDK sysroot include paths and that mix leads to compilation errors. E.g. -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include gets mixed up with -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/ MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk causing errors like /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace By default when targeting macOS, pkg-config should not be used, to ensure 3rd party dependencies are not picked up and mixed with the macOS SDK provided dependencies. This is in-line with the behavior of Qt's CMake build as well. Disable the usage of pkg-config by setting PKG_CONFIG_EXECUTABLE to an empty string by default. Allow to opt into usage of pkg-config by configuring shiboken with the -DSHIBOKEN_SKIP_PKG_CONFIG_ADJUSTMENT=ON option. Change-Id: Iec2acc4026f12a7baac4afb4259aeacd9e3b32b4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit d496ffdac10eaad74af4142510fbf979bab340c2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken6/CMakeLists.txt2
-rw-r--r--sources/shiboken6/data/shiboken_helpers.cmake24
2 files changed, 26 insertions, 0 deletions
diff --git a/sources/shiboken6/CMakeLists.txt b/sources/shiboken6/CMakeLists.txt
index de4b51c09..9eda2af14 100644
--- a/sources/shiboken6/CMakeLists.txt
+++ b/sources/shiboken6/CMakeLists.txt
@@ -18,6 +18,8 @@ option(BUILD_TESTS "Build tests." TRUE)
option(USE_PYTHON_VERSION "Use specific python version to build shiboken6." "")
option(DISABLE_DOCSTRINGS "Disable documentation extraction." FALSE)
+shiboken_internal_disable_pkg_config_if_needed()
+
set (QT_MAJOR_VERSION 6)
message(STATUS "Using Qt ${QT_MAJOR_VERSION}")
find_package(Qt${QT_MAJOR_VERSION} 6.0 REQUIRED COMPONENTS Core)
diff --git a/sources/shiboken6/data/shiboken_helpers.cmake b/sources/shiboken6/data/shiboken_helpers.cmake
index 7e772c7fd..2e4a23867 100644
--- a/sources/shiboken6/data/shiboken_helpers.cmake
+++ b/sources/shiboken6/data/shiboken_helpers.cmake
@@ -363,3 +363,27 @@ Detected: '${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}'")
endif()
endif()
endfunction()
+
+function(shiboken_internal_disable_pkg_config)
+ # Disable pkg-config by setting an empty executable path. There's no documented way to
+ # mark the package as not found, but we can force all pkg_check_modules calls to do nothing
+ # by setting the variable to an empty value.
+ set(PKG_CONFIG_EXECUTABLE "" CACHE STRING "Disabled pkg-config usage." FORCE)
+endfunction()
+
+function(shiboken_internal_disable_pkg_config_if_needed)
+ if(SHIBOKEN_SKIP_PKG_CONFIG_ADJUSTMENT)
+ return()
+ endif()
+
+ # pkg-config should not be used by default on Darwin platforms.
+ if(APPLE)
+ set(pkg_config_enabled OFF)
+ else()
+ set(pkg_config_enabled ON)
+ endif()
+
+ if(NOT pkg_config_enabled)
+ shiboken_internal_disable_pkg_config()
+ endif()
+endfunction()