Fix build with SWIG 4.4

SWIG 4.4 has dropped the usage of SWIG_NULLPTR again, which means we can't
rely on its presence to identify SWIG >= 4.2.0

Generate a swig_version.h by parsing the output of `swig -version` and
writing this in a hex representation

Fixes #1979
This commit is contained in:
Dominique Leuenberger
2025-12-02 11:10:27 +01:00
committed by Alexey Sokolov
parent 18416d7df6
commit 49af1c8d53
3 changed files with 71 additions and 8 deletions
+14 -3
View File
@@ -29,6 +29,17 @@ if(APPLE)
endif()
if(SWIG_FOUND)
set(SWIG_VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/swig_version.h")
add_custom_command(
OUTPUT "${SWIG_VERSION_HEADER}"
COMMAND ${CMAKE_COMMAND}
-DSWIG_EXECUTABLE=${SWIG_EXECUTABLE}
-DSWIG_VERSION_HEADER=${SWIG_VERSION_HEADER}
-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_swig_version.cmake"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generate_swig_version.cmake"
)
add_custom_command(
OUTPUT "pyfunctions.cpp"
COMMAND "${PERL_EXECUTABLE}"
@@ -36,7 +47,7 @@ if(SWIG_FOUND)
"${CMAKE_CURRENT_SOURCE_DIR}/functions.in"
"pyfunctions.cpp"
VERBATIM
DEPENDS codegen.pl functions.in)
DEPENDS codegen.pl functions.in "${SWIG_VERSION_HEADER}")
add_custom_command(
OUTPUT "swigpyrun.h"
@@ -98,7 +109,7 @@ endfunction()
add_custom_target(modpython_dist
COMMAND "${CMAKE_COMMAND}" -E tar cz
"${CMAKE_CURRENT_SOURCE_DIR}/generated.tar.gz"
"swigpyrun.h" "znc_core.py" "modpython_biglib.cpp" "pyfunctions.cpp"
DEPENDS swigpyrun.h znc_core.py modpython_biglib.cpp pyfunctions.cpp
"swigpyrun.h" "znc_core.py" "modpython_biglib.cpp" "pyfunctions.cpp" "${SWIG_VERSION_HEADER}"
DEPENDS swigpyrun.h znc_core.py modpython_biglib.cpp pyfunctions.cpp "${SWIG_VERSION_HEADER}"
VERBATIM)
add_dependencies(modpython_dist copy_csocket_h)