From 7ec0f9c9a597a54dd1f200509a2c4811c8f22181 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sun, 25 Sep 2022 16:39:42 +0200 Subject: [PATCH] Fix swig-python compatibility --- ports/ogre/portfile.cmake | 1 + ports/ogre/swig-python-polyfill.patch | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 ports/ogre/swig-python-polyfill.patch diff --git a/ports/ogre/portfile.cmake b/ports/ogre/portfile.cmake index 44c99063809bec..a3855afe68a226 100644 --- a/ports/ogre/portfile.cmake +++ b/ports/ogre/portfile.cmake @@ -15,6 +15,7 @@ vcpkg_from_github( PATCHES fix-dependencies.patch disable-dependency-qt.patch + swig-python-polyfill.patch fix-cmake-feature-summary.patch ) diff --git a/ports/ogre/swig-python-polyfill.patch b/ports/ogre/swig-python-polyfill.patch new file mode 100644 index 00000000000000..31bb01b64603ba --- /dev/null +++ b/ports/ogre/swig-python-polyfill.patch @@ -0,0 +1,19 @@ +diff --git a/Components/Python/CMakeLists.txt b/Components/Python/CMakeLists.txt +index b6062c6..df955e3 100644 +--- a/Components/Python/CMakeLists.txt ++++ b/Components/Python/CMakeLists.txt +@@ -22,7 +22,14 @@ if(OGRE_BUILD_COMPONENT_OVERLAY_IMGUI) + list(APPEND CMAKE_SWIG_FLAGS -DHAVE_IMGUI -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS) + endif() + ++# cf. https://github.com/swig/swig/pull/1587 ++file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pyobject_gc_polyfill.h" CONTENT [[ ++#define _PyObject_GC_UNTRACK(x) PyObject_GC_UnTrack(x) ++]]) + macro(ogre_python_module target) ++ if(SWIG_FOUND AND SWIG_VERSION VERSION_LESS "4.0.1" AND Python3_VERSION VERSION_GREATER_EQUAL "3.8") ++ target_precompile_headers(${SWIG_MODULE_${target}_REAL_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/pyobject_gc_polyfill.h") ++ endif() + set_target_properties(${SWIG_MODULE_${target}_REAL_NAME} PROPERTIES + DEBUG_POSTFIX "") + install(TARGETS ${SWIG_MODULE_${target}_REAL_NAME} LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES})