From f8942f36d09758e408605758db13180de9d0db24 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 13 Nov 2024 15:36:20 +0100 Subject: [PATCH] Fix compilation of downstream bindings that include yarp.i --- bindings/CMakeLists.txt | 10 ++++++++++ bindings/yarp.i | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 896dc1fd64..78f4932d00 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -155,6 +155,16 @@ mark_as_advanced(SWIG_EXTRA_FLAGS) if(YARP_COMPILE_BINDINGS) unset(SWIG_COMMON_FLAGS) + ############################################################################# + ## Pass a macro to permit to code in yarp.i to distinguish between when is + ## swig is processing yarp.i because it is generated yarp bindings, or if + ## it is processing yarp.i as it was included in some downstream bindings + ## (such as icub-main bindings) + ## If you mantain a project downstream of YARP that is including yarp.i, + ## make sure that you DO NOT define this macro + list(APPEND SWIG_COMMON_FLAGS "-DSWIG_GENERATING_YARP_BINDINGS") + + ############################################################################# ## Do not build deprecated functions when disabled diff --git a/bindings/yarp.i b/bindings/yarp.i index 5f834d2451..1de8af2e34 100644 --- a/bindings/yarp.i +++ b/bindings/yarp.i @@ -2005,10 +2005,11 @@ public: } ////////////////////////////////////////////////////////////////////////// -// Just in Python add some code to automatically call +// Just in Python (and in yarp bindings itself, not in downstream bindings +// that include yarp.i) add some code to automatically call // add_dll_directory as necessary // See https://github.com/robotology/robotology-superbuild/issues/1268 // for more details -#ifdef SWIGPYTHON +#if defined(SWIGPYTHON) && defined(SWIG_GENERATING_YARP_BINDINGS) %include #endif