From 1509a2b43f18a554cda9da909e879db11b1ef0c9 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath <rashad.kanavath@c-s.fr> Date: Tue, 4 Oct 2016 11:39:18 +0200 Subject: [PATCH] BUG: fix make of cookbook from otb build or install directory --- .../RunApplicationsRstGenerator.sh.cmake.in | 2 +- Documentation/Cookbook/CMakeLists.txt | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in b/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in index 1dd8facd8b..d5f17f1f07 100644 --- a/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in +++ b/Documentation/Cookbook/CMake/RunApplicationsRstGenerator.sh.cmake.in @@ -1,6 +1,6 @@ #!/bin/sh export LD_LIBRARY_PATH=@OTB_INSTALL_PREFIX@/lib:$LD_LIBRARY_PATH -export PYTHONPATH=@OTB_INSTALL_PREFIX@/lib:@OTB_INSTALL_PREFIX@/lib/otb/python:$PYTHONPATH +export PYTHONPATH=@OTB_INSTALL_PREFIX@/lib:@OTB_PYTHONPATH@:$PYTHONPATH export OTB_APPLICATION_PATH=@OTB_INSTALL_PREFIX@/lib/otb/applications @PYTHON_EXECUTABLE@ @CMAKE_SOURCE_DIR@/Scripts/otbGenerateWrappersRstDoc.py diff --git a/Documentation/Cookbook/CMakeLists.txt b/Documentation/Cookbook/CMakeLists.txt index 157eb54fea..7228a6a1e4 100644 --- a/Documentation/Cookbook/CMakeLists.txt +++ b/Documentation/Cookbook/CMakeLists.txt @@ -10,6 +10,25 @@ endif() #find OTB find_package(OTB REQUIRED) +if( OTB_FOUND ) + include(${OTB_USE_FILE}) + message(STATUS "Found OTB: ${OTB_DIR} (found version \"${OTB_VERSION}\")") +else() + message(FATAL_ERROR "OTB not found. Please set OTB_DIR") + return() +endif() + +set(OTB_PYTHONPATH) +if( EXISTS "${OTB_DIR}/CMakeCache.txt" ) + set(OTB_INSTALL_PREFIX ${OTB_DIR}) + set(OTB_PYTHONPATH "${OTB_INSTALL_PREFIX}/Modules/Wrappers/SWIG/src") +elseif( EXISTS "${OTB_DIR}/UseOTB.cmake" ) + get_filename_component(OTB_INSTALL_PREFIX ${OTB_DIR} PATH) + get_filename_component(OTB_INSTALL_PREFIX ${OTB_INSTALL_PREFIX} PATH) + get_filename_component(OTB_INSTALL_PREFIX ${OTB_INSTALL_PREFIX} PATH) + set(OTB_PYTHONPATH "${OTB_INSTALL_PREFIX}/lib/otb/python") +endif() + #find Python find_package(PythonInterp REQUIRED) @@ -94,9 +113,16 @@ foreach(rst_file ${rst_sources3}) configure_file(${rst_file} ${RST_GENERATED_SOURCE_DIR}/Applications/${out_file} COPYONLY) endforeach() +file(GLOB rst_sources4 ${RST_SOURCES}/*.txt) +foreach(rst_file ${rst_sources4}) + get_filename_component(out_file ${rst_file} NAME) + configure_file(${rst_file} ${RST_GENERATED_SOURCE_DIR}/${out_file} COPYONLY) +endforeach() + configure_file(${RST_SOURCES}/conf.py.in ${RST_GENERATED_SOURCE_DIR}/conf.py @ONLY) configure_file(${RST_SOURCES}/Makefile.in ${RST_GENERATED_SOURCE_DIR}/Makefile @ONLY) + add_custom_target(generate_otbapps_rst ALL COMMAND ${SH_INTERP} ${CMAKE_CURRENT_BINARY_DIR}/RunApplicationsRstGenerator.sh -- GitLab