sword/sword-1.8.1-swig.diff
Gregory Hellings dab06ef8dc Fix Fedora 29+ builds & Python3
Patch for building against ICU 61+
Patch for building Python bindings in 2/3
Add python3 package
2018-07-11 23:52:51 -05:00

155 lines
5.5 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d3a2d2..f627850 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -293,9 +293,10 @@ INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake")
# Bindings are good, right?
#
-IF(NOT SWORD_BINDINGS STREQUAL "" AND SWORD_BINDINGS)
+MESSAGE(STATUS "${SWORD_SWIG_BINDINGS}")
+IF(SWORD_SWIG_BINDINGS)
ADD_SUBDIRECTORY("${CMAKE_CURRENT_SOURCE_DIR}/bindings")
-ENDIF(NOT SWORD_BINDINGS STREQUAL "" AND SWORD_BINDINGS)
+ENDIF(SWORD_SWIG_BINDINGS)
##############################################################################################
# Utilities are hawt
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index 9caf6d6..729b499 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -1,5 +1,3 @@
-IF(SWORD_BINDINGS MATCHES ".*Python.*"
- OR SWORD_BINDINGS MATCHES ".*Perl.*")
+IF(SWORD_SWIG_BINDINGS)
ADD_SUBDIRECTORY("${CMAKE_CURRENT_SOURCE_DIR}/swig")
-ENDIF(SWORD_BINDINGS MATCHES ".*Python.*"
- OR SWORD_BINDINGS MATCHES ".*Perl.*")
+ENDIF(SWORD_SWIG_BINDINGS)
diff --git a/bindings/swig/CMakeLists.txt b/bindings/swig/CMakeLists.txt
index d2f4b16..93d55f1 100644
--- a/bindings/swig/CMakeLists.txt
+++ b/bindings/swig/CMakeLists.txt
@@ -15,27 +15,33 @@ IF(NOT SWIG_FOUND)
MESSAGE(FATAL_ERROR "Swig: no")
ELSE(NOT SWIG_FOUND)
MESSAGE(STATUS "Swig: yes")
-
+
SET(CMAKE_SWIG_FLAGS "-w-451,-402;-shadow;-c++")
-
+
MACRO(SWORD_SWIG_GENERATE LANG)
- ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx
+ ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx"
COMMAND ${SWIG_EXECUTABLE} ${CMAKE_SWIG_FLAGS} -${LANG} -o "${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx"
"-I${CMAKE_SOURCE_DIR}/bindings/swig" ${SWIG_INCLUDES} "${CMAKE_SOURCE_DIR}/bindings/swig/sword.i"
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
ENDMACRO(SWORD_SWIG_GENERATE)
-
+
GET_DIRECTORY_PROPERTY(cmake_include_directories INCLUDE_DIRECTORIES)
SET(SWIG_INCLUDES)
FOREACH(directory ${cmake_include_directories})
SET(SWIG_INCLUDES ${SWIG_INCLUDES} "-I${directory}")
ENDFOREACH(directory ${cmake_include_directories})
-
- IF(SWORD_BINDINGS MATCHES ".*Python.*")
- ADD_SUBDIRECTORY(python)
- ENDIF(SWORD_BINDINGS MATCHES ".*Python.*")
-
- IF(SWORD_BINDINGS MATCHES ".*Perl.*")
+
+ IF(SWORD_PYTHON_2)
+ SET(SWORD_PYTHON_VERSION 2)
+ ADD_SUBDIRECTORY(python python2)
+ ENDIF(SWORD_PYTHON_2)
+
+ IF(SWORD_PYTHON_3)
+ SET(SWORD_PYTHON_VERSION 3)
+ ADD_SUBDIRECTORY(python python3)
+ ENDIF(SWORD_PYTHON_3)
+
+ IF(SWORD_PERL)
ADD_SUBDIRECTORY(perl)
- ENDIF(SWORD_BINDINGS MATCHES ".*Perl.*")
+ ENDIF(SWORD_PERL)
ENDIF(NOT SWIG_FOUND)
diff --git a/bindings/swig/python/CMakeLists.txt b/bindings/swig/python/CMakeLists.txt
index bbf7561..eced324 100644
--- a/bindings/swig/python/CMakeLists.txt
+++ b/bindings/swig/python/CMakeLists.txt
@@ -11,6 +11,11 @@
#
#SWIG_LINK_LIBRARIES(Sword ${PYTHON_LIBRARIES} ${SWORD_LINK_NAME})
+UNSET(PYTHON_EXECUTABLE CACHE)
+UNSET(PYTHON_LIBS CACHE)
+SET(PythonInterp_FIND_VERSION "${SWORD_PYTHON_VERSION}")
+SET(PythonInterp_FIND_VERSION_MAJOR "${SWORD_PYTHON_VERSION}")
+SET(PythonLibs_FIND_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibs)
@@ -38,10 +43,10 @@ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/setup.py "${PY_SCRIPT}")
SWORD_SWIG_GENERATE(python)
-ADD_CUSTOM_TARGET(swordswig ALL
- COMMAND python setup.py build
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx ${SWORD_LINK_NAME}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ADD_CUSTOM_TARGET(swordswig_python${SWORD_PYTHON_VERSION} ALL
+ COMMAND "${PYTHON_EXECUTABLE}" setup.py build
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx" ${SWORD_LINK_NAME}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# Allow user installation to custom directory
IF(NOT SWORD_PYTHON_INSTALL_DIR STREQUAL "")
diff --git a/bindings/swig/python/install.cmake.in b/bindings/swig/python/install.cmake.in
index 5dbd52e..9b7da58 100644
--- a/bindings/swig/python/install.cmake.in
+++ b/bindings/swig/python/install.cmake.in
@@ -1,4 +1,4 @@
EXECUTE_PROCESS(COMMAND
- python setup.py install @SETUP_ARGS@
+ "@PYTHON_EXECUTABLE@" setup.py install @SETUP_ARGS@
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 19b7004..b20370e 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -46,6 +46,12 @@ _SET_FANCY(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" "Directory to in
_SET_FANCY(SWORD_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" STRING "Directory where the Python bindings will be installed. Defaults to default Python path.")
+_SET_FANCY(SWORD_PYTHON_2 FALSE STRING "Set to TRUE to build Swig Python bindings for Python 2")
+
+_SET_FANCY(SWORD_PYTHON_3 FALSE STRING "Set to TRUE to build Swig Python bindings for Python 3")
+
+_SET_FANCY(SWORD_PERL FALSE STRING "Set to TRUE to build Swig Perl bindings")
+
# Post-processing of variables
MACRO(PROCESS_VERSION LEVEL VALUE)
SET(SWORD_VERSION_${LEVEL} ${VALUE})
@@ -74,3 +80,16 @@ SET(SWORD_VERSION_STR "${SWORD_VERSION}")
SET(SWORD_VERSION_NUM "${SWORD_VERSION_MAJOR}${MINOR}${MICRO}${NANO}")
MESSAGE(STATUS "SWORD Version ${SWORD_VERSION_NUM}")
+
+IF(SWORD_PYTHON_2 OR SWORD_PYTHON_3 OR SWORD_PERL)
+ MESSAGE(STATUS "Building SWIG Bindings")
+ SET(SWORD_SWIG_BINDINGS 1)
+ELSE()
+ SET(SWORD_SWIG_BINDINGS 0)
+ENDIF()
+
+IF(SWORD_SWIG_BINDINGS)
+ SET(SWORD_BINDINGS TRUE)
+ELSE()
+ SET(SWORD_BINDINGS FALSE)
+ENDIF()