Commit 7eb09607 authored by Antoine Regimbeau's avatar Antoine Regimbeau

ENH: use of Python_ADDITIONAL_VERSIONS

parent 21552344
Pipeline #310 passed with stage
in 27 minutes and 18 seconds
......@@ -374,26 +374,3 @@ macro(otb_module_requires_cxx11)
message(WARNING "otb_module_requires_cxx11 is deprecated since OTB version 6.2 which build with c++14 by default. You can safely remove the call to this macro.")
set(OTB_MODULE_${otb-module}_REQUIRES_CXX11 1)
endmacro()
# This macro helps finding the right python interpreter, library and numpy
macro(find_python CRITICITY)
set( otb_python_major_version 3 )
find_package( PythonInterp ${otb_python_major_version} QUIET )
if( NOT PythonInterp_FOUND )
if ( NOT ${CRITICITY} STREQUAL "QUIET" )
message (WARNING "Python3 not found. There is no longer support of \
wrapping in python2 in OTB, but it can still be used.")
endif()
set (otb_python_major_version 2)
if ( ${CRITICITY} STREQUAL "QUIET")
find_package ( PythonInterp ${otb_python_major_version} QUIET )
else()
find_package ( PythonInterp ${otb_python_major_version} REQUIRED )
endif()
endif()
if ( ${CRITICITY} STREQUAL "QUIET")
find_package ( PythonLibs ${otb_python_major_version} QUIET )
else()
find_package ( PythonLibs ${otb_python_major_version} REQUIRED )
endif()
endmacro()
......@@ -100,10 +100,21 @@ reset_qt_i18n_sources()
repository_status(${PROJECT_SOURCE_DIR} OTB_GIT_STATUS_MESSAGE)
# Find python stuff
# Version 3 is prefered before 2
set (Python_ADDITIONAL_VERSIONS "3;2")
if ( OTB_WRAP_PYTHON )
find_python( "REQUIRED" )
else()
find_python( "QUIET" )
find_package( PythonInterp REQUIRED )
if ( ${PYTHON_VERSION_MAJOR} EQUAL 2 )
message (WARNING "Python3 not found. There is no longer support of \
wrapping in python2 in OTB, but it can still be used.")
endif()
find_package ( PythonLibs ${PYTHON_VERSION_MAJOR} REQUIRED )
else()
# If NOT OTB_WRAP_PYTHON we still need python for testing but it is okay if
# the find package fail
find_package ( PythonInterp QUIET )
find_package ( PythonLibs ${PYTHON_VERSION_MAJOR} QUIET )
endif()
#-----------------------------------------------------------------------------
......
......@@ -109,7 +109,8 @@ if(UNIX)
# For now gdal is built if Superbuild has find python... And only on UNIX
# That might be a problem
if ( OTB_WRAP_PYTHON )
# User will not be able to override this...
if ( OTB_WRAP_PYTHON AND PYTHON_EXECUTABLE)
list(APPEND GDAL_CONFIGURE_COMMAND "--with-python=${PYTHON_EXECUTABLE}")
endif()
......
......@@ -381,25 +381,17 @@ endforeach()
# -PYTHON_INCLUDE_DIR
# -PYTHON_LIBRARY
# -NUMPY_INCLUDE_DIR
set( otb_python_major_version 3 )
find_package( PythonInterp ${otb_python_major_version} QUIET )
if( NOT PythonInterp_FOUND)
if( OTB_WRAP_PYTHON )
set (Python_ADDITIONAL_VERSIONS "3;2")
if ( OTB_WRAP_PYTHON )
find_package( PythonInterp REQUIRED )
if ( ${PYTHON_VERSION_MAJOR} EQUAL 2 )
message (WARNING "Python3 not found. There is no longer support of \
wrapping in python2 in OTB, but it can still be used.")
endif()
set (otb_python_major_version 2)
if ( OTB_WRAP_PYTHON )
find_package ( PythonInterp ${otb_python_major_version} REQUIRED )
else()
find_package ( PythonInterp ${otb_python_major_version} QUIET )
endif()
endif()
if ( OTB_WRAP_PYTHON )
find_package ( PythonLibs ${otb_python_major_version} REQUIRED )
find_package ( PythonLibs ${PYTHON_VERSION_MAJOR} REQUIRED )
else()
find_package ( PythonLibs ${otb_python_major_version} QUIET )
find_package( PythonInterp QUIET )
find_package ( PythonLibs ${PYTHON_VERSION_MAJOR} QUIET )
endif()
include(External_otb)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment