Commit b69514fe authored by Antoine Regimbeau's avatar Antoine Regimbeau

ENH: new workflow for find_package python in OTB

parent eac31490
......@@ -26,7 +26,6 @@
# python is needed to verify the presence of the module name in the doxygen header
# Don't require it to not force the developers to install python to be able to build
# OTB. The tests will simply not be run if python is not available.
find_package(PythonInterp QUIET)
macro( otb_module_doxygen _name )
......
......@@ -26,7 +26,6 @@
# This does not force the developer to install python to be able to build OTB.
# The tests will simply not be run if python is unavailable.
find_package(PythonInterp QUIET)
# The maximum number of headers in a test. This helps limit memory issues,
# and the cppcheck tests. However, if this is not unity, there is a slight
......
......@@ -374,3 +374,25 @@ 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)
message (WARNING "Python3 not found. There is no longer support of python2 \
in OTB, but it can still be used.")
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()
find_package ( Numpy )
endmacro()
......@@ -100,6 +100,12 @@ reset_qt_i18n_sources()
repository_status(${PROJECT_SOURCE_DIR} OTB_GIT_STATUS_MESSAGE)
if ( OTB_WRAP_PYTHON )
find_python( "REQUIERED" )
else()
find_python( "QUIET" )
endif()
#-----------------------------------------------------------------------------
# Configure the default OTB_DATA_ROOT for the location of OTB Data.
find_path(OTB_DATA_ROOT
......@@ -337,6 +343,7 @@ set(OTB_CONFIG_CODE "
set(OTB_MODULES_DIR \"${OTB_MODULES_DIR}\")")
set(OTB_CONFIG_CMAKE_DIR "${OTB_SOURCE_DIR}/CMake")
set(OTB_USE_FILE "${OTB_CONFIG_CMAKE_DIR}/UseOTB.cmake")
if(OTB_WRAP_PYTHON)
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_PYTHONPATH \"${OTB_BINARY_DIR}/${OTB_INSTALL_PYTHON_DIR}\")")
......@@ -364,10 +371,12 @@ set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_MODULES_DIR \"\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/Modules\")")
set(OTB_USE_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/UseOTB.cmake")
set(OTB_CONFIG_CMAKE_DIR "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}")
if(OTB_WRAP_PYTHON)
set(OTB_CONFIG_CODE "${OTB_CONFIG_CODE}
set(OTB_PYTHONPATH \"\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PYTHON_DIR}\")")
endif()
set(OTB_CONFIG_APPLICATION_PATH "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_APP_DIR}")
set(OTB_CONFIG_TARGETS_CONDITION "")
set(OTB_CONFIG_TARGETS_FILE "\${OTB_INSTALL_PREFIX}/${OTB_INSTALL_PACKAGE_DIR}/OTBTargets.cmake")
......
......@@ -40,18 +40,9 @@ macro(check_PIC_flag Language)
endif()
endmacro()
# thi macro should be removed
if ( OTB_WRAP_PYTHON )
check_PIC_flag ( Python )
set (PythonVersion 3)
find_package ( PythonInterp ${PythonVersion} )
if( NOT PythonInterp_FOUND)
message (WARNING "Python3 not found. There is no longer support of python2 \
in OTB, but it can still be used.")
set (PythonVersion 2)
find_package ( PythonInterp ${PythonVersion} REQUIRED)
endif()
find_package ( PythonLibs ${PythonVersion} REQUIRED )
find_package ( Numpy )
endif()
#
......
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