← Back to team overview

hugin-devs team mailing list archive

[Bug 801869] Re: swig test needs to check version

 

can you try with something along the following please?  sorry I do not
have time right now to do it myself.

OPTION(BUILD_HSI "Python Scripting Interface" OFF)
IF(BUILD_HSI)

  # find Python first because the version of SWIG required depends on
the version of Python available

  FIND_PACKAGE(PythonLibs REQUIRED)
  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
  ADD_DEFINITIONS(-DHUGIN_HSI)

  # get version of Python libs

  FILE(STRINGS "${PYTHON_INCLUDE_DIRS}/patchlevel.h"
      PY_DEF_MAJOR
      REGEX "#define[ \t]+PY_MAJOR_VERSION.*$")

  FILE(STRINGS "${PYTHON_INCLUDE_DIRS}/patchlevel.h"
      PY_DEF_MINOR
      REGEX "#define[ \t]+PY_MINOR_VERSION.*$")

  FILE(STRINGS "${PYTHON_INCLUDE_DIRS}/patchlevel.h"
      PY_DEF_MICRO
      REGEX "#define[ \t]+PY_MICRO_VERSION.*$")

  STRING(REGEX
        REPLACE "^.*VERSION[ \t]+([0-9]+).*" "\\1"
        PYTHON_VERSION_MAJOR
        "${PY_DEF_MAJOR}")

  STRING(REGEX
        REPLACE "^.*VERSION[ \t]+([0-9]+).*" "\\1"
        PYTHON_VERSION_MINOR
        "${PY_DEF_MINOR}")

  STRING(REGEX
        REPLACE "^.*VERSION[ \t]+([0-9]+).*" "\\1"
        PYTHON_VERSION_PATCH
        "${PY_DEF_MICRO}")

  # now we can find the right SWIG version
  FIND_PROGRAM(SWIG_EXECUTABLE NAMES swig2.0 swig)
  # unclean to test for Python 3, but the assumption is that by the time we have Python 4 this issue is long gone
  IF(${PYTHON_VERSION_MAJOR}==3)&&(${PYTHON_VERSION_MINOR}>=2))
    FIND_PACKAGE(SWIG 2.0.4 REQUIRED)
  ELSE()
    FIND_PACKAGE(SWIG 2.0 REQUIRED)
  ENDIF()
  INCLUDE(${SWIG_USE_FILE})

ENDIF()


** Changed in: hugin
       Status: New => Confirmed

** Changed in: hugin
   Importance: Undecided => Critical

** Changed in: hugin
    Milestone: None => 2011.2.0

** Changed in: hugin
       Status: Confirmed => In Progress

-- 
You received this bug notification because you are a member of Hugin
Developers, which is subscribed to Hugin.
https://bugs.launchpad.net/bugs/801869

Title:
  swig test needs to check version

Status in Hugin - Panorama Tools GUI:
  In Progress

Bug description:
  According to 2011.2.0_beta1 README hsi has specific version
  requirements on swig:

          SWIG >=2.0 - If Python >=3.2, SWIG must be >=2.0.4

  However the CMake setup does not do any version checks.

  FindPythonLibs seems to be one of the (imho very broken) cmake modules
  that does return any versioning info, making it impossible to
  completely express the abovementioned dependency without trickery.
  However FindSWIG can do version checks, making part1 (swig >= 2.0)
  easy as pie:

  --- CMakeLists.txt.orig 2011-06-25 09:03:31.000000000 +0200
  +++ CMakeLists.txt      2011-06-25 09:03:54.000000000 +0200
  @@ -295,7 +295,7 @@
   OPTION(BUILD_HSI "Python Scripting Interface" OFF)
   IF(BUILD_HSI)
     find_program(SWIG_EXECUTABLE NAMES swig2.0 swig)
  -  FIND_PACKAGE(SWIG REQUIRED)
  +  FIND_PACKAGE(SWIG 2.0 REQUIRED)
     INCLUDE(${SWIG_USE_FILE})

     FIND_PACKAGE(PythonLibs REQUIRED)

To manage notifications about this bug go to:
https://bugs.launchpad.net/hugin/+bug/801869/+subscriptions


Follow ups

References