diff --git a/CMake/OTBStandaloneModuleMacros.cmake b/CMake/OTBStandaloneModuleMacros.cmake index e877a15ceb405951e27bddf2e55f914b5ad2d980..5771498ab5f0b4040fa02a1a0d40d82532514c8b 100644 --- a/CMake/OTBStandaloneModuleMacros.cmake +++ b/CMake/OTBStandaloneModuleMacros.cmake @@ -23,6 +23,8 @@ # OTB before including OTBModuleMacros. This is the preferred way to build an # OTB module outside of the OTB source tree. +include(GenerateExportHeaderCustom) + macro(otb_module_test) include(../otb-module.cmake) # Load module meta-data set(${otb-module-test}_LIBRARIES "") diff --git a/Packaging/Files/build_wrapping.cmake b/Packaging/Files/build_wrapping.cmake index 45036d00e7d1eb28b086a89913cd22bea61cc45e..3cbce611896581e1ea533b6f342c14767a324650 100644 --- a/Packaging/Files/build_wrapping.cmake +++ b/Packaging/Files/build_wrapping.cmake @@ -38,6 +38,7 @@ endif() set(CONFIGURE_OPTIONS "-DCMAKE_INSTALL_PREFIX=${PKG_PREFIX}" + "-DCMAKE_INSTALL_RPATH=${PKG_PREFIX}/lib" "-DCMAKE_BUILD_TYPE=Release") if(PYTHON_EXECUTABLE) list(APPEND CONFIGURE_OPTIONS "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") diff --git a/Packaging/Files/otbenv.bash b/Packaging/Files/otbenv.bash index 4102c5b50d73bc7cbfeae495d91f291320224226..f2f56b4822de33759300d8b4c0d5cde1af869d9a 100644 --- a/Packaging/Files/otbenv.bash +++ b/Packaging/Files/otbenv.bash @@ -18,6 +18,22 @@ # limitations under the License. # +cat_path() +{ + if [ $# -eq 0 ]; then exit 0; fi + if [ $# -eq 1 ]; then echo "$1"; exit 0; fi + cur="$1" + shift 1 + next="$(cat_path $@)" + if [ -z "$cur" ]; then + echo "$next" + elif [ -z "$next" ]; then + echo "$cur" + else + echo "$cur:$next" + fi +} + # The below environment variables only affect current shell # So if you run again from a terminal. you need to run the script again # see how this is sourced in monteverdi.sh and mapla.sh @@ -26,11 +42,11 @@ CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P unset LD_LIBRARY_PATH -PATH=$CURRENT_DIR/bin:$PATH +PATH=$(cat_path "$CURRENT_DIR/bin" "$PATH") GDAL_DATA=$CURRENT_DIR/share/data GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv -PYTHONPATH=$CURRENT_DIR/lib/python:$PYTHONPATH -OTB_APPLICATION_PATH=$CURRENT_DIR/lib/otb/applications +PYTHONPATH=$(cat_path "$CURRENT_DIR/lib/python" "$PYTHONPATH") +OTB_APPLICATION_PATH=$(cat_path "$CURRENT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH") GDAL_DRIVER_PATH="disable" LC_NUMERIC=C diff --git a/Packaging/Files/otbenv.bat b/Packaging/Files/otbenv.bat index 615271ecd6104cf6e4bc70651ce2bd0aaeada606..6b4efefb227c0767592e1210f801f62212a7aded 100644 --- a/Packaging/Files/otbenv.bat +++ b/Packaging/Files/otbenv.bat @@ -16,15 +16,31 @@ :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. :: See the License for the specific language governing permissions and :: limitations under the License. - +@echo off :: Setup environment for OTB package set CURRENT_SCRIPT_DIR=%~dp0 -set PATH=%CURRENT_SCRIPT_DIR%bin;%PATH% +call :prefix_path PATH "%CURRENT_SCRIPT_DIR%bin" +call :prefix_path PYTHONPATH "%CURRENT_SCRIPT_DIR%lib\python" +call :prefix_path OTB_APPLICATION_PATH "%CURRENT_SCRIPT_DIR%lib\otb\applications" + set GDAL_DATA=%CURRENT_SCRIPT_DIR%share\data set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv -set PYTHONPATH=%CURRENT_SCRIPT_DIR%lib\python;%PYTHONPATH% -set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%lib\otb\applications set GDAL_DRIVER_PATH=disable :: Set numeric locale to C set LC_NUMERIC=C +goto :eof + +:prefix_path +setlocal enabledelayedexpansion +set output=%~2 +set var=%1 +set content= +if not defined %var% ( goto :prefix_path_testcontent ) +set content=!%var%! +:prefix_path_testcontent +if "%content%" == "" ( goto :prefix_path_end ) +set output=%output%;%content% +:prefix_path_end +endlocal & set %1=%output% +goto :eof diff --git a/Packaging/Files/otbenv.profile b/Packaging/Files/otbenv.profile index 1e147d1c0528dbe4a16d99e76ac040989773aaf8..c98c77a451515aabf146a123668954b9dad91533 100644 --- a/Packaging/Files/otbenv.profile +++ b/Packaging/Files/otbenv.profile @@ -19,6 +19,22 @@ # limitations under the License. # +cat_path() +{ + if [ $# -eq 0 ]; then exit 0; fi + if [ $# -eq 1 ]; then echo "$1"; exit 0; fi + cur="$1" + shift 1 + next="$(cat_path $@)" + if [ -z "$cur" ]; then + echo "$next" + elif [ -z "$next" ]; then + echo "$cur" + else + echo "$cur:$next" + fi +} + # The below environment variables only affect current shell # So if you run again from a terminal. you need to run the script again # see how this is sourced in monteverdi.sh and mapla.sh @@ -27,17 +43,13 @@ CMAKE_PREFIX_PATH=OUT_DIR export CMAKE_PREFIX_PATH # check and set OTB_APPLICATION_PATH -if [ -z "$OTB_APPLICATION_PATH" ] || [ "$OTB_APPLICATION_PATH" = "" ]; then - OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications -else - OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications:$OTB_APPLICATION_PATH -fi +OTB_APPLICATION_PATH=$(cat_path "OUT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH") # Add bin direcotory to system PATH -PATH=OUT_DIR/bin:$PATH +PATH=$(cat_path "OUT_DIR/bin" "$PATH") # export PYTHONPATH to import otbApplication.py -PYTHONPATH=OUT_DIR/lib/python:$PYTHONPATH +PYTHONPATH=$(cat_path "OUT_DIR/lib/python" "$PYTHONPATH") # set numeric locale to C LC_NUMERIC=C