Skip to content

Commit

Permalink
Fix swig-python compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Sep 25, 2022
1 parent 9239a80 commit 7ec0f9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions ports/ogre/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ vcpkg_from_github(
PATCHES
fix-dependencies.patch
disable-dependency-qt.patch
swig-python-polyfill.patch
fix-cmake-feature-summary.patch
)

Expand Down
19 changes: 19 additions & 0 deletions ports/ogre/swig-python-polyfill.patch
Original file line number Diff line number Diff line change
@@ -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})

0 comments on commit 7ec0f9c

Please sign in to comment.