diff --git a/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in b/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in index b726f35e7af7da5771f3bfffcdcc19ba05b6bcfc..ff3c204aa76e02eedb85f763d3a476f749d3c16c 100644 --- a/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in +++ b/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in @@ -2,7 +2,7 @@ #cmake builds with rpath in the binary dir, so we don't need to set LD_LIBRARY_PATH here #export LD_LIBRARY_PATH=@CMAKE_BINARY_DIR@/lib:$LD_LIBRARY_PATH -export PYTHONPATH=@CMAKE_BINARY_DIR@/lib/otb/python:$PYTHONPATH +export PYTHONPATH=@PYTHONPATH_COOKBOOK@:$PYTHONPATH export OTB_APPLICATION_PATH=@CMAKE_BINARY_DIR@/lib/otb/applications python3 @CMAKE_CURRENT_SOURCE_DIR@/Scripts/otbGenerateWrappersRstDoc.py -o "$1" diff --git a/Documentation/Cookbook/CMakeLists.txt b/Documentation/Cookbook/CMakeLists.txt index 736db217de5d9ab708ce3f9515a76e4934298a14..8974733ed2a4dc385a81698ac09b2f9b5368beeb 100644 --- a/Documentation/Cookbook/CMakeLists.txt +++ b/Documentation/Cookbook/CMakeLists.txt @@ -61,6 +61,19 @@ foreach(cmd endif() endforeach() +# We need to set PYTHONPATH for the script otbGenerateWrappersRstDoc.py, depending on how the Python3 module was built +if (OTB_WRAP_PYTHON3) + set(PYTHONPATH_COOKBOOK "${CMAKE_BINARY_DIR}/lib/otb/python3") +elseif (OTB_WRAP_PYTHON) + # Cookbook only supports Python3 + # But OTB_WRAP_PYTHON can wrap both python2 and python3 + if (${PYTHONLIBS_VERSION_STRING} STRGREATER "3.0.0") + set(PYTHONPATH_COOKBOOK "${CMAKE_BINARY_DIR}/lib/otb/python") + else() + message(ERROR "Must wrap OTB with python lib 3+ to build the cookbook, but found version ${PYTHONLIBS_VERSION_STRING}") + endif() +endif() + set(RST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rst) set(RST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/rst) set(LATEX_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex) @@ -71,6 +84,7 @@ message(STATUS "RST_SOURCE_DIR = ${RST_SOURCE_DIR}") message(STATUS "RST_BINARY_DIR = ${RST_BINARY_DIR}") message(STATUS "LATEX_DIR = ${LATEX_DIR}") message(STATUS "HTML_DIR = ${HTML_DIR}") +message(STATUS "PYTHONPATH_COOKBOOK = ${PYTHONPATH_COOKBOOK}") # Clean any existing build macro(remove_and_make_directories) @@ -106,14 +120,6 @@ set(OTB_COPYRIGHT_TEXT "${OTB_COPYRIGHT_YEAR} CNES.The OTB CookBook is licensed configure_file(${RST_SOURCE_DIR}/conf.py.in ${SPHINX_CONF_DIR}/conf.py @ONLY) -#configure_file(${RST_SOURCE_DIR}/Makefile.in ${RST_GENERATED_SOURCE_DIR}/Makefile.sphinx @ONLY) -# Internal variables. -# PAPEROPT_a4 = -D latex_paper_size=a4 -# PAPEROPT_letter = -D latex_paper_size=letter -# ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# # the i18n builder cannot share the environment and doctrees with the others -# I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - add_custom_target(generate_otbapps_rst COMMAND ${SH_INTERP} ${CMAKE_CURRENT_BINARY_DIR}/RunApplicationsRstGenerator.sh ${RST_BINARY_DIR}