aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-01-12 16:52:31 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-01-15 10:39:30 +0000
commit11dbdfc351d70f556790d6ff5b5eac488b8eca0c (patch)
tree304117fc8a96f80c702b950b6b37d1dadcdbf32e /sources/shiboken2/CMakeLists.txt
parent73594da7ba14a5847e14ab871adb5b9ffe3d10dd (diff)
Do not link shared libraries against the python shared library on Unix
There is no need to link against the python shared library (or static library) on Linux / macOS because the python symbols will already be loaded by the dynamic linker, by the time when a PySide2 module is imported. This is especially relevant on Debian distributions, which ship a statically built python interpreter, as well as a python shared library (which is not used by the interpreter). The python shared library package is intended for native application that want to embed a Python interpreter inside the application. So far PySide2 would have linked against the python shared library, which means that on Debian distributions when running a PySide2 example, the executable would load two versions of the same python symbols (one from the static interpreter, and one from the shared library), and this might cause issues. On Windows we still need to link against the python.lib import library, because otherwise the python symbols would not be resolved. Task-number: PYSIDE-522 Change-Id: I4483ded96461c04f8e7a17d39068d07f772a973c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/CMakeLists.txt')
-rw-r--r--sources/shiboken2/CMakeLists.txt14
1 files changed, 12 insertions, 2 deletions
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
index 424142699..be3187591 100644
--- a/sources/shiboken2/CMakeLists.txt
+++ b/sources/shiboken2/CMakeLists.txt
@@ -199,6 +199,12 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(SHIBOKEN_BUILD_TYPE "Release")
+
+# We do not want to link against the python shared / static library on Linux And macOS.
+# The dynamic linker will pick up the python symbols at runtime automatically.
+# On Windows we do need to link against the python.lib import library.
+
+set(SBK_PYTHON_LIBRARIES "")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(NOT PYTHON_DEBUG_LIBRARIES)
message(WARNING "Python debug shared library not found; assuming python was built with shared library support disabled.")
@@ -218,10 +224,14 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SBK_PKG_CONFIG_PY_DEBUG_DEFINITION "${SBK_PKG_CONFIG_PY_DEBUG_DEFINITION} -DCOUNT_ALLOCS")
endif()
- set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES})
+ if(WIN32)
+ set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES})
+ endif()
set(SHIBOKEN_BUILD_TYPE "Debug")
else()
- set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
+ if(WIN32)
+ set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES})
+ endif()
add_definitions("-DNDEBUG")
endif()