diff --git a/CMake/FindGLEW.cmake b/CMake/FindGLEW.cmake index c54e3656c7f7844cb52d8cfa1b15258c515fa9b3..243191dbd57e5d53d680c74fa7f697f4e6b13f60 100644 --- a/CMake/FindGLEW.cmake +++ b/CMake/FindGLEW.cmake @@ -28,54 +28,33 @@ # # Try to find GLEW library and include path. # Once done this will define +#rewritten for OTB by Rashad Kanavath # # GLEW_FOUND # GLEW_INCLUDE_PATH # GLEW_LIBRARY # -IF (WIN32) - FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h - $ENV{PROGRAMFILES}/GLEW/include - ${GLEW_ROOT_DIR}/include - DOC "The directory where GL/glew.h resides") +find_path( + GLEW_INCLUDE_DIR GL/glew.h + DOC "The directory where GL/glew.h resides" + ) - FIND_LIBRARY( GLEW_LIBRARY - NAMES glew GLEW glew32 glew32s - PATHS - $ENV{PROGRAMFILES}/GLEW/lib - ${GLEW_ROOT_DIR}/lib - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib - DOC "The GLEW library") -ELSE (WIN32) - FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h - /usr/include - /usr/local/include - /sw/include - /opt/local/include - ${GLEW_ROOT_DIR}/include - DOC "The directory where GL/glew.h resides") +if(WIN32) + set(GLEW_LIB_NAMES glew GLEW glew32 glew32s) +else() + set(GLEW_LIB_NAMES libGLEW GLEW) +endif() - # Prefer the static library. - FIND_LIBRARY( GLEW_LIBRARY - NAMES libGLEW.so GLEW - PATHS - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - ${GLEW_ROOT_DIR}/lib - DOC "The GLEW library") -ENDIF (WIN32) +FIND_LIBRARY( GLEW_LIBRARY + NAMES ${GLEW_LIB_NAMES} + DOC "The GLEW library") -SET(GLEW_FOUND "NO") -IF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) - SET(GLEW_LIBRARIES ${GLEW_LIBRARY}) - SET(GLEW_FOUND "YES") -ENDIF () +set(GLEW_FOUND FALSE) +if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) + set(GLEW_LIBRARIES ${GLEW_LIBRARY}) + set(GLEW_FOUND TRUE) +endif() INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW diff --git a/CMake/FindGLFW.cmake b/CMake/FindGLFW.cmake index 3f4c29ef713aeed6e7f4b65673065bb49f4f4141..2accc1c780a5fdceef6297d059c405ab6b3dc57a 100644 --- a/CMake/FindGLFW.cmake +++ b/CMake/FindGLFW.cmake @@ -80,4 +80,4 @@ ENDIF() INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW REQUIRED_VARS GLFW_LIBRARY GLFW_INCLUDE_DIR - VERSION_VAR GLFW_VERSION_STRING) \ No newline at end of file + VERSION_VAR GLFW_VERSION_STRING) diff --git a/CMake/FindLibKML.cmake b/CMake/FindLibKML.cmake index bb3136e4639ed4e7f7809de53bff8af21ae9a8dc..0a3706d38892f403921ef69eb540c63cead12694 100644 --- a/CMake/FindLibKML.cmake +++ b/CMake/FindLibKML.cmake @@ -31,55 +31,35 @@ if( LIBKML_INCLUDE_DIR ) set( LibKML_FIND_QUIETLY TRUE ) endif() -find_path( LIBKML_INCLUDE_DIR kml/dom.h ) +find_path( LIBKML_INCLUDE_DIR kml/dom.h ) +find_library( LIBKML_BASE_LIBRARY NAMES kmlbase ) +find_library( LIBKML_DOM_LIBRARY NAMES kmldom ) +find_library( LIBKML_ENGINE_LIBRARY NAMES kmlengine ) -find_library( LIBKML_BASE_LIBRARY - NAMES kmlbase ) - -# TODO : add HINTS derived from path of LIBKML_BASE_LIBRARY -find_library( LIBKML_CONVENIENCE_LIBRARY - NAMES kmlconvenience ) -find_library( LIBKML_DOM_LIBRARY - NAMES kmldom ) -find_library( LIBKML_ENGINE_LIBRARY - NAMES kmlengine ) -find_library( LIBKML_REGIONATOR_LIBRARY - NAMES kmlregionator ) -find_library( LIBKML_XSD_LIBRARY - NAMES kmlxsd ) -find_library( LIBKML_MINIZIP_LIBRARY - NAMES minizip ) - -mark_as_advanced( LIBKML_INCLUDE_DIR - LIBKML_BASE_LIBRARY - LIBKML_CONVENIENCE_LIBRARY - LIBKML_DOM_LIBRARY - LIBKML_ENGINE_LIBRARY - LIBKML_REGIONATOR_LIBRARY - LIBKML_XSD_LIBRARY - LIBKML_MINIZIP_LIBRARY ) +mark_as_advanced( + LIBKML_INCLUDE_DIR + LIBKML_BASE_LIBRARY + LIBKML_DOM_LIBRARY + LIBKML_ENGINE_LIBRARY + ) # handle the QUIETLY and REQUIRED arguments and set LIBKML_FOUND to TRUE if # all listed variables are TRUE include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( LibKML DEFAULT_MSG - LIBKML_BASE_LIBRARY - LIBKML_CONVENIENCE_LIBRARY - LIBKML_DOM_LIBRARY - LIBKML_ENGINE_LIBRARY - LIBKML_REGIONATOR_LIBRARY - LIBKML_XSD_LIBRARY - LIBKML_MINIZIP_LIBRARY - LIBKML_INCLUDE_DIR - ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + LibKML + DEFAULT_MSG + LIBKML_INCLUDE_DIR + LIBKML_BASE_LIBRARY + LIBKML_DOM_LIBRARY + LIBKML_ENGINE_LIBRARY + ) if(LIBKML_FOUND) set(LIBKML_INCLUDE_DIRS ${LIBKML_INCLUDE_DIR}) - set(LIBKML_LIBRARIES ${LIBKML_BASE_LIBRARY} - ${LIBKML_CONVENIENCE_LIBRARY} - ${LIBKML_DOM_LIBRARY} - ${LIBKML_ENGINE_LIBRARY} - ${LIBKML_REGIONATOR_LIBRARY} - ${LIBKML_XSD_LIBRARY} - ${LIBKML_MINIZIP_LIBRARY}) + set(LIBKML_LIBRARIES + ${LIBKML_BASE_LIBRARY} + ${LIBKML_DOM_LIBRARY} + ${LIBKML_ENGINE_LIBRARY} + ) endif() diff --git a/CMake/FindLibSVM.cmake b/CMake/FindLibSVM.cmake index cc15db682271e70994459569eb590b6d0e241900..93b2c9d126f4b7abe7aa89fb0d7a92fa40bc4f76 100644 --- a/CMake/FindLibSVM.cmake +++ b/CMake/FindLibSVM.cmake @@ -14,7 +14,7 @@ # LIBSVM_MINOR_VERSION - minor version # LIBSVM_PATCH_VERSION - patch version # LIBSVM_VERSION_STRING - version (ex. 2.9.0) -# LIBSVM_ROOT_DIR - root dir (ex. /usr/local) +# LIBSVM_ROOT_DIR - libsvm install directory #============================================================================= # Copyright 2000-2009 Kitware, Inc., Insight Software Consortium diff --git a/CMake/FindOpenThreads.cmake b/CMake/FindOpenThreads.cmake index e57dff2ce667c6dceec96a49d55f011a0926877d..2462dbfb27cf1a0ed154e961ffcf637a346ccb5e 100644 --- a/CMake/FindOpenThreads.cmake +++ b/CMake/FindOpenThreads.cmake @@ -58,23 +58,9 @@ # standard install paths. # Explicit -DVAR=value arguments should still be able to override everything. -find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread - HINTS - # enough environment variables? - $ENV{OPENTHREADS_INCLUDE_DIR} - $ENV{OPENTHREADS_DIR} - $ENV{OSG_INCLUDE_DIR} - $ENV{OSG_DIR} - $ENV{OSGDIR} - $ENV{OpenThreads_ROOT} - $ENV{OSG_ROOT} - PATHS - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - /usr/freeware - PATH_SUFFIXES include +find_path( + OPENTHREADS_INCLUDE_DIR OpenThreads/Thread + PATH_SUFFIXES include ) mark_as_advanced(OPENTHREADS_INCLUDE_DIR) @@ -95,41 +81,12 @@ endif() find_library(OPENTHREADS_LIBRARY NAMES OpenThreads OpenThreadsWin32 - HINTS - $ENV{OPENTHREADS_LIBRARY_DIR} - $ENV{OPENTHREADS_DIR} - $ENV{OSG_LIBRARY_DIR} - $ENV{OSG_DIR} - $ENV{OSGDIR} - $ENV{OpenThreads_ROOT} - $ENV{OSG_ROOT} - PATHS - /sw - /opt/local - /opt/csw - /opt - /usr/freeware PATH_SUFFIXES lib64 lib ) mark_as_advanced(OPENTHREADS_LIBRARY) find_library(OPENTHREADS_LIBRARY_DEBUG NAMES OpenThreadsd OpenThreadsWin32d - HINTS - $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR} - $ENV{OPENTHREADS_LIBRARY_DIR} - $ENV{OPENTHREADS_DIR} - $ENV{OSG_LIBRARY_DIR} - $ENV{OSG_DIR} - $ENV{OSGDIR} - $ENV{OpenThreads_ROOT} - $ENV{OSG_ROOT} - PATHS - /sw - /opt/local - /opt/csw - /opt - /usr/freeware PATH_SUFFIXES lib64 lib ) mark_as_advanced(OPENTHREADS_LIBRARY_DEBUG) diff --git a/CMake/FindQwt.cmake b/CMake/FindQwt.cmake index d0c8a70a8a99ff0feb5644bb45780176c57d7a9c..fc2f5254b1ba5d91bdfd54957a1073fff357e298 100644 --- a/CMake/FindQwt.cmake +++ b/CMake/FindQwt.cmake @@ -31,7 +31,7 @@ # QWT_MINOR_VERSION - minor version # QWT_PATCH_VERSION - patch version # QWT_VERSION_STRING - version (ex. 5.2.1) -# QWT_ROOT_DIR - root dir (ex. /usr/local) +# QWT_ROOT_DIR - root dir #============================================================================= # Copyright 2010-2013, Julien Schueller diff --git a/CMake/FindShark.cmake b/CMake/FindShark.cmake index c223e4a16c2b681d7aa9944987ead6c58da6df69..59bef138f730718a535ef984deace363cf4f8a47 100644 --- a/CMake/FindShark.cmake +++ b/CMake/FindShark.cmake @@ -55,12 +55,9 @@ find_library( SHARK_LIBRARY mark_as_advanced( SHARK_INCLUDE_DIR SHARK_LIBRARY ) -find_package( Boost 1.48.0 REQUIRED QUIET COMPONENTS - system date_time filesystem - program_options serialization thread - unit_test_framework - ) - +find_package( Boost 1.48.0 REQUIRED QUIET + COMPONENTS serialization + ) if(NOT Boost_FOUND) message(FATAL_ERROR "Please make sure Boost 1.48.0 is installed on your system") endif() @@ -107,33 +104,11 @@ string(REGEX MATCH "#define.SHARK_USE_OPENMP" SHARK_USE_OPENMP_matched "${SHARK_H_CONTENTS}") -#this variable is added in cache but not used now -# you can use it to see if shark installation has openMP -# later if needed in other places.. -set(SHARK_USE_OPENMP FALSE CACHE BOOL "shark is built with OpenMP") if(SHARK_USE_OPENMP_matched) - set(SHARK_USE_OPENMP TRUE CACHE BOOL "shark is built with OpenMP" FORCE) -endif() - -#This is quick fix/hack/commit that will get back all failing tests on -# The good fix must to fix all those failing tests. They are crashing -# due to openmp issues which only popup with this fix -if(NOT WIN32) -if(SHARK_USE_OPENMP) - message(STATUS "Shark is built with OpenMP: SHARK_USE_OPENMP = TRUE") - find_package(OpenMP REQUIRED QUIET) - if(OPENMP_FOUND) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") - else() - message(FATAL_ERROR "Your shark libraries are compiled with it OpenMP") - set(SHARK_FOUND FALSE) + if(NOT OTB_USE_OPENMP) + message(WARNING "Shark library is built with OpenMP and you have OTB_USE_OPENMP set to OFF.") endif() -else() - message(STATUS "Shark is built without OpenMP: SHARK_USE_OPENMP = FALSE") endif() -endif(NOT WIN32) INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Shark diff --git a/CMake/OTBCheckSSEFeatures.cmake b/CMake/OTBCheckSSEFeatures.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a7c67ed7de4f8274c379f86af8663f85630793c3 --- /dev/null +++ b/CMake/OTBCheckSSEFeatures.cmake @@ -0,0 +1,63 @@ +function(check_sse_features sse_flags ) + include(CheckCXXSourceRuns) + include(CheckCXXCompilerFlag) + + set(${sse_flags} "0" PARENT_SCOPE) + # For apple assume sse2 is on for all intel builds, check for 64 and 32 bit versions + if(APPLE) + message(STATUS "For apple assume sse2 is on for all intel builds") + return() + endif() + set(sse_flags_detected) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + set(CMAKE_REQUIRED_FLAGS "-msse2") + set(sse_flags_detected "-msse2 -mfpmath=sse") + elseif(MSVC AND NOT CMAKE_CL_64) + set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") + set(sse_flags_detected "/arch:SSE2") + endif() + + check_cxx_source_runs(" + #include <emmintrin.h> + int main () + { + __m128d a, b; + double vals[2] = {0}; + a = _mm_loadu_pd (vals); + b = _mm_add_pd (a,a); + _mm_storeu_pd (vals,b); + return (0); + }" + HAVE_SSE2_EXTENSIONS) + + if(HAVE_SSE2_EXTENSIONS) + set(${sse_flags} "${sse_flags_detected}" PARENT_SCOPE) + return() + endif() + + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + set(CMAKE_REQUIRED_FLAGS "-msse") + set(sse_flags_detected "-msse -mfpmath=sse") + elseif(MSVC AND NOT CMAKE_CL_64) + set(CMAKE_REQUIRED_FLAGS "/arch:SSE") + set(sse_flags_detected "/arch:SSE") + endif() + + check_cxx_source_runs(" + #include <xmmintrin.h> + int main() + { + __m128 a, b; + float vals[4] = {0}; + a = _mm_loadu_ps(vals); + b = a; + b = _mm_add_ps(a,b); + _mm_storeu_ps(vals,b); + return 0; + }" HAVE_SSE_EXTENSIONS) + + if(HAVE_SSE_EXTENSIONS) + set(${sse_flags} "${sse_flags_detected}" PARENT_SCOPE) + return() + endif() +endfunction() #check_sse_features diff --git a/CMake/OTBConfig.cmake.in b/CMake/OTBConfig.cmake.in index d0361832e47f1967ca2d18dbd22edbcf1ad6bb02..fcaed33779c658840d652a672a42d3d1cd785f2f 100644 --- a/CMake/OTBConfig.cmake.in +++ b/CMake/OTBConfig.cmake.in @@ -26,6 +26,11 @@ # to load OTB's settings for an external project. @OTB_CONFIG_CODE@ +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +#RK: TODO: add sse2, see4, see4.1, openmp flags + # The C and C++ flags added by OTB to the cmake-configured flags. set(OTB_REQUIRED_C_FLAGS "@OTB_REQUIRED_C_FLAGS@") set(OTB_REQUIRED_CXX_FLAGS "@OTB_REQUIRED_CXX_FLAGS@") @@ -39,12 +44,24 @@ set(OTB_VERSION_PATCH "@OTB_VERSION_PATCH@") # OTB's CMake directory with modules OTB uses. set(OTB_CMAKE_DIR "@OTB_CONFIG_CMAKE_DIR@") +# OTB uses OPENMP +set(OTB_USE_OPENMP "@OTB_USE_OPENMP@") + +# OTB uses SSE optim +set(OTB_USE_SSE_FLAGS "@OTB_USE_SSE_FLAGS@") + +# use Find*.cmake files included in OTB package for external dependencies. (OpenCV, GDAL etc..) +set(CMAKE_MODULE_PATH ${OTB_CMAKE_DIR} ${CMAKE_MODULE_PATH}) + # The location of the UseOTB.cmake file. set(OTB_USE_FILE "@OTB_USE_FILE@") # Whether OTB was built with shared libraries. set(OTB_BUILD_SHARED "@BUILD_SHARED_LIBS@") +# Default value for WINDOWS_EXPORT_ALL_SYMBOLS target property +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "@OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS@") + # List of available OTB modules. set(OTB_MODULES_ENABLED "@OTB_CONFIG_MODULES_ENABLED@") diff --git a/CMake/OTBModuleEnablement.cmake b/CMake/OTBModuleEnablement.cmake index 749a3b375f109c24c8050f4d4384a7a06f5b99f7..4ec34d94df5315c4381769b3c33a380358163a86 100644 --- a/CMake/OTBModuleEnablement.cmake +++ b/CMake/OTBModuleEnablement.cmake @@ -157,14 +157,18 @@ macro(otb_module_enable otb-module _needed_by) endif() if(NOT ${otb-module}_ENABLED) set(${otb-module}_ENABLED 1) - foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS) - otb_module_enable(${dep} ${otb-module}) - endforeach() - foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS) - otb_module_enable(${dep} ${otb-module}) - endforeach() - if(${otb-module}_TESTED_BY AND (OTB_BUILD_DEFAULT_MODULES OR OTB_BUILD_ALL_MODULES_FOR_TESTS OR Module_${otb-module})) - otb_module_enable(${${otb-module}_TESTED_BY} "") + # if this module has an ACTIVATION_OPTION=OFF, don't bother enable its dependencies + if(NOT (OTB_MODULE_${otb-module}_ACTIVATION_OPTION + AND NOT ${OTB_MODULE_${otb-module}_ACTIVATION_OPTION})) + foreach(dep IN LISTS OTB_MODULE_${otb-module}_DEPENDS) + otb_module_enable(${dep} ${otb-module}) + endforeach() + foreach(dep IN LISTS OTB_MODULE_${otb-module}_OPTIONAL_DEPENDS) + otb_module_enable(${dep} ${otb-module}) + endforeach() + if(${otb-module}_TESTED_BY AND (OTB_BUILD_DEFAULT_MODULES OR OTB_BUILD_ALL_MODULES_FOR_TESTS OR Module_${otb-module})) + otb_module_enable(${${otb-module}_TESTED_BY} "") + endif() endif() endif() endmacro() diff --git a/CMake/OTBSetStandardCompilerFlags.cmake b/CMake/OTBSetStandardCompilerFlags.cmake index f8549625df6b882bf1d666a037505a9f29677619..d2495d4a0756a73bf0f4edd1fffe251cbdb4a636 100644 --- a/CMake/OTBSetStandardCompilerFlags.cmake +++ b/CMake/OTBSetStandardCompilerFlags.cmake @@ -235,35 +235,11 @@ macro(check_compiler_platform_flags) ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "4.8" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.9") )) set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -Wno-array-bounds") endif() + endif() - if(APPLE) - option(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING "Turn on warnings on 64bits to 32bits truncations." OFF) - mark_as_advanced(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING) - - execute_process(COMMAND "${CMAKE_C_COMPILER}" --version - OUTPUT_VARIABLE _version ERROR_VARIABLE _version) - - # -fopenmp breaks compiling the HDF5 library in shared library mode - # on the OS X platform -- at least with gcc 4.2 from Xcode. - set(compile_flag_lists CMAKE_C_FLAGS CMAKE_CXX_FLAGS - CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO) - foreach(listname ${compile_flag_lists}) - if("${${listname}}" MATCHES ".*-fopenmp.*") - string(REPLACE "-fopenmp" "" tmpFlags "${${listname}}") - set(${listname} "${tmpFlags}") - message("-fopenmp causes incorrect compliation of HDF, removing from ${listname}") - endif() - endforeach() - endif() - - # gcc must have -msse2 option to enable sse2 support - if(VNL_CONFIG_ENABLE_SSE2 OR VNL_CONFIG_ENABLE_SSE2_ROUNDING) - set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} -msse2") - endif() - + if(APPLE) + option(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING "Turn on warnings on 64bits to 32bits truncations." OFF) + mark_as_advanced(OTB_USE_64BITS_APPLE_TRUNCATION_WARNING) endif() #----------------------------------------------------------------------------- @@ -296,6 +272,36 @@ macro(check_compiler_platform_flags) set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -mthreads") endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") + set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} -Wl,--no-undefined") + endif() + + # check for OpenMP + if(OTB_USE_OPENMP) + message(STATUS "OpenMP support requested with OTB_USE_OPENMP=${OTB_USE_OPENMP}") + find_package(OpenMP QUIET) + endif() + if(OPENMP_FOUND) + message(STATUS "Adding '${OpenMP_CXX_FLAGS}' to OTB_REQUIRED_CXX_FLAGS ") + set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + if(OpenMP_EXE_LINKER_FLAGS) + set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + endif() + endif() + + set(OTB_SSE_FLAGS) + if(OTB_USE_SSE_FLAGS) + message(STATUS "SIMD extensions requested with OTB_USE_SSE_FLAGS=${OTB_USE_SSE_FLAGS}") + include(OTBCheckSSEFeatures) + check_sse_features(OTB_SSE_FLAGS) + if(OTB_SSE_FLAGS) + message(STATUS "Adding '${OTB_SSE_FLAGS}' to OTB_REQUIRED_CXX_FLAGS") + set(OTB_REQUIRED_CXX_FLAGS "${OTB_REQUIRED_CXX_FLAGS} ${OTB_SSE_FLAGS}") + endif() + endif() #----------------------------------------------------------------------------- # The frename-registers option does not work due to a bug in the gnu compiler. @@ -303,6 +309,7 @@ macro(check_compiler_platform_flags) # will be produced. This is first documented in the gcc4 man page. if(CMAKE_COMPILER_IS_GNUCXX) set(ALL_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" ) + #TODO: list(REMOVE_DUPLICATES ALL_FLAGS) separate_arguments(ALL_FLAGS) foreach(COMP_OPTION ${ALL_FLAGS}) if("${COMP_OPTION}" STREQUAL "-frename-registers") diff --git a/CMake/otbcli.bat.in b/CMake/otbcli.bat.in index 165d8338726754d5f7188bc7ae3ae3e52a41685d..3016c022e474338576c20cea114da8662d247045 100644 --- a/CMake/otbcli.bat.in +++ b/CMake/otbcli.bat.in @@ -21,8 +21,8 @@ if exist %CURRENT_SCRIPT_DIR%..\@OTB_INSTALL_APP_DIR_NATIVE@ ( ) ::set GDAL_DATA, EPSG_CSV and update PATH -if exist %CURRENT_SCRIPT_DIR%\..\otbenv.cmd ( - call %CURRENT_SCRIPT_DIR%\..\otbenv.cmd +if exist %CURRENT_SCRIPT_DIR%\..\otbenv.bat ( + call %CURRENT_SCRIPT_DIR%\..\otbenv.bat ) set LC_NUMERIC=C diff --git a/CMake/otbcli.sh.in b/CMake/otbcli.sh.in index 3026dad88730fcaca2543bff9e97c5db66a85c6a..65bec6865398591429712c71c636bed7b1abdeb6 100644 --- a/CMake/otbcli.sh.in +++ b/CMake/otbcli.sh.in @@ -16,15 +16,6 @@ else OTB_CLI_LAUNCHER=otbApplicationLauncherCommandLine fi -# works for install tree -if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ] -then - OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH -fi - -# export it to make it available to otbApplicationLauncherCommandLine environment -export OTB_APPLICATION_PATH - # avoid numerical issues caused by locale export LC_NUMERIC=C @@ -32,6 +23,13 @@ export LC_NUMERIC=C # Note that OTB_APPLICATION_PATH is reset here. if [ -f "$CURRENT_SCRIPT_DIR/../otbenv.profile" ]; then . "$CURRENT_SCRIPT_DIR/../otbenv.profile" +else + # works for install tree + if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ]; then + OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH + fi + # export it to make it available to otbApplicationLauncherCommandLine environment + export OTB_APPLICATION_PATH fi # start the application diff --git a/CMake/otbgui.bat.in b/CMake/otbgui.bat.in index c02e16ebf88e53714c73d4f8f93269be7961e65e..a450ce7881e68eff1a4d718155d1c7e63149fe82 100644 --- a/CMake/otbgui.bat.in +++ b/CMake/otbgui.bat.in @@ -22,6 +22,11 @@ if exist %CURRENT_SCRIPT_DIR%../@OTB_INSTALL_APP_DIR@ ( set LC_NUMERIC=C +::set GDAL_DATA, EPSG_CSV and update PATH +if exist %CURRENT_SCRIPT_DIR%\..\otbenv.bat ( + call %CURRENT_SCRIPT_DIR%\..\otbenv.bat +) + :: start the application %OTB_GUI_LAUNCHER% %* endlocal diff --git a/CMake/otbgui.sh.in b/CMake/otbgui.sh.in index 5f6354a75ced0919941e7012083e02cda4696a4c..8633efad8cb9097ab3caf34b9c80a91a18f129d7 100644 --- a/CMake/otbgui.sh.in +++ b/CMake/otbgui.sh.in @@ -16,21 +16,19 @@ else OTB_GUI_LAUNCHER=otbApplicationLauncherQt fi -# use the default install tree path for applications -if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ] -then - OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH -fi - -# export it to make it available to otbApplicationLauncherCommandLine environment -export OTB_APPLICATION_PATH - # avoid numerical issues caused by locale export LC_NUMERIC=C # Export GDAL_DATA, EPSG_CSV if [ -f "$CURRENT_SCRIPT_DIR/../otbenv.profile" ]; then . "$CURRENT_SCRIPT_DIR/../otbenv.profile" +else + # use the default install tree path for applications + if [ -d "$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@" ]; then + OTB_APPLICATION_PATH=$CURRENT_SCRIPT_DIR/../@OTB_INSTALL_APP_DIR@:$OTB_APPLICATION_PATH + fi + # export it to make it available to otbApplicationLauncherCommandLine environment + export OTB_APPLICATION_PATH fi # start the application diff --git a/CMakeLists.txt b/CMakeLists.txt index 19a6202b9f3e5a5455dc4babf186f9b1b6197fc2..31310a07f0d1b869ac0f5809d5b8f2b6081c0aab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,8 @@ endif() option(OTB_USE_DEPRECATED "Turn on the use and test of deprecated classes" OFF) mark_as_advanced(OTB_USE_DEPRECATED) +option(OTB_USE_OPENMP "Add openmp compiler and linker flags" OFF) +option(OTB_USE_SSE_FLAGS "Enable SIMD optimizations (hardware dependent)." ON) #----------------------------------------------------------------------------- # SHOW_ALL_MSG_DEBUG option option(OTB_SHOW_ALL_MSG_DEBUG "Show all debug messages (very verbose)" OFF) @@ -504,6 +506,8 @@ foreach(otb_option OTB_WRAP_PYTHON OTB_WRAP_JAVA OTB_DATA_ROOT + OTB_USE_OPENMP + OTB_USE_SSE_FLAGS ) get_white_spaces("${otb_option}" spaces) message("${otb_option} ${spaces} = ${${otb_option}}") diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index 7fd0efa838a4af62aeedaadf7f1b307d6079b234..042c4f450434c96de5367033f2c42ccde851dfe8 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -210,7 +210,7 @@ private: const int nbFeatures = GetSelectedItems("feat").size(); input->SetMeasurementVectorSize(nbFeatures); - + otb::ogr::Layer::const_iterator it = layer.cbegin(); otb::ogr::Layer::const_iterator itEnd = layer.cend(); for( ; it!=itEnd ; ++it) @@ -219,7 +219,11 @@ private: mv.SetSize(nbFeatures); for(int idx=0; idx < nbFeatures; ++idx) { - mv[idx] = (*it)[GetSelectedItems("feat")[idx]].GetValue<double>(); + // Beware that itemIndex differs from ogr layer field index + unsigned int itemIndex = GetSelectedItems("feat")[idx]; + std::string fieldName = GetChoiceNames( "feat" )[itemIndex]; + + mv[idx] = (*it)[fieldName].GetValue<double>(); } input->PushBack(mv); } diff --git a/Modules/Applications/AppSegmentation/app/CMakeLists.txt b/Modules/Applications/AppSegmentation/app/CMakeLists.txt index 097d9971f16a23b266e64e28469fca2444e15f0f..f55ae3d7f91d607359b5024a17f89136428edf76 100644 --- a/Modules/Applications/AppSegmentation/app/CMakeLists.txt +++ b/Modules/Applications/AppSegmentation/app/CMakeLists.txt @@ -75,3 +75,8 @@ otb_create_application( NAME MeanShiftSmoothing SOURCES otbMeanShiftSmoothing.cxx LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + +otb_create_application( + NAME LargeScaleMeanShift + SOURCES otbLargeScaleMeanShift.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) diff --git a/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d0dfadb1a535ce0c3acafecb650258c3c4d855e1 --- /dev/null +++ b/Modules/Applications/AppSegmentation/app/otbLargeScaleMeanShift.cxx @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +#include "otbWrapperCompositeApplication.h" +#include "otbWrapperApplicationFactory.h" + +namespace otb +{ +namespace Wrapper +{ + +/** + * \class LargeScaleMeanShift + * + * \brief All-in-one application for the LSMS framework + * + * This application gathers the 4 steps of the large-scale MeanShift + * segmentation framework. + * + */ +class LargeScaleMeanShift : public CompositeApplication +{ +public: + /** Standard class typedefs. */ + typedef LargeScaleMeanShift Self; + typedef CompositeApplication Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + +/** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(LargeScaleMeanShift, otb::CompositeApplication); + +private: + void DoInit() ITK_OVERRIDE + { + SetName("LargeScaleMeanShift"); + SetDescription("Large-scale segmentation using MeanShift"); + + // Documentation + SetDocName("Large-Scale MeanShift"); + SetDocLongDescription("This application chains together the 4 steps of the " + "MeanShit framework, that is the MeanShiftSmoothing [1], the " + "LSMSSegmentation [2], the LSMSSmallRegionsMerging [3] and the " + "LSMSVectorization [4].\n\n" + "This application can be a preliminary step for an object-based analysis.\n\n" + "It generates a vector data file containing the regions extracted with " + "the MeanShift algorithm. The spatial and range radius parameters allow " + "to adapt the sensitivity of the algorithm depending on the image dynamic " + "and resolution. There is a step to remove small regions whose size " + "(in pixels) is less than the given 'minsize' parameter. These regions " + "are merged to a similar neighbor region. In the output vectors, there " + "are additional fields to describe each region. In particular the mean " + "and standard deviation (for each band) is computed for each region " + "using the input image as support. If an optional 'imfield' image is " + "given, it will be used as support image instead." + ); + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("[1] MeanShiftSmoothing\n" + "[2] LSMSSegmentation\n" + "[3] LSMSSmallRegionsMerging\n" + "[4] LSMSVectorization"); + + AddDocTag(Tags::Segmentation); + AddDocTag("LSMS"); + + ClearApplications(); + AddApplication("MeanShiftSmoothing", "smoothing", "Smoothing step"); + AddApplication("LSMSSegmentation", "segmentation", "Segmentation step"); + AddApplication("LSMSSmallRegionsMerging", "merging", "Small region merging step"); + AddApplication("LSMSVectorization", "vectorization", "Vectorization step"); + + ShareParameter("in","smoothing.in"); + ShareParameter("spatialr","smoothing.spatialr"); + ShareParameter("ranger","smoothing.ranger"); + ShareParameter("minsize","merging.minsize"); + + ShareParameter("tilesizex","segmentation.tilesizex"); + ShareParameter("tilesizey","segmentation.tilesizey"); + + AddParameter(ParameterType_Choice, "mode","Output mode"); + SetParameterDescription("mode", "Type of segmented output"); + + AddChoice("mode.vector", "Segmentation as vector output"); + SetParameterDescription("mode.vector","In this mode, the application will " + "produce a vector file or database and compute field values for each " + "region"); + + AddParameter(ParameterType_InputImage, "mode.vector.imfield", "Support image for field computation"); + SetParameterDescription( "mode.vector.imfield", "This is an optional support image " + "that can be used to compute field values in each region. Otherwise, the " + "input image is used as support." ); + MandatoryOff("mode.vector.imfield"); + + ShareParameter("mode.vector.out","vectorization.out"); + + AddChoice("mode.raster", "Standard segmentation with labeled raster output"); + SetParameterDescription("mode.raster","In this mode, the application will produce a standard labeled raster."); + + ShareParameter("mode.raster.out","merging.out", + "The output raster image", + "It corresponds to the output of the small region merging step."); + + AddParameter( ParameterType_Empty, "cleanup", "Temporary files cleaning" ); + EnableParameter( "cleanup" ); + SetParameterDescription( "cleanup", + "If activated, the application will try to clean all temporary files it created" ); + MandatoryOff( "cleanup" ); + + // Setup RAM + ShareParameter("ram","smoothing.ram"); + Connect("merging.ram","smoothing.ram"); + Connect("vectorization.ram","smoothing.ram"); + + Connect("merging.tilesizex","segmentation.tilesizex"); + Connect("merging.tilesizey","segmentation.tilesizey"); + Connect("vectorization.tilesizex","segmentation.tilesizex"); + Connect("vectorization.tilesizey","segmentation.tilesizey"); + + // TODO : this is not exactly true, we used to choose the smoothed image instead + Connect("merging.in","smoothing.in"); + + // Setup constant parameters + GetInternalApplication("smoothing")->SetParameterString("foutpos","foo"); + GetInternalApplication("smoothing")->EnableParameter("foutpos"); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "QB_1_ortho.tif"); + SetDocExampleParameterValue("spatialr", "4"); + SetDocExampleParameterValue("ranger", "80"); + SetDocExampleParameterValue("minsize", "16"); + SetDocExampleParameterValue("mode.vector.out", "regions.shp"); + + SetOfficialDocLink(); + } + + void DoUpdateParameters() ITK_OVERRIDE + {} + + void DoExecute() ITK_OVERRIDE + { + bool isVector(GetParameterString("mode") == "vector"); + std::string outPath(isVector ? + GetParameterString("mode.vector.out"): + GetParameterString("mode.raster.out")); + std::vector<std::string> tmpFilenames; + tmpFilenames.push_back(outPath+std::string("_labelmap.tif")); + tmpFilenames.push_back(outPath+std::string("_labelmap.geom")); + ExecuteInternal("smoothing"); + // in-memory connexion here (saves 1 additional update for foutpos) + GetInternalApplication("segmentation")->SetParameterInputImage("in", + GetInternalApplication("smoothing")->GetParameterOutputImage("fout")); + GetInternalApplication("segmentation")->SetParameterInputImage("inpos", + GetInternalApplication("smoothing")->GetParameterOutputImage("foutpos")); + // temporary file output here + GetInternalApplication("segmentation")->SetParameterString("out", + tmpFilenames[0]); + // take half of previous radii + GetInternalApplication("segmentation")->SetParameterFloat("spatialr", + 0.5 * (double)GetInternalApplication("smoothing")->GetParameterInt("spatialr")); + GetInternalApplication("segmentation")->SetParameterFloat("ranger", + 0.5 * GetInternalApplication("smoothing")->GetParameterFloat("ranger")); + GetInternalApplication("segmentation")->ExecuteAndWriteOutput(); + + GetInternalApplication("merging")->SetParameterString("inseg", + tmpFilenames[0]); + EnableParameter("mode.raster.out"); + if (isVector) + { + tmpFilenames.push_back(outPath+std::string("_labelmap_merged.tif")); + tmpFilenames.push_back(outPath+std::string("_labelmap_merged.geom")); + GetInternalApplication("merging")->SetParameterString("out", + tmpFilenames[2]); + GetInternalApplication("merging")->ExecuteAndWriteOutput(); + if (IsParameterEnabled("mode.vector.imfield") && + HasValue("mode.vector.imfield")) + { + GetInternalApplication("vectorization")->SetParameterString("in", + GetParameterString("mode.vector.imfield")); + } + else + { + GetInternalApplication("vectorization")->SetParameterString("in", + GetParameterString("in")); + } + GetInternalApplication("vectorization")->SetParameterString("inseg", + tmpFilenames[2]); + ExecuteInternal("vectorization"); + } + else + { + GetInternalApplication("merging")->ExecuteAndWriteOutput(); + } + DisableParameter("mode.raster.out"); + + if( IsParameterEnabled( "cleanup" ) ) + { + otbAppLogINFO( <<"Final clean-up ..." ); + for (unsigned int i=0 ; i<tmpFilenames.size() ; ++i) + { + if(itksys::SystemTools::FileExists(tmpFilenames[i].c_str())) + { + itksys::SystemTools::RemoveFile(tmpFilenames[i].c_str()); + } + } + } + } + +}; + +} // end of namespace Wrapper +} // end of namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::LargeScaleMeanShift) diff --git a/Modules/Applications/AppSegmentation/test/CMakeLists.txt b/Modules/Applications/AppSegmentation/test/CMakeLists.txt index 090a2562ef000e91787672ced1a327d2cf4cd9bb..e04c3bbc1e328924e605ab1fd77fce88dcf800dc 100644 --- a/Modules/Applications/AppSegmentation/test/CMakeLists.txt +++ b/Modules/Applications/AppSegmentation/test/CMakeLists.txt @@ -293,3 +293,18 @@ otb_test_application(NAME apTvSeHooverCompareSegmentationTest --ignore-lines-with 2 outgt: outms: ) +#----------- LargeScaleMeanShift TESTS ---------------- +otb_test_application(NAME apTvSeLargeScaleMeanShiftTest + APP LargeScaleMeanShift + OPTIONS -in ${EXAMPLEDATA}/QB_1_ortho.tif + -spatialr 3 + -ranger 80 + -minsize 16 + -tilesizex 100 + -tilesizey 100 + -mode vector + -mode.vector.out ${TEMP}/apTvSeLargeScaleMeanShiftTestOut.shp + VALID --compare-ogr ${NOTOL} + ${BASELINE_FILES}/apTvSeLargeScaleMeanShiftTestOut.shp + ${TEMP}/apTvSeLargeScaleMeanShiftTestOut.shp + ) diff --git a/Modules/Core/Common/src/otbConfigure.h.in b/Modules/Core/Common/src/otbConfigure.h.in index d6968cb48f9ac97df74af529d277c4525d5ac2b0..5194398344bab96a44eb4bb622fda9dc1bf0ae46 100644 --- a/Modules/Core/Common/src/otbConfigure.h.in +++ b/Modules/Core/Common/src/otbConfigure.h.in @@ -31,3 +31,7 @@ #cmakedefine OTB_SHOW_ALL_MSG_DEBUG #cmakedefine OTB_USE_GDAL_20 + +#cmakedefine OTB_USE_OPENMP + +#cmakedefine OTB_USE_SSE_FLAGS diff --git a/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx b/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx index 4a2a416e5f9903b969816ecc22b52a059c419d90..d5f0f32747e42ebc0a7eb6a119a1d12628b34f2b 100644 --- a/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx +++ b/Modules/Feature/Descriptors/test/otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii.cxx @@ -36,9 +36,9 @@ bool CMP(std::vector<float> a, std::vector<float> b) return lexicographical_compare(a.begin(), a.begin() + 2, b.begin(), b.begin() + 2); } -int otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii(int itkNotUsed(argc), char * argv[]) +int +otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii( int itkNotUsed( argc ), char * argv[] ) { - const char * infname = argv[1]; const char * outfname = argv[2]; @@ -59,7 +59,7 @@ int otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii(int itkNotUsed(a typedef PointSetType::PointDataContainer PointDataContainerType; typedef PointDataContainerType::Iterator PointDataIteratorType; - typedef std::vector<float> siftDataVector; + typedef std::vector< RealType > siftDataVector; typedef std::vector<siftDataVector> ImageDataType; //Kind of PointSet with vectors // Instantiating object @@ -76,10 +76,29 @@ int otbImageToFastSIFTKeyPointSetFilterOutputInterestPointAscii(int itkNotUsed(a PointsIteratorType pIt = filter->GetOutput()->GetPoints()->Begin(); PointDataIteratorType pDataIt = filter->GetOutput()->GetPointData()->Begin(); + assert( + filter->GetOutput()->GetPoints()->Size() == + filter->GetOutput()->GetPointData()->Size() ); + std::ofstream outfile(outfname); outfile << "Number of scales: " << scales << std::endl; - outfile << "Number of SIFT key points: " << filter->GetOutput()->GetNumberOfPoints() << std::endl; + + outfile << "Number of SIFT key points: " + << filter->GetOutput()->GetNumberOfPoints() + << std::endl; + + outfile << "Number of points: " + << filter->GetOutput()->GetPoints()->Size() + << std::endl; + + outfile << "Number of points data: " + << filter->GetOutput()->GetPointData()->Size() + << std::endl; + + if( filter->GetOutput()->GetPoints()->Size() != + filter->GetOutput()->GetPointData()->Size() ) + return EXIT_FAILURE; // Copy the PointSet to std::vector< std::vector > while (pIt != filter->GetOutput()->GetPoints()->End()) diff --git a/Modules/IO/ImageIO/test/CMakeLists.txt b/Modules/IO/ImageIO/test/CMakeLists.txt index d8374f8955993381a7db0634300990f485c57964..aac49fcdeab48d245227689b5aeb6461f6d6dd07 100644 --- a/Modules/IO/ImageIO/test/CMakeLists.txt +++ b/Modules/IO/ImageIO/test/CMakeLists.txt @@ -458,13 +458,13 @@ otb_add_test(NAME ioTvStreamingImageFileWriterCalculateNumberOfDivisions_SetNumb ) otb_add_test(NAME ioTvStreamingImageFileWriterCalculateNumberOfDivisions_SetTileDimensionTiledStreaming COMMAND otbImageIOTestDriver - --compare-image ${EPSILON_9} ${INPUTDATA}/ToulouseQuickBird_Extrait_1500_3750.tif + --compare-image ${EPSILON_9} ${INPUTDATA}/QB_Toulouse_ortho_labelImage.tif ${TEMP}/ioStreamingImageFileWriterCalculateNumberOfDivisions_SetTileDimensionTiledStreaming.tif otbImageFileWriterTestCalculateNumberOfDivisions - ${INPUTDATA}/ToulouseQuickBird_Extrait_1500_3750.tif + ${INPUTDATA}/QB_Toulouse_ortho_labelImage.tif ${TEMP}/ioStreamingImageFileWriterCalculateNumberOfDivisions_SetTileDimensionTiledStreaming.tif SetTileDimensionTiledStreaming - 32 + 256 ) otb_add_test(NAME ioTvStreamingImageFileWriterCalculateNumberOfDivisions_SetNumberOfDivisionsTiledStreamingS COMMAND otbImageIOTestDriver diff --git a/Modules/IO/TestKernel/test/CMakeLists.txt b/Modules/IO/TestKernel/test/CMakeLists.txt index d0195c9e670427a31401d46e2c06641fdf24b033..945167830db96ed3722bb8f8ad5c9851da980194 100644 --- a/Modules/IO/TestKernel/test/CMakeLists.txt +++ b/Modules/IO/TestKernel/test/CMakeLists.txt @@ -32,6 +32,38 @@ set(OTBTestKernelTests add_executable(otbTestKernelTestDriver ${OTBTestKernelTests}) target_link_libraries(otbTestKernelTestDriver ${OTBTestKernel-Test_LIBRARIES}) + +# So the story here is that -Wl,-no-needed is a default linker flag on only on Ubuntu +# (debian or archlinux does not use this). This will exclude a lot of libraries from linking into +# executable. +# #ITK_LIBRARIES in a superbuild now contains the following libraries. +# "itkdouble-conversion itksys itkvcl itknetlib itkv3p_netlib itkvnl itkvnl_algo +# ITKVNLInstantiation ITKCommon itkNetlibSlatec ITKStatistics ITKTransform ITKLabelMap +# ITKMesh ITKMetaIO ITKSpatialObjects ITKPath ITKQuadEdgeMesh ITKIOImageBase ITKOptimizers +# ITKPolynomials ITKBiasCorrection ITKFFT ITKKLMRegionGrowing ITKOptimizersv4 ITKWatersheds" + +# OTBITK module will find all of these components in Modules/ThirdParty/ITK/otb-module-init.cmake +# But due to default -Wl,-as-needed flag many of them are ignored. +# see the documentation of GNU ld -as-needed for details on this behaviour. + +# Our problem is that we need these ignored ones in the some header-only modules. +# Eg: Modules/Core/LabelMap +# This module depends on ITKLabelMap but does not link with it as it doesn't create any module (lib, exe) +# All it use is a couple of headers from ITKLabelMap. So removing that dependency is out of question. + +# At this point, possible solution are follows: +# 1. use -Wl,-as-no-needed to CMAKE_LINKER FLAGS and be done with it. (all executable contains many used libs) +# 2. glob all libITK*, libitk* in the package script. (ugly and I don't agree) +# 3. make a dummy executable and link that with all of OTB libs and use -Wl,-no-as-needed in that +# 4. pick one of the random test executable and only add -Wl,-no-as-needed to it. (still a hack) +# .. +# ... +# RK: I finally decided to go with 4th option. +# Take an existing test executable otbTestKernelTestDriver and force -Wl,-no-as-needed. +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set_target_properties(otbTestKernelTestDriver PROPERTIES LINK_FLAGS "-Wl,-no-as-needed") +endif() + otb_module_target_label(otbTestKernelTestDriver) otb_add_test(NAME tsTvCompareAscii2 COMMAND otbTestKernelTestDriver --compare-ascii ${NOTOL} diff --git a/Modules/Remote/SertitObject.remote.cmake b/Modules/Remote/SertitObject.remote.cmake index 429896f222016846533a6270a059804ec4143285..e424926127c501f9886aeb0d0efbd11561dfb24d 100644 --- a/Modules/Remote/SertitObject.remote.cmake +++ b/Modules/Remote/SertitObject.remote.cmake @@ -26,5 +26,5 @@ median, variance, kurtosis, skewness. The result could be use to perform further object-oriented image analysis. " GIT_REPOSITORY https://github.com/sertit/SertitObject.git - GIT_TAG 9088356af5835e0a8de9946bd508735f3e55cb83 + GIT_TAG 49b6540c774ddb7c2d56e39f6f118c4dfb9b8bd3 ) diff --git a/Modules/ThirdParty/GeoTIFF/otb-module.cmake b/Modules/ThirdParty/GeoTIFF/otb-module.cmake index 0f331ec1574388189090987f879cea0e05cef9ab..8fbc7b52481a0374426fbede32743bae1da7b6d4 100644 --- a/Modules/ThirdParty/GeoTIFF/otb-module.cmake +++ b/Modules/ThirdParty/GeoTIFF/otb-module.cmake @@ -27,4 +27,6 @@ otb_module(OTBGeoTIFF DESCRIPTION "${DOCUMENTATION}" + + EXCLUDE_FROM_DEFAULT ) diff --git a/Modules/ThirdParty/OpenCV/CMakeLists.txt b/Modules/ThirdParty/OpenCV/CMakeLists.txt index 224f7318f21b3db89e7fb3848f8658727102bef3..e6b73b5096c68ac822737f74298ba491cd390d6d 100644 --- a/Modules/ThirdParty/OpenCV/CMakeLists.txt +++ b/Modules/ThirdParty/OpenCV/CMakeLists.txt @@ -27,7 +27,5 @@ set(OTBOpenCV_LIBRARIES "${OPENCV_LIBRARIES}") set(OTBOpenCV_INCLUDE_DIRS ${OTBOpenCV_BINARY_DIR}/src ) -set(OTBOpenCV_EXPORT_CODE_BUILD "find_package(OpenCV REQUIRED)") -set(OTBOpenCV_EXPORT_CODE_INSTALL ${OTBOpenCV_EXPORT_CODE_BUILD}) otb_module_impl() diff --git a/Modules/ThirdParty/OpenGL/CMakeLists.txt b/Modules/ThirdParty/OpenGL/CMakeLists.txt index cfbdd8cbfe568598f93eb4eef577f2f2cc635b30..99ab638244cb409a0a60c4d43706906777c12d97 100644 --- a/Modules/ThirdParty/OpenGL/CMakeLists.txt +++ b/Modules/ThirdParty/OpenGL/CMakeLists.txt @@ -23,5 +23,12 @@ set(OTBOpenGL_THIRD_PARTY 1) set(OTBOpenGL_SYSTEM_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) set(OTBOpenGL_LIBRARIES ${OPENGL_LIBRARIES}) +set(OTBOpenGL_EXPORT_CODE_INSTALL " +set(OTBOpenGL_LIBRARIES) +set(OTBOpenGL_INCLUDE_DIRS) +find_package(OpenGL REQUIRED) +set(OTBOpenGL_LIBRARIES \${OPENGL_LIBRARIES}) +set(OTBOpenGL_SYSTEM_INCLUDE_DIRS \${OPENGL_INCLUDE_DIR}) +") otb_module_impl() diff --git a/Modules/ThirdParty/Qt4/otb-module-init.cmake b/Modules/ThirdParty/Qt4/otb-module-init.cmake index d121d0689fec2907c69d87a76512fe176b18b351..951a96171c3e9701d6556c8ddfe8b013248960a5 100644 --- a/Modules/ThirdParty/Qt4/otb-module-init.cmake +++ b/Modules/ThirdParty/Qt4/otb-module-init.cmake @@ -18,7 +18,7 @@ # limitations under the License. # -find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL QtXml ) +find_package( Qt4 REQUIRED QtCore QtGui QtOpenGL) # QtXml ) mark_as_advanced( QT_QMAKE_EXECUTABLE ) -set( QT_USE_QTXML 1 ) +#set( QT_USE_QTXML 1 ) include( ${QT_USE_FILE} ) diff --git a/Modules/ThirdParty/SPTW/otb-module.cmake b/Modules/ThirdParty/SPTW/otb-module.cmake index eca0cb9b79963f110975bbe003094cf5f72720a1..a1dc674bd5b571e9beaa2d67929291914236b3be 100644 --- a/Modules/ThirdParty/SPTW/otb-module.cmake +++ b/Modules/ThirdParty/SPTW/otb-module.cmake @@ -24,6 +24,7 @@ otb_module(OTBSPTW DEPENDS OTBMPI OTBGDAL + OTBTIFF TEST_DEPENDS diff --git a/Modules/ThirdParty/SPTW/src/CMakeLists.txt b/Modules/ThirdParty/SPTW/src/CMakeLists.txt index 5e0feb3b3564cce128322633b60a77aab1107512..fcc9539ece8e4d8f92e11a6edde50ebbbdb73b00 100644 --- a/Modules/ThirdParty/SPTW/src/CMakeLists.txt +++ b/Modules/ThirdParty/SPTW/src/CMakeLists.txt @@ -28,7 +28,11 @@ set(OTBSPTW_MAIN_SRCS sptw.cc) add_library(otbSPTW ${OTBSPTW_MAIN_SRCS}) -target_link_libraries(otbSPTW) +target_link_libraries(otbSPTW + ${OTBMPI_LIBRARIES} + ${OTBGDAL_LIBRARIES} + ${OTBTIFF_LIBRARIES} + ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) #Install TARGET & FILES for otb-lib diff --git a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt index d96230c769a1286c55d4e6e9fe8390de445b53cd..2c6dc502edfb4c1e5c4df806b7db366c2d55e4de 100644 --- a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt +++ b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt @@ -51,12 +51,8 @@ if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) message(FATAL_ERROR "Impossible to compile libsiftfast. Contact OTB development team") endif() set(OTB_DISABLE_FAST_FUNCTIONS_VALUE 1) - else() - message(STATUS "Try to compile libsiftfast.cpp done.") endif() - set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g") - add_definitions(" -Wall -fPIC ") # check for x86-64 system check_cxx_source_runs(" @@ -72,120 +68,30 @@ if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) return 0; }" IS_X86_64) - - if( IS_X86_64 ) - add_definitions("-D__x86_64__") - endif() else() set(IS_X86_64 0) endif() -if(OTB_DISABLE_FAST_FUNCTIONS_VALUE) - add_definitions(-DOTB_DISABLE_FAST_FUNCTIONS) -endif() - - -include(CheckIncludeFile) -include(CheckLibraryExists) -include(CheckCXXSourceRuns) -include(CheckCXXCompilerFlag) - -# if( UNIX OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) -# set(STDC_LIBRARY stdc++) -# else() -# set(STDC_LIBRARY) -# endif() +#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g") +#add_xxdefinitions(" -Wall -fPIC ") -# check for SSE extensions +add_library(otbsiftfast libsiftfast.cpp) if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) - set(SSE_FLAGS) - - set(CMAKE_REQUIRED_FLAGS "-msse2") - check_cxx_source_runs(" - #include <emmintrin.h> - - int main() - { - __m128d a, b; - double vals[2] = {0}; - a = _mm_loadu_pd(vals); - b = _mm_add_pd(a,a); - _mm_storeu_pd(vals,b); - return 0; - }" - HAS_SSE2_EXTENSIONS) - - set(CMAKE_REQUIRED_FLAGS "-msse") - check_cxx_source_runs(" - #include <xmmintrin.h> - int main() - { - __m128 a, b; - float vals[4] = {0}; - a = _mm_loadu_ps(vals); - b = a; - b = _mm_add_ps(a,b); - _mm_storeu_ps(vals,b); - return 0; - }" - HAS_SSE_EXTENSIONS) - - set(CMAKE_REQUIRED_FLAGS) - - if(HAS_SSE2_EXTENSIONS) - message(STATUS "Using SSE2 extensions") - set(SSE_FLAGS "-msse2 -mfpmath=sse") - elseif(HAS_SSE_EXTENSIONS) - message(STATUS "Using SSE extensions") - set(SSE_FLAGS "-msse -mfpmath=sse") - endif() - - add_definitions(${SSE_FLAGS}) -elseif(MSVC) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - message(STATUS "Not using SSE2 extensions on x64") - else() - check_cxx_source_runs(" - #include <emmintrin.h> - - int main() - { - __m128d a, b; - double vals[2] = {0}; - a = _mm_loadu_pd(vals); - b = _mm_add_pd(a,a); - _mm_storeu_pd(vals,b); - return 0; - }" - HAS_SSE2_EXTENSIONS) - - if( HAS_SSE2_EXTENSIONS ) - message(STATUS "Using SSE2 extensions") - add_definitions( "/arch:SSE2 /fp:fast -D__SSE__ -D__SSE2__" ) - endif() - endif() + # target_link_libraries(otbsiftfast m stdc++) + target_link_libraries(otbsiftfast m) endif() -#set(Boost_ADDITIONAL_VERSIONS "1.40" "1.39" "1.38" "1.37.0" "1.37" "1.35.0" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") -#if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) -# set(Boost_INCLUDE_DIR $ENV{BOOST_INCLUDEDIR}) -#endif() -#if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) -# set(Boost_LIBRARY_DIRS $ENV{BOOST_LIBRARYDIR}) -#endif() -#find_package(Boost COMPONENTS python) - -#if( Boost_FOUND ) -# message(STATUS "found boost version: ${Boost_VERSION}") -#else() -# message(STATUS "Could not find boost libraries!") -#endif() -add_library(otbsiftfast libsiftfast.cpp) +if(IS_X86_64) + set_target_properties(otbsiftfast + PROPERTIES COMPILE_FLAGS "-D__x86_64__") +endif() -if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) -# target_link_libraries(otbsiftfast m stdc++) - target_link_libraries(otbsiftfast m) +#set_source_files_properties(<file> PROPERTIES COMPILE_FLAGS <flags>) + +if(OTB_DISABLE_FAST_FUNCTIONS_VALUE) + set_target_properties(otbsiftfast + PROPERTIES COMPILE_FLAGS "-DOTB_DISABLE_FAST_FUNCTIONS") endif() #set_target_properties(otbsiftfast PROPERTIES OUTPUT_NAME siftfast CLEAN_DIRECT_OUTPUT 1) @@ -195,20 +101,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) #set_target_properties(siftfast PROPERTIES COMPILE_FLAGS "-DDVPROFILE") #target_link_libraries(siftfast libsiftfast) -# check for OpenMP -find_package(OpenMP) -if(OPENMP_FOUND) - message(STATUS "Enabling OpenMP support") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") -else() - message(STATUS "Disabling OpenMP support") -endif() - #Install TARGET & FILES for otb-lib if(OTB_LIBRARY_PROPERTIES) - set_target_properties(otbsiftfast PROPERTIES ${OTB_LIBRARY_PROPERTIES}) + set_target_properties(otbsiftfast PROPERTIES ${OTB_LIBRARY_PROPERTIES}) endif() install(TARGETS otbsiftfast diff --git a/Modules/ThirdParty/TIFF/CMakeLists.txt b/Modules/ThirdParty/TIFF/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d3cb2a3a7b53cb2896ad1509c90e7f3195305398 --- /dev/null +++ b/Modules/ThirdParty/TIFF/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +project(OTBTIFF) + +set(OTBTIFF_SYSTEM_INCLUDE_DIRS ${TIFF_INCLUDE_DIRS}) +set(OTBTIFF_LIBRARIES "${TIFF_LIBRARIES}") + +otb_module_impl() diff --git a/Modules/ThirdParty/TIFF/otb-module-init.cmake b/Modules/ThirdParty/TIFF/otb-module-init.cmake new file mode 100644 index 0000000000000000000000000000000000000000..93a99b67b9e593352f69510e69a97e91fc4abf46 --- /dev/null +++ b/Modules/ThirdParty/TIFF/otb-module-init.cmake @@ -0,0 +1,21 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +find_package ( TIFF REQUIRED ) diff --git a/Modules/ThirdParty/TIFF/otb-module.cmake b/Modules/ThirdParty/TIFF/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a0662801804720735275fc8ef276decf750e5035 --- /dev/null +++ b/Modules/ThirdParty/TIFF/otb-module.cmake @@ -0,0 +1,32 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +set(DOCUMENTATION "This module imports TIFF to the build system") + +otb_module(OTBTIFF + DEPENDS + + TEST_DEPENDS + + DESCRIPTION + "${DOCUMENTATION}" + + EXCLUDE_FROM_DEFAULT + ) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 3d944f931ca7f268d8b0b07389f97bf5cf289af6..aa0cdd076ad93109e8acd054fc920c4a3892304e 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -167,7 +167,7 @@ public: /* Get the internal application parameter specified * * WARNING: this method may disappear from the API */ - const Parameter* GetParameterByKey(std::string parameter) const; + const Parameter* GetParameterByKey(std::string parameter, bool follow=true) const; /* Returns the description of a parameter */ std::string GetParameterName(std::string paramKey); @@ -284,8 +284,21 @@ public: void SetParameterEmpty(std::string parameter, bool value, bool hasUserValueFlag = true); + /** Checks if the application is ready to be executed. It checks that there + * is no parameter missing + */ bool IsApplicationReady(); + /** Checks if a parameter 'key' is missing. + * + * A parameter is missing when all the following conditions are true : + * - the parameter is mandatory + * - the parameter has Role_Input + * - the parameter is not a group + * - the parameter has no value + * - the parameter ancestors are mandatory or enabled. + */ + bool IsParameterMissing(const std::string &key) const; /* Set an default integer value, must used in the * DoInit when setting a value by default @@ -695,7 +708,10 @@ public: */ ComplexImagePixelType GetParameterComplexOutputImagePixelType(std::string parameter); - otb::Logger* GetLogger(); + otb::Logger* GetLogger() const; + + /** Sets the logger instance of the application (use with caution) */ + void SetLogger(otb::Logger *logger); itk::ProcessObject* GetProgressSource() const; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h index 3dae3b16346ec255054ddf14c6d5cfc711fe7215..859e6a81e733f238b81e51a80bf8bf665d72d653 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperCompositeApplication.h @@ -149,10 +149,6 @@ private: InternalAppContainer m_AppContainer; - itk::StdStreamLogOutput::Pointer m_LogOutput; - - std::ostringstream m_Oss; - AddProcessCommandType::Pointer m_AddProcessCommand; }; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 7a7b45bb34e6b7b329b8ce174bd916d9a2f24c4d..178a8d55608661aa4253607f272cd54b5bddb6ad 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -36,6 +36,7 @@ #include "otbWrapperInputProcessXMLParameter.h" #include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" +#include "otbWrapperParameterKey.h" #include "otbWrapperAddProcessToWatchEvent.h" @@ -74,11 +75,19 @@ Application::~Application() { } -otb::Logger* Application::GetLogger() +otb::Logger* Application::GetLogger() const { return m_Logger; } +void Application::SetLogger(otb::Logger *logger) +{ + if (m_Logger != logger) + { + m_Logger = logger; + } +} + std::vector<std::string> Application::GetParametersKeys(bool recursive) { @@ -297,11 +306,11 @@ void Application::SetParameterUserValue(std::string paramKey, bool value) GetParameterByKey(paramKey)->SetUserValue(value); } -const Parameter* Application::GetParameterByKey(std::string name) const +const Parameter* Application::GetParameterByKey(std::string name, bool follow) const { // GetParameterList is non const... Application* _this = const_cast<Application*>(this); - return _this->GetParameterByKey(name); + return _this->GetParameterByKey(name,follow); } void Application::Init() @@ -1599,57 +1608,50 @@ Application::IsApplicationReady() it != paramList.end(); ++it) { - // Check all Input Parameters with Input Role - if (GetParameterByKey(*it)->GetRole() == Role_Input) + // Check all parameters + if (IsParameterMissing(*it)) { - // When a parameter is mandatory : - // return false when does not have value and: - // - The param is root - // - The param is not root and belonging to a Mandatory Group - // which is activated - if ( !this->HasValue(*it) && IsMandatory(*it) ) - { - if( GetParameterByKey(*it)->IsRoot() ) - { - otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Root)"); - return false; - } - else - { - // check if the parameter is linked to a root parameter with a chain of active parameters - Parameter* currentParam = GetParameterByKey(*it)->GetRoot(); - if (currentParam->IsRoot()) - { - otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Level 1)"); - return false; - } - - int level = 1; - - while (!currentParam->IsRoot()) - { - if (!currentParam->GetActive()) - { - // the missing parameter is not on an active branch : we can ignore it - break; - } - currentParam = currentParam->GetRoot(); - - level++; + ready = false; + break; + } + } + return ready; +} - if (currentParam->IsRoot()) - { - // the missing parameter is on an active branch : we need it - otbDebugMacro("MISSING : "<< (*it).c_str() << " ( Is Level "<< level<<")"); - return false; - } - } - } +bool +Application::IsParameterMissing(const std::string &key) const +{ + bool ret(false); + const Parameter* param = GetParameterByKey(key); + if (param->GetRole() == Role_Input && + GetParameterType(key) != ParameterType_Group && + param->GetMandatory() && + !param->HasValue()) + { + ret = true; + ParameterKey paramKey(key); + std::vector<std::string> split = paramKey.Split(); + std::string currentRoot(key); + unsigned int level = 1; + while (level < split.size()) + { + currentRoot.resize(currentRoot.find_last_of(".")); + param = GetParameterByKey(currentRoot); + if (!param->GetActive() && !param->GetMandatory()) + { + // the missing parameter is not on an active branch : we can ignore it + ret = false; + break; } + level++; + } + if (ret) + { + // the missing parameter is on an active branch : we need it + otbDebugMacro("MISSING : "<< key << " (Level "<< split.size()<<")"); } } - - return ready; + return ret; } void diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx index 1ebb88d529cb5648416a466f98dc4a1dec8ec527..2f64625f58a08987b4db3c4940c8d1b978d2e3f6 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx @@ -44,7 +44,7 @@ ChoiceParameter::AddChoice( std::string choicekey, std::string choiceName ) choice.m_AssociatedParameter->SetName(choiceName); choice.m_AssociatedParameter->SetRoot(this); choice.m_AssociatedParameter->SetKey(choicekey); - + choice.m_AssociatedParameter->SetMandatory(false); m_ChoiceList.push_back(choice); // check if the new choice matches the m_CurrentChoice : if so the group should be active. diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx index 741bcb03974feef556c01fd1be194be907d3bf40..db216594f54992949895a4158aadc5e3137f15eb 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperCompositeApplication.cxx @@ -32,8 +32,6 @@ namespace Wrapper CompositeApplication::CompositeApplication() { - m_LogOutput = itk::StdStreamLogOutput::New(); - m_LogOutput->SetStream(m_Oss); m_AddProcessCommand = AddProcessCommandType::New(); m_AddProcessCommand->SetCallbackFunction(this, &CompositeApplication::LinkWatchers); } @@ -65,8 +63,7 @@ CompositeApplication container.App = ApplicationRegistry::CreateApplication(appType); container.Desc = desc; // Setup logger - container.App->GetLogger()->AddLogOutput(m_LogOutput); - container.App->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); + container.App->SetLogger(this->GetLogger()); container.App->AddObserver(AddProcessToWatchEvent(), m_AddProcessCommand.GetPointer()); m_AppContainer[key] = container; return true; @@ -179,40 +176,14 @@ CompositeApplication ::ExecuteInternal(std::string key) { otbAppLogINFO(<< GetInternalAppDescription(key) <<"..."); - try - { - GetInternalApplication(key)->Execute(); - } - catch(...) - { - this->GetLogger()->Write( itk::LoggerBase::FATAL, std::string("\n") + m_Oss.str() ); - throw; - } - if(!m_Oss.str().empty()) - { - otbAppLogINFO(<< "\n" << m_Oss.str()); - m_Oss.str(std::string("")); - } + GetInternalApplication(key)->Execute(); } void CompositeApplication ::UpdateInternalParameters(std::string key) { - try - { - GetInternalApplication(key)->UpdateParameters(); - } - catch(...) - { - this->GetLogger()->Write( itk::LoggerBase::FATAL, std::string("\n") + m_Oss.str() ); - throw; - } - if(!m_Oss.str().empty()) - { - otbAppLogINFO(<< "\n" << m_Oss.str()); - m_Oss.str(std::string("")); - } + GetInternalApplication(key)->UpdateParameters(); } } // end namespace Wrapper diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index 686d4d58cf65f248024accc8ad306cda13d73e4a..736ad395b5255f46e4ff29d725bbeb64f38f5e36 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -582,99 +582,23 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() for (unsigned int i = 0; i < appKeyList.size(); i++) { const std::string paramKey(appKeyList[i]); - Parameter::Pointer param = m_Application->GetParameterByKey(paramKey); ParameterType type = m_Application->GetParameterType(paramKey); - const bool paramExists(m_Parser->IsAttributExists(std::string("-").append(paramKey), m_VExpression)); - std::vector<std::string> values; - - // When a parameter is mandatory : - // it must be set if : - // - The param is root - // - The param is not root and belonging to a Mandatory Group - // which is activated - bool mustBeSet = false; - const bool hasValue = m_Application->HasValue(paramKey); - - //skip if mandatory parameters are missing because we have it already in XML - if(!paramInXMLExists) - { - if( param->GetMandatory() == true && param->GetRole() != Role_Output && type != ParameterType_Group) - { - // check if the parameter is linked to a root parameter with a chain of active parameters - if( param->IsRoot() || param->GetRoot()->IsRoot()) - { - // the parameter is a root or inside a group at root level - mustBeSet = true; - } - else - { - Parameter* currentParam = param->GetRoot(); - while (!currentParam->IsRoot()) - { - if (!currentParam->GetActive()) - { - // the missing parameter is not on an active branch : we can ignore it - break; - } - currentParam = currentParam->GetRoot(); - - if (currentParam->IsRoot()) - { - // the missing parameter is on an active branch : we need it - mustBeSet = true; - } - } - } - } - } - - if( mustBeSet ) - { - if (!paramExists) - { - // If key doesn't exist and parameter hasn't default value set... - if (!hasValue) - { - std::cerr << "ERROR: Missing mandatory parameter -" << paramKey << "." << std::endl; - return MISSINGMANDATORYPARAMETER; - } - } - else - { - values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_VExpression); - if (values.size() == 0 && !m_Application->HasValue(paramKey)) - { - std::cerr << "ERROR: Missing mandatory parameter -" << paramKey << "." << std::endl; - return MISSINGPARAMETERVALUE; - } - } - } - // Check if non mandatory parameter have values - else + if (m_Application->IsParameterMissing(paramKey)) { - if( paramExists ) - { - values = m_Parser->GetAttribut(std::string("-").append(paramKey), m_VExpression); - if (values.size() == 0) - { - std::cerr << "ERROR: Missing non-mandatory parameter -" << paramKey << "." << std::endl; - return MISSINGPARAMETERVALUE; - } - } + std::cerr << "ERROR: Missing mandatory parameter -" << paramKey << "." << std::endl; + return MISSINGMANDATORYPARAMETER; } // Check output paths validity - if (hasValue) + if (m_Application->HasValue(paramKey) && + type == ParameterType_OutputFilename) { - if (type == ParameterType_OutputFilename) + std::string filename = m_Application->GetParameterString(paramKey); + itksys::String path = itksys::SystemTools::GetFilenamePath(filename); + if (path!="" && !itksys::SystemTools::FileIsDirectory(path.c_str())) { - std::string filename = m_Application->GetParameterString(paramKey); - itksys::String path = itksys::SystemTools::GetFilenamePath(filename); - if (path!="" && !itksys::SystemTools::FileIsDirectory(path.c_str())) - { - std::cerr <<"ERROR: Directory doesn't exist : "<< path.c_str() << std::endl; - return WRONGPARAMETERVALUE; - } + std::cerr <<"ERROR: Directory doesn't exist : "<< path.c_str() << std::endl; + return WRONGPARAMETERVALUE; } } } @@ -813,47 +737,7 @@ std::string CommandLineLauncher::DisplayParameterHelp(const Parameter::Pointer & std::ostringstream oss; - // When a parameter is mandatory : - // it must be set if : - // - The param is root - // - The param is not root and belonging to a Mandatory Group - // which is activated - bool isMissing = false; - if (!m_Parser->IsAttributExists(std::string("-").append(paramKey), m_VExpression)) - { - if (!m_Application->HasValue(paramKey)) - { - if( param->GetMandatory() && param->GetRole() != Role_Output ) - { - if( param->IsRoot() || param->GetRoot()->IsRoot()) - { - // the parameter is a root or inside a group at root level - isMissing = true; - } - else - { - Parameter* currentParam = param->GetRoot(); - while (!currentParam->IsRoot()) - { - if (!currentParam->GetActive()) - { - // the missing parameter is not on an active branch : we can ignore it - break; - } - currentParam = currentParam->GetRoot(); - - if (currentParam->IsRoot()) - { - // the missing parameter is on an active branch : we need it - isMissing = true; - } - } - } - } - } - } - - if( isMissing ) + if( m_Application->IsParameterMissing(paramKey) ) { oss << "MISSING "; } diff --git a/Packaging/CMakeLists.txt b/Packaging/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..55dee29e7d807e4ddffe3e60d5a5a85bcdeba706 --- /dev/null +++ b/Packaging/CMakeLists.txt @@ -0,0 +1,239 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +cmake_minimum_required(VERSION 3.3.0) + +project(OTBPackaging) + +include(CMakeParseArguments) +include(CMakeDetermineSystem) +include(GetPrerequisites) +include(CTest) + +#setting this variable prints a lot of debug information +set(PKG_DEBUG OFF) +#set( PKG_DEBUG 1) + +set(CMAKE_BUILD_TYPE Release) + +#user-defined variables and option +option(OTB_WRAP_PYTHON "include python bindings in package" ON) +set(SUPERBUILD_BINARY_DIR "" CACHE PATH "path to superbuild binary directory") +set(SUPERBUILD_INSTALL_DIR "" CACHE PATH "path to superbuild install directory") +set(DOWNLOAD_LOCATION "" CACHE PATH "path to superbuild download archives") + +#variables based on above user-defined variables +set(OTB_BINARY_DIR "${SUPERBUILD_BINARY_DIR}/OTB/build") +set(QT_TRANSLATIONS_DIR "${SUPERBUILD_INSTALL_DIR}/translations") +get_filename_component(PACKAGE_OTB_SRC_DIR ${OTBPackaging_SOURCE_DIR} PATH) +set(SUPERBUILD_SOURCE_DIR "${PACKAGE_OTB_SRC_DIR}/SuperBuild") + + +set(LINUX FALSE) +if( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(LINUX TRUE) +endif() + +if(OTB_WRAP_PYTHON AND NOT PYTHON_EXECUTABLE) + find_package(PythonInterp REQUIRED) +endif() + +find_program(FILE_COMMAND NAMES "file") +find_program(READLINK NAMES "readlink") +find_program(ZIP_EXECUTABLE NAMES 7z 7za) + +#install prefix is same as SUPERBUILD_INSTALL_DIR. could be changed later +set(CMAKE_INSTALL_PREFIX "${SUPERBUILD_INSTALL_DIR}") + +#set CMAKE_MODULE_PATH to be the current source directory. +# This will allow to include all cmake files without full path and .cmake extension! +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +#include superbuild_macro for get_version() +include(${SUPERBUILD_SOURCE_DIR}/CMake/SuperBuild_Macro.cmake) + +#include superbuild_macro for OTB_TARGET_SYSTEM_ARCH_IS_X64 value +include(${PACKAGE_OTB_SRC_DIR}/CMake/OTBCheckTargetSystemArch.cmake) + +# get itk version from External_itk.cmake if not on mingw +# because mxe has different version +get_version( + INPUT_FILE "${SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake" + MATCH_STRINGS "SB_ITK_VERSION_MAJOR" "SB_ITK_VERSION_MINOR" + PREFIX PKG + ) +set(PKG_ITK_SB_VERSION "${PKG_SB_ITK_VERSION_MAJOR}.${PKG_SB_ITK_VERSION_MINOR}") + +#get version of OTB from source_dir/CMakeLists.txt +get_version( + INPUT_FILE "${PACKAGE_OTB_SRC_DIR}/CMakeLists.txt" + MATCH_STRINGS "OTB_VERSION_MAJOR" "OTB_VERSION_MINOR" "OTB_VERSION_PATCH" + PREFIX PKG + ) + +set(PKG_OTB_VERSION_STRING ${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}.${PKG_OTB_VERSION_PATCH}) + +set(PACKAGE_LONG_NAME OrfeoToolBox) +set(NAME_SUFFIX "" CACHE STRING "extra suffix for package name") +set(PACKAGE_NAME OTB) +if(NAME_SUFFIX) + set(PACKAGE_NAME OTB${NAME_SUFFIX}) +endif() +if(APPLE) + set(PACKAGE_PLATFORM_NAME "Darwin") +elseif(WIN32) + set(PACKAGE_PLATFORM_NAME "win") +elseif(LINUX) + set(PACKAGE_PLATFORM_NAME "Linux") +endif() +set(PACKAGE_ARCH "32") +if(OTB_TARGET_SYSTEM_ARCH_IS_X64) +set(PACKAGE_ARCH "64") +endif() + +# This directory is important. +# We stage/keep files that goes into final package in this directory +set(PKG_STAGE_DIR ${PACKAGE_NAME}-${PKG_OTB_VERSION_STRING}-${PACKAGE_PLATFORM_NAME}${PACKAGE_ARCH}) + +set(PATCHELF_PROGRAM "${CMAKE_BINARY_DIR}/PATCHELF/src/patchelf/src/patchelf") +include(External_patchelf) + +include(PackageGlobals) + +# Note that MANY or ALL of function use global variables set in this CMakeLists.txt +# The order in which the functions in these "included" files are called is only important. +# We tried not to share variables which are created inside functions or macro. In such cases, +# function return the value. + +include(setif_value_in_list) +include(get_variables_ending_with) +include(clear_cmakecache_variables) +include(check_cmake_variables) +include(configure_loader) +include(search_library) +include(prepare_search_dirs) +include(prepare_file_list) +include(process_file_recurse) +include(install_without_message) +include(install_rule) +include(isfile_symlink) +include(detect_using_file_command) +include(install_otbapp_wrapper_scripts) +include(cleanup_package) + +# below functions include many install commands which are installing +# files under PKG_STAGE_DIR +include(install_include_dirs) +include(install_importlibs) +include(install_python_bindings) +include(install_share_dirs) +include(install_cmake_files) +include(install_qtdev_files) +include(install_vstudio_files) +include(installer_files) +include(create_package) + +configure_loader(LOADER_PROGRAM LOADER_ARGS LOADER_REGEX) + + +# creation of package is different from windows and unix like +# WE KEEP THIS VARIABLE HERE BECAUSE IT IS USED IN +# cleanup_package, create_package, testing.cmake +# and check_cmake_variables + +# THIS IS JUST TO AVOID DUPLICATION +if(WIN32) + set(PACKAGE_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PKG_STAGE_DIR}.zip") +else() + set(PACKAGE_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PKG_STAGE_DIR}.run") +endif() + +check_cmake_variables() + +cleanup_package() + +set(HAVE_QT4 FALSE CACHE INTERNAL "HAVE_QT4") +if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/otbApplicationLauncherQt${EXE_EXT}") + set(HAVE_QT4 TRUE) +endif() + +set(HAVE_MVD FALSE CACHE INTERNAL "HAVE_MVD") +if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/monteverdi${EXE_EXT}") + set(HAVE_MVD TRUE) +endif() + +set(HAVE_PYTHON FALSE CACHE INTERNAL "HAVE_PYTHON") +if(EXISTS "${SUPERBUILD_INSTALL_DIR}/lib/otb/python/_otbApplication${PYMODULE_EXT}") + set(HAVE_PYTHON TRUE) +endif() + + #only for *nix +if(UNIX) + file(WRITE ${CMAKE_BINARY_DIR}/make_symlinks "#!/bin/sh\n") +endif() + +#remove all *_USED|*_RESOLVED variables from CMakeCache.txt +clear_cmakecache_variables() + +set(PKG_SEARCHDIRS) +prepare_search_dirs(PKG_SEARCHDIRS) + +set(PKG_PEFILES) +prepare_file_list(PKG_PEFILES) +foreach(pfile ${PKG_PEFILES}) + get_filename_component(pfile_name ${pfile} NAME) + process_file_recurse(${pfile_name}) +endforeach() + +install_include_dirs() + +install_importlibs() + +install_python_bindings() + +install_share_dirs() + +install_cmake_files() + +install_qtdev_files() + +install_vstudio_files() + +installer_files() + +create_package() + +if(BUILD_TESTING) + enable_testing() + include(testing.cmake) +endif() + + + + +#TODO: dummy targets. to be removed after merge +add_custom_target( + PACKAGE-OTB + COMMAND + "${CMAKE_COMMAND}" --build . --target install + WORKING_DIRECTORY + "${CMAKE_BINARY_DIR}" + COMMENT "dummy target PACKAGE-OTB" + ) diff --git a/Packaging/CTestConfig.cmake b/Packaging/CTestConfig.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ac2fbdca4ec3cd622a46eceef0b8fad5c9125b87 --- /dev/null +++ b/Packaging/CTestConfig.cmake @@ -0,0 +1,28 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +set(CTEST_PROJECT_NAME "OTB") +set(CTEST_NIGHTLY_START_TIME "20:00:00 CEST") +set(CTEST_DROP_METHOD "https") +set(CTEST_DROP_SITE "dash.orfeo-toolbox.org") +set(CTEST_DROP_LOCATION "/submit.php?project=OTB") +set(CTEST_DROP_SITE_CDASH TRUE) +set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 4096) +set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 4096) diff --git a/Packaging/External_patchelf.cmake b/Packaging/External_patchelf.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d16876373c11f65d6763faa0836171da2539db11 --- /dev/null +++ b/Packaging/External_patchelf.cmake @@ -0,0 +1,61 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +set(PATCHELF_PREFIX_DIR "${CMAKE_BINARY_DIR}/PATCHELF") +set(PATCHELF_SOURCE_DIR "${PATCHELF_PREFIX_DIR}/src/patchelf") +# PATCHELF_BINARY_DIR is same as PATCHELF_SOURCE_DIR +set(PATCHELF_INSTALL_DIR "${PATCHELF_PREFIX_DIR}/install/patchelf") +set(PATCHELF_STAMP_DIR "${PATCHELF_PREFIX_DIR}/stamp/patchelf") +set(PATCHELF_TMP_DIR "${PATCHELF_PREFIX_DIR}/tmp/patchelf") + +if( __EXTERNAL_PATCHELF__) + return() +else() + set(__EXTERNAL_PATCHELF__ 1) +endif() + +if(WIN32 OR APPLE) + add_custom_target(PATCHELF) + return() +endif() + +include(ExternalProject) + +set(PATCHELF_ENV_COMMAND env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=-static) + +ExternalProject_Add(PATCHELF + PREFIX "${PATCHELF_PREFIX_DIR}" + URL "http://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2" + URL_MD5 d02687629c7e1698a486a93a0d607947 + DOWNLOAD_DIR "${DOWNLOAD_LOCATION}" + SOURCE_DIR "${PATCHELF_SOURCE_DIR}" + BINARY_DIR "${PATCHELF_SOURCE_DIR}" + INSTALL_DIR "${PATCHELF_INSTALL_DIR}" + STAMP_DIR "${PATCHELF_STAMP_DIR}" + TMP_DIR "${PATCHELF_TMP_DIR}" + CONFIGURE_COMMAND + ${PATCHELF_ENV_COMMAND} + ${PATCHELF_SOURCE_DIR}/configure + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + ) + diff --git a/SuperBuild/Packaging/Files/Monteverdi.icns b/Packaging/Files/Monteverdi.icns similarity index 100% rename from SuperBuild/Packaging/Files/Monteverdi.icns rename to Packaging/Files/Monteverdi.icns diff --git a/Packaging/Files/OTB Project.zip b/Packaging/Files/OTB Project.zip new file mode 100644 index 0000000000000000000000000000000000000000..5e5b6d607f59e48ffd1afbe7f624ee9af245d8cf Binary files /dev/null and b/Packaging/Files/OTB Project.zip differ diff --git a/Packaging/Files/build_examples.cmake b/Packaging/Files/build_examples.cmake new file mode 100644 index 0000000000000000000000000000000000000000..46404dd2949cc1853f0ffc19f227b6ef7b466263 --- /dev/null +++ b/Packaging/Files/build_examples.cmake @@ -0,0 +1,97 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +if(NOT SRC_DIR) + message(FATAL_ERROR "SRC_DIR is not set") +endif() + +set(PKG_DIR) +get_filename_component(PKG_DIR ${CMAKE_CURRENT_LIST_DIR} PATH) +set(TEST_DIR ${PKG_DIR}/ex_build) + +if(EXISTS "${TEST_DIR}") + execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}) +else() + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}) +endif() +message("TEST_DIR=${TEST_DIR}") +message("PKG_DIR=${PKG_DIR}") +message("SRC_DIR=${SRC_DIR}") + +set(cmake_gen) +if(WIN32) + set(cmake_gen "-GNinja") +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_INSTALL_PREFIX=${PKG_DIR} + -DCMAKE_BUILD_TYPE=RelWithDebInfo + ${cmake_gen} + ${SRC_DIR} + WORKING_DIRECTORY ${TEST_DIR} + RESULT_VARIABLE configure_rv + OUTPUT_VARIABLE configure_ov + ERROR_VARIABLE configure_ov + ) + +if( configure_rv ) + message(FATAL_ERROR "Configure FAILED. configure_ov:\n${configure_ov}") + return() +else() + message("Configure PASSED. configure_ov:\n${configure_ov}") +endif() + +# If you want to test building a third targert, use foreach. +# the code is written in a way that it is easy to stuff these two +# into a cmake foreach +execute_process(COMMAND ${CMAKE_COMMAND} + --build ${TEST_DIR} + --config RelWithDebInfo + --target HelloWorldOTB + WORKING_DIRECTORY ${TEST_DIR} + RESULT_VARIABLE build_HelloWorldOTB_rv + OUTPUT_VARIABLE build_HelloWorldOTB_ov + ERROR_VARIABLE build_HelloWorldOTB_ov + ) + +if( build_HelloWorldOTB_rv ) + message(FATAL_ERROR "Build FAILED. build_HelloWorldOTB_ov:\n${build_HelloWorldOTB_ov}") + return() +else() + message("Build PASSED. build_HelloWorldOTB_ov:\n${build_HelloWorldOTB_ov}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} + --build ${TEST_DIR} + --config RelWithDebInfo + --target Pipeline + WORKING_DIRECTORY ${TEST_DIR} + RESULT_VARIABLE build_Pipeline_rv + OUTPUT_VARIABLE build_Pipeline_ov + ERROR_VARIABLE build_Pipeline_ov + ) + +if( build_Pipeline_rv ) + message(FATAL_ERROR "Build FAILED. build_Pipeline_ov=${build_Pipeline_ov}") + return() +else() + message("Build PASSED. build_Pipeline_ov=${build_Pipeline_ov}") +endif() diff --git a/Packaging/Files/linux_pkgsetup.in b/Packaging/Files/linux_pkgsetup.in new file mode 100644 index 0000000000000000000000000000000000000000..6c56a3b976e7a54cb041a244b4f917ff073ef125 --- /dev/null +++ b/Packaging/Files/linux_pkgsetup.in @@ -0,0 +1,89 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +set -e + +DIRNAME_0=$(dirname "$0") +cd "$DIRNAME_0" + +# NOTE: $OUT_DIR is also used in make_sylinks script (see below) +# Avoid any pre-mature optimization on variable names here. + +OUT_DIR=$(pwd) + +PATCH_ELF_EXE="$OUT_DIR/patchelf" + +#do not move below block. it must be before "unset LD_LIBRARY_PATH" code +#check if we have any python bindings +set OTB_PYTHON_LIB_PATH= +if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ] ; then + sed -i "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/setup_python.sh" + chmod +x $OUT_DIR/setup_python.sh + . ./setup_python.sh + set OTB_PYTHON_LIB_PATH=$OUT_DIR/lib/python +fi + +# No no interference with LD_LIBRARY_PATH +unset LD_LIBRARY_PATH + +#RK: We cannot avoid -maxdepth 1 option in find command below because, +# there are files in $OUT_DIR/lib/gtk which we CANNOT add new rpath +BINARY_FILES=$(find $OTB_PYTHON_LIB_PATH $OUT_DIR/lib $OUT_DIR/bin $OUT_DIR/lib/otb/applications -maxdepth 1 -type f -exec file {} \; | grep -i elf|cut -f1 -d':') +# run patchelf +for bin_file in $BINARY_FILES; do + #echo "adding rpath to $bin_file" + if [ -f "$bin_file" ]; then + "$PATCH_ELF_EXE" "--set-rpath" "$OUT_DIR/lib" "$bin_file" + fi +done + +#install uninstall_otb script +echo "Installing uninstall script for OTB 'tools/uninstall_otb.sh'" +sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/tools/uninstall_otb.sh" +chmod +x "$OUT_DIR/tools/uninstall_otb.sh" + +sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/monteverdi.sh" +chmod +x "$OUT_DIR/monteverdi.sh" + +sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/mapla.sh" +chmod +x "$OUT_DIR/mapla.sh" + +sed -i -E "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/otbenv.profile" +chmod +x "$OUT_DIR/otbenv.profile" + +sed -i -E "s,../lib,$OUT_DIR/lib,g" "$OUT_DIR/bin/qt.conf" + +#echo "Creating symbolic links..." +. ./make_symlinks + +rm -f "$OUT_DIR/make_symlinks" + +printf %s\\n "" +printf %s\\n "source './otbenv.profile' file to set required environment variables" +printf %s\\n "eg: '. $OUT_DIR/otbenv.profile'" +printf %s\\n "You can also copy above line to ~/.profile to keep changes permanently!" +printf %s\\n "More documentation can be found in $OUT_DIR/README" + + +#rm -f "$OUT_DIR/make_symlinks" +rm -f "$OUT_DIR/patchelf" +rm -f "$OUT_DIR/setup_python.sh" +rm -f "$OUT_DIR/pkgsetup" + diff --git a/Packaging/Files/macx_pkgsetup.in b/Packaging/Files/macx_pkgsetup.in new file mode 100755 index 0000000000000000000000000000000000000000..46606ffb164881b7afe4639c42cb1ff6ce3ab519 --- /dev/null +++ b/Packaging/Files/macx_pkgsetup.in @@ -0,0 +1,116 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +set -e + +DIRNAME_0=$(dirname "$0") +cd "$DIRNAME_0" || exit 1 + +# NOTE: $OUT_DIR is also used in make_sylinks script (see below) +# Avoid any pre-mature optimization on variable names here. + +OUT_DIR=$(pwd) + +#do not move below 3 lines. it must be before "unset LD_LIBRARY_PATH" code +sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/setup_python.sh" +chmod +x $OUT_DIR/setup_python.sh +./setup_python.sh + +# find install_name_tool +INSTALL_NAME_TOOL=$(which install_name_tool) +if [ -z "$INSTALL_NAME_TOOL" ]; then + echo "install_name_tool does not exists.." + echo "please install install_name_tool and make sure it can be found from PATH" + exit 1; +fi + +# no interference with DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH +unset DYLD_LIBRARY_PATH +unset DYLD_FALLBACK_LIBRARY_PATH + +echo "Configuring..." + +LIB_FILES=$(find "$OUT_DIR/lib" -type f -exec file {} \; | grep -i "Mach-O"|cut -d ':' -f1) +BIN_FILES=$(find "$OUT_DIR/bin" -type f -exec file {} \; | grep -i "Mach-O*.*executable"|cut -d ':' -f1) +# run install_name_tool +for input_file in $LIB_FILES $BIN_FILES; do + #echo "adding rpath to $OUT_DIR/$lib_file" + if [ -f "$input_file" ]; then + input_file_old_rpaths=$(otool -l "$input_file" | grep -A 3 "LC_RPATH" | grep -oE 'path .* \(offset' | cut -d ' ' -f 2) + for rpath_old in $input_file_old_rpaths; do + $INSTALL_NAME_TOOL "-delete_rpath" "$rpath_old" "$input_file" + done + $INSTALL_NAME_TOOL "-add_rpath" "$OUT_DIR/lib" "$input_file" + fi +done + +#install uninstall_otb script +echo "Installing uninstall script for OTB 'tools/uninstall_otb.sh'" +sed -i "" "s,mapla.sh,Mapla.app -r,g" "$OUT_DIR/tools/uninstall_otb.sh" +sed -i "" "s,monteverdi.sh,Monteverdi.app -r,g" "$OUT_DIR/tools/uninstall_otb.sh" +sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/tools/uninstall_otb.sh" +chmod +x "$OUT_DIR/tools/uninstall_otb.sh" + +mkdir "$OUT_DIR/template.app/Contents/MacOS" +mkdir "$OUT_DIR/template.app/Contents/Resources" +cp -r "$OUT_DIR/template.app" "$OUT_DIR/Mapla.app" +cp -r "$OUT_DIR/template.app" "$OUT_DIR/Monteverdi.app" +mv "$OUT_DIR/mapla.sh" "Mapla.app/Contents/MacOS/Mapla" +mv "$OUT_DIR/monteverdi.sh" "Monteverdi.app/Contents/MacOS/Monteverdi" +rm -fr "template.app" +LONG_VERSION_STRING=@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@.@Monteverdi_VERSION_PATCH@ +SHORT_VERSION_STRING=@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@ +#sed qt.conf +sed -i "" "s,../lib,$OUT_DIR/lib,g" "$OUT_DIR/bin/qt.conf" + +cp "$OUT_DIR/bin/qt.conf" "$OUT_DIR/Mapla.app/Contents/Resources/qt.conf" +cp "$OUT_DIR/Monteverdi.icns" "Mapla.app/Contents/Resources/" +sed -i "" "s,STARTUP_FILE,Mapla,g" "Mapla.app/Contents/Info.plist" +sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Mapla.app/Contents/Info.plist" +sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Mapla.app/Contents/Info.plist" +sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla" +chmod +x "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla" + +cp "$OUT_DIR/bin/qt.conf" "$OUT_DIR/Monteverdi.app/Contents/Resources/qt.conf" +cp "$OUT_DIR/Monteverdi.icns" "Monteverdi.app/Contents/Resources/" +sed -i "" "s,STARTUP_FILE,Monteverdi,g" "Monteverdi.app/Contents/Info.plist" +sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist" +sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist" +sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi" +chmod +x "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi" + +sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/otbenv.profile" +chmod +x "$OUT_DIR/otbenv.profile" + +printf %s\\n "" +printf %s\\n "source './otbenv.profile' file to set required environment variables" +printf %s\\n "eg: '. $OUT_DIR/otbenv.profile'" +printf %s\\n "You can also copy above line to ~/.profile to keep changes permanently!" +printf %s\\n "More documentation can be found in $OUT_DIR/README" + + +# echo "Creating symbolic links..." +. "./make_symlinks" +rm -f "$OUT_DIR/make_symlinks" +rm -f "$OUT_DIR/setup_python.sh" +rm -f "$OUT_DIR/Monteverdi.icns" +rm -f "$OUT_DIR/pkgsetup" + +#open "$OUT_DIR" diff --git a/Packaging/Files/mapla.bat b/Packaging/Files/mapla.bat new file mode 100644 index 0000000000000000000000000000000000000000..1823697e43c9035a7fc7ccc80ae58da9f25bbc6b --- /dev/null +++ b/Packaging/Files/mapla.bat @@ -0,0 +1,38 @@ +:: +:: Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +:: +:: This file is part of Orfeo Toolbox +:: +:: https://www.orfeo-toolbox.org/ +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: 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. + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Mapla launcher to set up proper environment +::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +@echo off +setlocal + +:: Get the directory of the current script +set CURRENT_SCRIPT_DIR=%~dp0 + +:: Setup environment +call "%CURRENT_SCRIPT_DIR%otbenv.bat" + +:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access +cd %HOMEDRIVE%%HOMEPATH% + +:: Start Monteverdi +start "Monteverdi Application Launcher" /B "%CURRENT_SCRIPT_DIR%bin\mapla.exe" %* + +endlocal diff --git a/Packaging/Files/mapla.sh b/Packaging/Files/mapla.sh new file mode 100755 index 0000000000000000000000000000000000000000..1164c66963792953cd23e7079ff2820e8f702076 --- /dev/null +++ b/Packaging/Files/mapla.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +. OUT_DIR/otbenv.profile + +OUT_DIR/bin/mapla "$@" diff --git a/Packaging/Files/monteverdi.bat b/Packaging/Files/monteverdi.bat new file mode 100644 index 0000000000000000000000000000000000000000..4ffe60380efeae6730c5da3398c3b4bec8fbbbff --- /dev/null +++ b/Packaging/Files/monteverdi.bat @@ -0,0 +1,38 @@ +:: +:: Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +:: +:: This file is part of Orfeo Toolbox +:: +:: https://www.orfeo-toolbox.org/ +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: 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. + +::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: Monteverdi launcher to set up proper environment +::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +@echo off +setlocal + +:: Get the directory of the current script +set CURRENT_SCRIPT_DIR=%~dp0 + +:: Setup environment +call "%CURRENT_SCRIPT_DIR%otbenv.bat" + +:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access +cd %HOMEDRIVE%%HOMEPATH% + +:: Start Monteverdi +start "Monteverdi Viewer" /B "%CURRENT_SCRIPT_DIR%bin\monteverdi.exe" %* + +endlocal diff --git a/Packaging/Files/monteverdi.sh b/Packaging/Files/monteverdi.sh new file mode 100755 index 0000000000000000000000000000000000000000..6ba6a2c4e8044e40ff46206527053b7d7e598a39 --- /dev/null +++ b/Packaging/Files/monteverdi.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +. OUT_DIR/otbenv.profile + +OUT_DIR/bin/monteverdi "$@" diff --git a/SuperBuild/Packaging/Files/otb_loader.cxx b/Packaging/Files/otb_loader.cxx similarity index 100% rename from SuperBuild/Packaging/Files/otb_loader.cxx rename to Packaging/Files/otb_loader.cxx diff --git a/Packaging/Files/otbenv.bash b/Packaging/Files/otbenv.bash new file mode 100644 index 0000000000000000000000000000000000000000..50151f649790ef8855ce9158ae6de36ea211a2c0 --- /dev/null +++ b/Packaging/Files/otbenv.bash @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# 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 + +CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P)") + +unset LD_LIBRARY_PATH + +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 +GDAL_DRIVER_PATH="disable" +LC_NUMERIC=C + +export PATH +export GDAL_DATA +export GEOTIFF_CSV +export PYTHONPATH +export OTB_APPLICATION_PATH +export GDAL_DRIVER_PATH +export LC_NUMERIC diff --git a/Packaging/Files/otbenv.bat b/Packaging/Files/otbenv.bat new file mode 100644 index 0000000000000000000000000000000000000000..dbc42eea3155aa222d7143e16315302ca7e91a9a --- /dev/null +++ b/Packaging/Files/otbenv.bat @@ -0,0 +1,30 @@ +:: +:: Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +:: +:: This file is part of Orfeo Toolbox +:: +:: https://www.orfeo-toolbox.org/ +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: 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. + +:: Setup environment for OTB package +set CURRENT_SCRIPT_DIR=%~dp0 + +set PATH=%CURRENT_SCRIPT_DIR%bin;%PATH% +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 diff --git a/Packaging/Files/otbenv.profile b/Packaging/Files/otbenv.profile new file mode 100644 index 0000000000000000000000000000000000000000..191121e411efbe133bd2a458e1fc2e9bd705e684 --- /dev/null +++ b/Packaging/Files/otbenv.profile @@ -0,0 +1,75 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# 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 + +# unset any existing LD_LIBRARY_PATH +unset LD_LIBRARY_PATH + +CMAKE_PREFIX_PATH=OUT_DIR +export CMAKE_PREFIX_PATH + + +# if OTB_USE_LOCAL_GTK is set to one, +# we must include ./lib/gtk because gtklibs are installed there. +# OTB_USE_LOCAL_GTK is not set by default (use GTK system) +#This code only affect linux system. for osx OUT_DIR/lib/gtk does not exists +if [ "$OTB_USE_LOCAL_GTK" = "1" ]; then + if [ -d "OUT_DIR/lib/gtk" ]; then + LD_LIBRARY_PATH=OUT_DIR/lib/gtk + export LD_LIBRARY_PATH + fi +fi + +# 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 + +# Add bin direcotory to system PATH +PATH=OUT_DIR/bin:$PATH + +# export PYTHONPATH to import otbApplication.py +PYTHONPATH=OUT_DIR/lib/python:$PYTHONPATH + +# set numeric locale to C +LC_NUMERIC=C + +# set GDAL_DATA variable used by otb application +GDAL_DATA=OUT_DIR/share/gdal + +export GDAL_DRIVER_PATH=disable + +# set GEOTIFF_CSV variable used by otb application +GEOTIFF_CSV=OUT_DIR/share/epsg_csv + +# export variables +export LC_NUMERIC +export GDAL_DATA +export GEOTIFF_CSV +export OTB_APPLICATION_PATH +export PATH +export PYTHONPATH + diff --git a/SuperBuild/Packaging/Files/qt.conf b/Packaging/Files/qt.conf similarity index 100% rename from SuperBuild/Packaging/Files/qt.conf rename to Packaging/Files/qt.conf diff --git a/SuperBuild/Packaging/Files/selftester.bat b/Packaging/Files/selftester.bat similarity index 65% rename from SuperBuild/Packaging/Files/selftester.bat rename to Packaging/Files/selftester.bat index 7aabc01e5e2fa305b032818ab51627dc5f48e7a3..756b3f793d5f2138a0774bc93ffba25798890879 100755 --- a/SuperBuild/Packaging/Files/selftester.bat +++ b/Packaging/Files/selftester.bat @@ -1,33 +1,59 @@ @echo off -setlocal +:: Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +:: +:: This file is part of Orfeo Toolbox +:: +:: https://www.orfeo-toolbox.org/ +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: 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. + +rem set EXIT_ON_ERROR=0 +rem set TEST_VERBOSE=1 +rem cmd /k tools\selftester.bat /q > selftest_report.log 2>&1 + +set MY_TOOLS_DIR=%~dp0 +cd %MY_TOOLS_DIR%.. +set MY_INSTALL_DIR=%cd% +echo "MY_INSTALL_DIR=%MY_INSTALL_DIR%" + +:: this is set in wrapper script +::set EXIT_ON_ERROR=0 +IF %EXIT_ON_ERROR%.==. ( set EXIT_ON_ERROR=1) +IF %TEST_VERBOSE%.==. ( set TEST_VERBOSE=1) -set CURRENT_SCRIPT_DIR=%~dp0 -set DIRNAME=%CURRENT_SCRIPT_DIR%.. -cd %DIRNAME% +echo TEST_VERBOSE=%TEST_VERBOSE% +echo EXIT_ON_ERROR=%EXIT_ON_ERROR% :: if "/q" is given, hide the error dialogs (hence make the script non-interactive) if /i not -%1-==-/q- ( goto :skip_hide_error ) -echo Hide error dialogs + + call :getDontShowUI if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 1 :skip_hide_error - +echo Hide error dialogs :: Get current PID type NUL > pid.log wmic PROCESS where "Name='WMIC.exe'" get ParentProcessId >pid.log 2>&1 for /F "TOKENS=1" %%b in ('type pid.log ^| findstr [0-9]') do set CURRENT_PID=%%b :: setup the otbenv -call otbenv.cmd +call otbenv.bat -del selftest_report.log -type NUL > selftest_report.log -call :nb_report_lines -set REF_SIZE=%nb_report_lines_out% :: ----------------------------------------------------------------------------------- -rem Check 1 : check binaries +REM Check 1 : check binaries for /R %%i in (*.dll) do ( call :check_binary %%i ) @@ -36,13 +62,6 @@ for %%i in (bin\mapla.exe,bin\monteverdi.exe,bin\otbApplicationLauncherCommandLi ) call :check_binary lib\python\_otbApplication.pyd -call :nb_report_lines -if %nb_report_lines_out% gtr %REF_SIZE% ( - echo Check 1/3 : FAIL -) else ( - echo Check 1/3 : PASS -) -set REF_SIZE=%nb_report_lines_out% :: ----------------------------------------------------------------------------------- rem Check 2 : check applications and Python wrapping set /a app_count=0 @@ -54,30 +73,17 @@ if %app_count% leq 90 ( ) call :check_python_wrapping -call :nb_report_lines -if %nb_report_lines_out% gtr %REF_SIZE% ( - echo Check 2/3 : FAIL -) else ( - echo Check 2/3 : PASS -) -set REF_SIZE=%nb_report_lines_out% :: ----------------------------------------------------------------------------------- rem Check 3 : check monteverdi & mapla call :check_desktop_app monteverdi call :check_desktop_app mapla 20 -call :nb_report_lines -if %nb_report_lines_out% gtr %REF_SIZE% ( - echo Check 3/3 : FAIL -) else ( - echo Check 3/3 : PASS -) - if /i not -%1-==-/q- ( goto :skip_restore_error ) if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 0 :skip_restore_error +setlocal del pid.log del tmp.log endlocal @@ -86,13 +92,14 @@ goto :eof ::########################[ FUNCTIONS ]################################## :check_binary setlocal +if %TEST_VERBOSE% gtr 1 ( echo ":check_binary %1" ) type NUL > tmp.log -bin\otb_loader.exe %1 > tmp.log 2>&1 +tools\otb_loader.exe %1 > tmp.log 2>&1 call :nb_tmp_lines if %nb_tmp_lines_out% gtr 0 ( - echo ERROR : otb_loader.exe %1 - echo otb_loader.exe %1 >> selftest_report.log - type tmp.log >> selftest_report.log + echo "ERROR: otb_loader.exe %1" + type tmp.log + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) ) endlocal goto :eof @@ -101,9 +108,10 @@ goto :eof setlocal set dll_path=%~n1 set app=%dll_path:~7% +if %TEST_VERBOSE% equ 1 ( echo ":check_application %app%" ) if not exist bin\otbcli_%app%.bat ( echo ERROR : missing cli launcher for application %app% - echo ERROR : missing cli launcher for application %app% >> selftest_report.log + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) goto :check_gui ) type NUL > tmp.log @@ -111,13 +119,14 @@ cmd /C bin\otbcli_%app%.bat "-help" ^> tmp.log ^2^>^&^1 call :parse_cli_output if %parse_cli_result% equ 0 ( echo ERROR : error launching application otbcli_%app% - echo ERROR : error launching application otbcli_%app% >> selftest_report.log - type tmp.log >> selftest_report.log -) + type results.txt + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) + ) + :check_gui if not exist bin\otbgui_%app%.bat ( echo ERROR : missing gui launcher for application %app% - echo ERROR : missing gui launcher for application %app% >> selftest_report.log + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) goto :check_application_end ) if %app_count% geq 2 goto :check_application_end @@ -130,20 +139,21 @@ if %child_pid% gtr 1 ( set first_child=%child_pid% ) else ( echo ERROR : could not launch otbgui_%app% - echo ERROR : could not launch otbgui_%app% >> selftest_report.log - type tmp.log >> selftest_report.log + type tmp.log goto :check_application_clean ) call :get_child_pid %first_child% otbApplicationLauncherQt.exe if not %child_pid% gtr 1 ( echo ERROR : could not launch otbApplicationLauncherQt %app% - echo ERROR : could not launch otbApplicationLauncherQt %app% >> selftest_report.log - type tmp.log >> selftest_report.log + type tmp.log + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) ) + :check_application_clean if not %first_child% == 0 ( taskkill /PID %first_child% /F /T > NUL 2>&1 ) + :check_application_end endlocal & set /a app_count=app_count+1 goto :eof @@ -161,8 +171,8 @@ if %child_pid% gtr 1 ( taskkill /PID %child_pid% /F /T > NUL 2>&1 ) else ( echo ERROR : could not launch %appName%.exe - echo ERROR : could not launch %appName%.exe >> selftest_report.log - type tmp.log >> selftest_report.log + type tmp.log + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) ) endlocal goto :eof @@ -174,8 +184,8 @@ python -c "import otbApplication" > tmp.log 2>&1 call :nb_tmp_lines if %nb_tmp_lines_out% gtr 0 ( echo ERROR : failed to run python wrapping - echo ERROR : failed to run python wrapping >> selftest_report.log - type tmp.log >> selftest_report.log + type tmp.log + if %EXIT_ON_ERROR% equ 1 ( exit 1 ) ) endlocal goto :eof @@ -183,39 +193,36 @@ goto :eof :parse_cli_output setlocal set /a ret=1 -for /F %%a in ('findstr /n /r /c:"^This is the %app% application, version " tmp.log') do set output=%%a -if not "%output%" gtr "1:" ( +findstr /n /r /c:"^This is the *.*(%app%) application, version " tmp.log > results.txt +if %errorlevel%==1 ( set /a ret=0 - goto :parse_cli_output_end + echo "findstr failed 1st regex in parse_cli_output" + goto :parse_cli_output_end ) -set output= -for /F %%a in ('findstr /n /r /c:"^Parameters:" tmp.log') do set output=%%a -if not "%output%" gtr "3:" ( +findstr /n /r /c:"^Parameters: " tmp.log > results.txt +if %errorlevel%==1 ( set /a ret=0 - goto :parse_cli_output_end + echo "findstr failed 2nd regex in parse_cli_output" + goto :parse_cli_output_end ) -set output= -for /F %%a in ('findstr /n /r /c:"^Examples:" tmp.log') do set output=%%a -if not "%output%" gtr "1" ( +findstr /n /r /c:"^Examples: " tmp.log > results.txt +if %errorlevel%==1 ( set /a ret=0 - goto :parse_cli_output_end + echo "findstr failed 3rd regex in parse_cli_output" + goto :parse_cli_output_end ) -set output= -for /F %%a in ('findstr /n /r /c:"FATAL" tmp.log') do set output=%%a -if "%output%" gtr "1" ( +findstr /n /r /c:"FATAL" tmp.log > results.txt +if %errorlevel%==0 ( set /a ret=0 - goto :parse_cli_output_end + echo "findstr passed 4th regex in parse_cli_output" + goto :parse_cli_output_end ) + :parse_cli_output_end endlocal & set /a parse_cli_result=%ret% goto :eof ::----------------------------------------------------------------------- -:nb_report_lines -setlocal -for /F "delims=" %%i in ('find /C /V "" ^< selftest_report.log') do set output=%%i -endlocal & set nb_report_lines_out=%output% -goto :eof -::----------------------------------------------------------------------- + :nb_tmp_lines setlocal for /F "delims=" %%i in ('find /C /V "" ^< tmp.log') do set output=%%i @@ -245,3 +252,4 @@ setlocal reg add "HKCU\Software\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d %1 /f endlocal goto :eof + diff --git a/SuperBuild/Packaging/Files/selftester.sh b/Packaging/Files/selftester.sh similarity index 70% rename from SuperBuild/Packaging/Files/selftester.sh rename to Packaging/Files/selftester.sh index 6cf5f86c2c59f7dfe1714e3dc0a8f71ef2491a4d..69d42e1304a79770bca9ffc2831ab3ac2d9be221 100755 --- a/SuperBuild/Packaging/Files/selftester.sh +++ b/Packaging/Files/selftester.sh @@ -1,9 +1,29 @@ #!/bin/sh - +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# # Setup test environment -DIRNAME_0=$(dirname "$0") -DIRNAME=$(readlink "$DIRNAME_0/..") -cd "$DIRNAME" || exit +CUR_DIR="$( cd "$( dirname "$0" )/../" && pwd )" +echo "CUR_DIR=$CUR_DIR" +cd "$CUR_DIR" || exit + +EXIT_ON_ERROR=1 # define convenient functions # ps_children( parentPID ) : get PIDs of children processes @@ -16,14 +36,23 @@ nb_report_lines () { report_lines="$(wc -l selftest_report.log)" echo $report_lines | cut -d ' ' -f 1 } +# + +exit_if () { + if [ $EXIT_ON_ERROR = 1 ]; then + echo "EXIT_ON_ERROR=1" + exit 1; + fi +} # echo_and_report ( string ) : echo and print to report echo_and_report () { - echo "$1" | tee -a selftest_report.log + echo "$1" | tee -a selftest_report.log + exit_if } # ------------------------------------------------------------------------- -. ./otbenv.profile +. "$CUR_DIR/otbenv.profile" rm -f selftest_report.log touch selftest_report.log @@ -35,7 +64,7 @@ OTB_SO_LIBRARIES=$(find lib -name '*.so*') OTB_DY_LIBRARIES=$(find lib -name '*.dylib') OTB_EXE="bin/mapla bin/monteverdi bin/otbApplicationLauncherQt bin/otbApplicationLauncherCommandLine" for name in $OTB_SO_LIBRARIES $OTB_DY_LIBRARIES $OTB_EXE; do - F_OUTPUT=$(file "$name") + F_OUTPUT=$(file "$name") if echo "$F_OUTPUT" | grep -q 'cannot open'; then echo_and_report "$F_OUTPUT" elif echo "$F_OUTPUT" | grep -q ': broken symbolic link'; then @@ -55,15 +84,15 @@ for name in $OTB_SO_LIBRARIES $OTB_DY_LIBRARIES $OTB_EXE; do elif echo "$F_OUTPUT" | grep -q ': symbolic link'; then : else - echo_and_report "Unkown file type : $F_OUTPUT" + echo_and_report "Unknown file type : $F_OUTPUT" fi done REPORT_SIZE=$(nb_report_lines) if [ "$REPORT_SIZE" -ne "$REF_SIZE" ]; then - echo "Check 1/3 : FAIL" + echo "Check 1/4 : FAIL" else - echo "Check 1/3 : PASS" + echo "Check 1/4 : PASS" fi REF_SIZE=$REPORT_SIZE @@ -76,14 +105,14 @@ fi app_index=0 for app in $OTB_APPS; do if [ ! -f "bin/otbcli_$app" ]; then - echo_and_report "ERROR: missing cli launcher for application $app" + echo_and_report "ERROR: missing cli launcher for application $app" + else CLI_OUTPUT=$("bin/otbcli_$app" -help 2>&1) - CLI_FILTER=$(echo "${CLI_OUTPUT}"| tr '\n' ' ' | grep -E "^This is the $app application, version .* Parameters: .* Examples:.*") + CLI_FILTER=$(echo "${CLI_OUTPUT}"| tr '\n' ' ' | grep -E "This is the*.*$app*.*application, version .* Parameters: .* Examples:.*") CLI_FILTER2=$(echo "$CLI_FILTER" | grep -v 'FATAL') if [ -z "$CLI_FILTER2" ]; then - echo_and_report "ERROR: bin/otbcli_$app" - echo_and_report "$CLI_OUTPUT" + echo_and_report "ERROR: bin/otbcli_$app\n$CLI_OUTPUT" fi fi # test the gui launcher only on 2 first applications @@ -104,12 +133,14 @@ for app in $OTB_APPS; do kill -9 "$NEXT_CHILD_PID" wait "$NEXT_CHILD_PID" 2>/dev/null else - echo_and_report "ERROR: otbApplicationLauncherQt $app failed to launch" + echo "ERROR: otbApplicationLauncherQt $app failed to launch" tee -a selftest_report.log < tmp.log + exit_if fi else - echo_and_report "ERROR: bin/otbgui_$app failed to launch" - tee -a selftest_report.log < tmp.log + echo "ERROR: bin/otbgui_$app failed to launch" + tee -a selftest_report.log < tmp.log + exit_if fi fi app_index=$(( app_index + 1 )) @@ -124,9 +155,9 @@ fi REPORT_SIZE=$(nb_report_lines) if [ "$REPORT_SIZE" -ne "$REF_SIZE" ]; then - echo "Check 2/3 : FAIL" + echo "Check 2/4 : FAIL" else - echo "Check 2/3 : PASS" + echo "Check 2/4 : PASS" fi REF_SIZE=$REPORT_SIZE @@ -168,9 +199,20 @@ fi REPORT_SIZE=$(nb_report_lines) if [ "$REPORT_SIZE" -ne "$REF_SIZE" ]; then - echo "Check 3/3 : FAIL" + echo "Check 3/4 : FAIL" +else + echo "Check 3/4 : PASS" +fi + +grep_cmd=$(which grep) +grep_out=$($grep_cmd -Rs "/usr/" "$CUR_DIR/lib/cmake/") +grep_ret=$? +if [ $grep_ret -ne 1 ]; then + echo "Check 4/4 : FAIL" + echo "ERROR: your cmake files contains references to /usr. Is this normal?" + echo_and_report "$grep_out" else - echo "Check 3/3 : PASS" + echo "Check 4/4 : PASS" fi # clean any background process diff --git a/Packaging/Files/setup_python.sh b/Packaging/Files/setup_python.sh new file mode 100755 index 0000000000000000000000000000000000000000..e24731a88ca3579ff40925d97cf9ffaa87dccd0a --- /dev/null +++ b/Packaging/Files/setup_python.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +# Setup python environment +if [ ! -f "$OTB_PYTHON_EXE" ] ; then + OTB_PYTHON_EXE=$(which python) +fi + +python_major_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[0])") +python_minor_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[1])") +python_patch_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[2])") +python_version="$python_major_version.$python_minor_version.$python_patch_version" + +python_check_failed() { + printf %s\\n "*****Error occurred during installation******" + printf %s\\n "OTB python bindings requires python2.6 or python2.7 but current detected python version is $python_version" + printf %s\\n "If you have python2.6 or Python2.7 installed in your system " + printf %s\\n "You should set OTB_PYTHON_EXE and re-run this installation script." + printf %s\\n "eg: OTB_PYTHON_EXE=/path/to/python2.7 ./OTB-X.Y-Linux64.run" + exit 1; +} +if [ "$python_major_version" -gt 2 ]; then +python_check_failed +fi + +if [ "$python_minor_version" -lt 5 ]; then +python_check_failed +fi + +python_INSTSONAME=$($OTB_PYTHON_EXE -c "import sys; from distutils import sysconfig; print (sysconfig.get_config_var('INSTSONAME'));") + +python_lib_dirs="$LD_LIBRARY_PATH /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu" +if [ "$(uname)" = "Darwin" ]; then + python_lib_dirs="$DYLD_LIBRARY_PATH /usr/lib /Library/Frameworks /opt/local/lib /opt/local/Library/Frameworks" +fi; + +found_python_lib="0" +python_lib_file_path="" +for list_of_dir in $python_lib_dirs +do + if [ -f "$list_of_dir/$python_INSTSONAME" ]; then + python_lib_file_path="$list_of_dir/$python_INSTSONAME" + found_python_lib="1" + break + fi +done + +if [ "$found_python_lib" -eq "1" ]; then + numpy_import_result="$($OTB_PYTHON_EXE -c 'import numpy' 2>&1)" + if [ ! -z "$numpy_import_result" ]; then + printf %s\\n "*****Error occurred during installation******" + printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )" + printf %s\\n "numpy not installed with '$OTB_PYTHON_EXE'" + printf %s\\n "Check failed with result:" + printf %s\\n "$numpy_import_result" + exit 1; + fi; + printf %s\\n "OTB python bindings will be configured for $OTB_PYTHON_EXE ( version: $python_version )" + printf %s\\n "Found python library: $python_lib_file_path" + #ln -sf "$python_lib_file_path" "OUT_DIR/lib/$python_INSTALLED_SONAME" +else + printf %s\\n "*****Error occurred during installation******" + printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )" + printf %s\\n "$python_INSTSONAME cannot be found in any of search directories." + printf %s\\n "We had searched following directories $python_lib_dirs" + printf %s\\n "If you don't have python-dev package installed, install it and make a symlink" + printf %s\\n "If you don't have python headers and so installed on a custom location, then make a symlink" + printf %s\\n "eg: ln -s /usr/lib/x86_64-linux-gnu/$python_INSTSONAME OUT_DIR/lib/$python_INSTSONAME" +fi diff --git a/Packaging/Files/start_devenv.bat b/Packaging/Files/start_devenv.bat new file mode 100755 index 0000000000000000000000000000000000000000..f0458cf027ca2a9f6b4ac24e65495409fee4ebe6 --- /dev/null +++ b/Packaging/Files/start_devenv.bat @@ -0,0 +1,41 @@ +:: +:: Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +:: +:: This file is part of Orfeo Toolbox +:: +:: https://www.orfeo-toolbox.org/ +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: 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 on + +set CURRENT_SCRIPT_DIR=%~dp0 +set CURRENT_SCRIPT_DIR=%CURRENT_SCRIPT_DIR:~0,-1% + + +set PATH=%CURRENT_SCRIPT_DIR%\bin;%PATH% +set VSDEV_ENV=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe +set OTB_VS_TEMPLATE_DIR=%USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates + +set OTB_XDK_DIR=%CURRENT_SCRIPT_DIR:\=/% +::dir %OTB_VS_TEMPLATE_DIR% +if exist "%VSDEV_ENV%" ( +if not exist "%OTB_VS_TEMPLATE_DIR%" ( md "%OTB_VS_TEMPLATE_DIR%" ) +copy "%CURRENT_SCRIPT_DIR%\OTB Project.zip" "%OTB_VS_TEMPLATE_DIR%" +START "" "%VSDEV_ENV%" +) else ( +echo "%VSDEV_ENV% not found" +) + +@cmd diff --git a/Packaging/Files/template.app/Contents/Info.plist b/Packaging/Files/template.app/Contents/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..5f870f8d090a22d89878bf1b9b5a272acd36756d --- /dev/null +++ b/Packaging/Files/template.app/Contents/Info.plist @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>STARTUP_FILE</string> + <key>CFBundleIconFile</key> + <string>Monteverdi.icns</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleLongVersionString</key> + <string>LONG_VERSION</string> + <key>CFBundleShortVersionString</key> + <string>SHORT_VERSION</string> +</dict> +</plist> diff --git a/Packaging/Files/uninstall_otb.bat b/Packaging/Files/uninstall_otb.bat new file mode 100644 index 0000000000000000000000000000000000000000..b437444cee283e5945f207b8995922a82ec69664 --- /dev/null +++ b/Packaging/Files/uninstall_otb.bat @@ -0,0 +1,39 @@ +:: +:: Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +:: +:: This file is part of Orfeo Toolbox +:: +:: https://www.orfeo-toolbox.org/ +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: 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. + +:: script to uninstall OTB + +setlocal +set CUR_DIR=%~dp0 +cd %CUR_DIR%.. +set MY_INSTALL_DIR=%cd% +del /S /Q %MY_INSTALL_DIR%\include\OTB* || exit 1 +del /S /Q %MY_INSTALL_DIR%\lib\cmake\OTB* || exit 1 +del /S /Q %MY_INSTALL_DIR%\lib\otb* || exit 1 +del /S /Q %MY_INSTALL_DIR%\lib\python\_otbApplication.* || exit 1 +del /S /Q %MY_INSTALL_DIR%\bin\otb* || exit 1 +del /S /Q %MY_INSTALL_DIR%\bin\monteverdi.exe || exit 1 +del /S /Q %MY_INSTALL_DIR%\bin\mapla.exe || exit 1 +del /S /Q %MY_INSTALL_DIR%\mapla.bat || exit 1 +del /S /Q %MY_INSTALL_DIR%\monteverdi.bat || exit 1 +del /S /Q %MY_INSTALL_DIR%\share\OTB* || exit 1 +del /S /Q "%MY_INSTALL_DIR%\OTB Project.zip" || exit 1 +endlocal + + diff --git a/Packaging/Files/uninstall_otb.sh b/Packaging/Files/uninstall_otb.sh new file mode 100755 index 0000000000000000000000000000000000000000..4f596f38ed35d397f6ecd01658ec77412bccfbf0 --- /dev/null +++ b/Packaging/Files/uninstall_otb.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +set -e +rm -fr OUT_DIR/include/OTB-* +rm -f OUT_DIR/lib/{libotb*,libOTB*} +rm -fr OUT_DIR/lib/{otb,python/_otbApplication*} +rm -fr OUT_DIR/share/OTB* +rm -fv OUT_DIR/bin/{otb*,monteverdi,mapla} +rm -fv OUT_DIR/{mapla.sh,monteverdi.sh} + +echo "OTB is now uninstalled from OUT_DIR" diff --git a/SuperBuild/Packaging/PackageGlobals.cmake b/Packaging/PackageGlobals.cmake similarity index 78% rename from SuperBuild/Packaging/PackageGlobals.cmake rename to Packaging/PackageGlobals.cmake index fdcfb3da3709c78e0b703ae99f296acced1aece7..e945e98f31646c9ee350d1e43d025d513215d0f5 100644 --- a/SuperBuild/Packaging/PackageGlobals.cmake +++ b/Packaging/PackageGlobals.cmake @@ -18,6 +18,30 @@ # limitations under the License. # +set(LOADER_REGEX_EOL "E") +set(DEST_BIN_DIR bin) +set(DEST_APP_DIR lib/otb/applications) + +set(LIB_PREFIX lib) +set(DEST_LIB_DIR lib) +set(EXE_EXT "") +set(SCRIPT_EXT ".sh") +set(LIB_EXT ".so") +set(PYMODULE_EXT ".so") +set(STATIC_LIB_EXT ".a") + +if(WIN32) + set(LIB_PREFIX) + set(DEST_LIB_DIR bin) + set(EXE_EXT ".exe") + set(LIB_EXT ".dll") + set(SCRIPT_EXT ".bat") + set(PYMODULE_EXT ".pyd") + set(STATIC_LIB_EXT ".lib") +elseif(APPLE) + set(LIB_EXT ".dylib") +endif() + set(WINDOWS_SYSTEM_DLLS user32.dll gdi32.dll @@ -45,28 +69,9 @@ set(WINDOWS_SYSTEM_DLLS python...dll ) -if(MINGW) - set(WINDOWS_SYSTEM_DLLS - ${WINDOWS_SYSTEM_DLLS} - msvcrt.dll - ) -endif() - -if(PKG_GENERATE_XDK) - set(WINDOWS_SYSTEM_DLLS - ${WINDOWS_SYSTEM_DLLS} - api-ms-win-* - concrt140.dll - ucrtbase.dll - msvcp140.dll - msvrt140.dll - vcomp140.dll - ) -endif() - set(LINUX_SYSTEM_DLLS libm.so - libc.so + libc.so.* libstdc* libgcc_s.so librt.so @@ -76,6 +81,9 @@ set(LINUX_SYSTEM_DLLS libgomp.so* ld-linux-x86-64.so* libX11.so* + libXi.so* #GLUT + libXcursor.so* #GLFW + libXinerama.so* #GLFW libXext.so* libXau.so* libXdmcp.so* @@ -88,11 +96,12 @@ set(LINUX_SYSTEM_DLLS libICE.so* libXrandr.so* libpython* - libexpat.so.* - libfontconfig.so* - libfreetype.so* - libwebp.so* ) + # libexpat.so.* + # libfontconfig.so* + # libfreetype.so* + # libwebp.so* + # ) # libgcc_s.*dylib and other *.framework are dragged by QT set(APPLE_SYSTEM_DLLS @@ -151,9 +160,11 @@ set(GTK_LIB_LIST_1 libpcre.so.3 libffi.so.6 ) -set(GTK_LIB_LIST_2 - libz.so.1 - libpng12.so.0 - ) +# set(GTK_LIB_LIST_2 +# libz.so.1 +# libpng12.so.0 +# ) + -set(ALLOWED_SYSTEM_DLLS ${GTK_LIB_LIST_1} ${GTK_LIB_LIST_2}) +#set(ALLOWED_SYSTEM_DLLS ${GTK_LIB_LIST_1} ${GTK_LIB_LIST_2}) +set(ALLOWED_SYSTEM_DLLS ${GTK_LIB_LIST_1}) # ${GTK_LIB_LIST_2}) diff --git a/SuperBuild/Packaging/README.md b/Packaging/README.md similarity index 100% rename from SuperBuild/Packaging/README.md rename to Packaging/README.md diff --git a/Packaging/check_cmake_variables.cmake b/Packaging/check_cmake_variables.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a757a3b07d3c4a0c5058dee1769848aeb6b58fe1 --- /dev/null +++ b/Packaging/check_cmake_variables.cmake @@ -0,0 +1,57 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +macro(check_cmake_variables) + set(required_vars) + if(OTB_WRAP_PYTHON) + list(APPEND required_vars PYTHON_EXECUTABLE) + endif() + + if(LINUX) + list(APPEND required_vars FILE_COMMAND) + list(APPEND required_vars READLINK) + list(APPEND required_vars PATCHELF_PROGRAM) + endif() + + if(WIN32) + list(APPEND required_vars ZIP_EXECUTABLE) + endif() + foreach(req + ${required_vars} + PKG_STAGE_DIR + SUPERBUILD_BINARY_DIR + SUPERBUILD_INSTALL_DIR + SUPERBUILD_SOURCE_DIR + PACKAGE_OTB_SRC_DIR + OTB_TARGET_SYSTEM_ARCH + OTB_TARGET_SYSTEM_ARCH_IS_X64 + LOADER_PROGRAM + LOADER_ARGS + LOADER_REGEX + PKG_ITK_SB_VERSION + PKG_OTB_VERSION_STRING + PACKAGE_OUTPUT_FILE + ) + if(NOT DEFINED ${req} OR "${${req}}" STREQUAL "") + message(FATAL_ERROR "you must set ${req}") + endif() + message(STATUS "${req}=[${${req}}]") + endforeach(req) + +endmacro() diff --git a/Packaging/cleanup_package.cmake b/Packaging/cleanup_package.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e7bae3164be1bc63518ea67f08bbc9351c58a879 --- /dev/null +++ b/Packaging/cleanup_package.cmake @@ -0,0 +1,58 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + +macro(cleanup_package) + +if(EXISTS "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}") + +message(STATUS "Deleting package staging directory: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}") +execute_process(COMMAND +${CMAKE_COMMAND} -E remove_directory + "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}" + RESULT_VARIABLE cleanup_stagedir_rv + OUTPUT_VARIABLE cleanup_stagedir_ov + ERROR_VARIABLE cleanup_stagedir_ov + ) + + if(cleanup_stagedir_rv) + message(FATAL_ERROR "Delete ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR} - FAILED\ncleanup_stagedir_ov=${cleanup_stagedir_ov}") + else() + message(STATUS "Delete ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR} - OK") + endif() +endif() + +if(EXISTS "${PACKAGE_OUTPUT_FILE}") +message(STATUS "Remove PACKAGE_OUTPUT_FILE: ${PACKAGE_OUTPUT_FILE}") +execute_process(COMMAND +${CMAKE_COMMAND} -E remove -f "${PACKAGE_OUTPUT_FILE}" + RESULT_VARIABLE cleanup_pkgfile_rv + OUTPUT_VARIABLE cleanup_pkgfile_ov + ERROR_VARIABLE cleanup_pkgfile_ov + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + if(cleanup_pkgfile_rv) + message(FATAL_ERROR "Delete ${PACKAGE_OUTPUT_FILE} - FAILED\ncleanup_pkgfile_ov=${cleanup_pkgfile_ov}") + else() + message(STATUS "Delete ${PACKAGE_OUTPUT_FILE} - OK") + endif() + +endif() +endmacro() diff --git a/Packaging/clear_cmakecache_variables.cmake b/Packaging/clear_cmakecache_variables.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e4418c001a9463399b759e1c09a57644bcad4750 --- /dev/null +++ b/Packaging/clear_cmakecache_variables.cmake @@ -0,0 +1,29 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +macro(clear_cmakecache_variables) +unset(matched_vars CACHE) + get_variables_ending_with("_USED|_RESOLVED" matched_vars) + foreach (var_to_unset IN LISTS matched_vars) + if(PKG_DEBUG) + message("unset ${var_to_unset} from cache") + endif() + unset(${var_to_unset} CACHE) + endforeach() +endmacro() #clear_cmakecache_variables diff --git a/Packaging/configure_loader.cmake b/Packaging/configure_loader.cmake new file mode 100644 index 0000000000000000000000000000000000000000..74f70943120ce26bc2ab2c15ada68e4acba1e69f --- /dev/null +++ b/Packaging/configure_loader.cmake @@ -0,0 +1,50 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(configure_loader loader_pgm_result loader_args_result loader_regex_result) +set(loader_PATHS) +if(MSVC) + set(loader_PATHS) + set(loader_names "dumpbin") + set(loader_args "/DEPENDENTS") + set(loader_regex "^ ([^ ].*[Dd][Ll][Ll])${LOADER_REGEX_EOL}$") + elseif(APPLE) + set(loader_PATHS) + set(loader_names otool) + set(loader_args "-l" ) + set(loader_regex ".*name.*([ ].*dylib ).*${LOADER_REGEX_EOL}$") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(loader_PATHS) + set(loader_names objdump) + set(loader_args "-p" ) + set(loader_regex "^..NEEDED.*([ ].*so.*)${LOADER_REGEX_EOL}$") + else() + message(FATAL_ERROR "find_loader_and_args: Unknown platform") + endif() + + find_program(loader_pgm "${loader_names}" PATHS ${loader_PATHS}) + if(NOT loader_pgm) + message(FATAL_ERROR "${loader_names} not found in ${loader_PATHS}.") + endif() + + #save result in PARENT_SCOPE + set(${loader_args_result} ${loader_args} PARENT_SCOPE) + set(${loader_pgm_result} ${loader_pgm} PARENT_SCOPE) + set(${loader_regex_result} ${loader_regex} PARENT_SCOPE) +endfunction() diff --git a/Packaging/create_package.cmake b/Packaging/create_package.cmake new file mode 100644 index 0000000000000000000000000000000000000000..d53e0181089311cc153da9032c5d7d0ef506e774 --- /dev/null +++ b/Packaging/create_package.cmake @@ -0,0 +1,45 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +macro(create_package) + install(CODE " + message(STATUS \"Creating ${PACKAGE_OUTPUT_FILE}\") + if(WIN32) + execute_process( + COMMAND ${ZIP_EXECUTABLE} \"a\" \"-r\" \"-y\" + \"${PACKAGE_OUTPUT_FILE}\" \"${PKG_STAGE_DIR}/*\" + WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\" + ) + else() + execute_process( + COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/makeself/makeself.sh + \"--quiet\" + \"--target\" + \"${PKG_STAGE_DIR}\" + \"${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}\" + \"${PKG_STAGE_DIR}.run\" + \"${PACKAGE_LONG_NAME} ${PKG_OTB_VERSION_STRING}\" + \"./pkgsetup\" + WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\" + ) + endif() + ") + +endmacro() + diff --git a/Packaging/detect_using_file_command.cmake b/Packaging/detect_using_file_command.cmake new file mode 100644 index 0000000000000000000000000000000000000000..61a060399aebedd020bd1b44688aec0a12bbc2cc --- /dev/null +++ b/Packaging/detect_using_file_command.cmake @@ -0,0 +1,111 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(detect_using_file_command input_file result_type result_dir) + + execute_process(COMMAND "${FILE_COMMAND}" "${input_file}" + RESULT_VARIABLE file_rv + OUTPUT_VARIABLE file_ov + ERROR_VARIABLE file_ev + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT file_rv STREQUAL "0") + message(FATAL_ERROR "${FILE_COMMAND} failed: ${file_rv}\n${file_ev}\n${file_ov}") + endif() + + get_filename_component(input_file_NAME ${input_file} NAME) + string(REPLACE "${input_file}" " _file_full_ " file_ov "${file_ov}") + string(TOLOWER "${file_ov}" file_ov_lower) + + set(detected_type) + set(detected_dir) + # below executable check works for both mac osx and linux + if("${file_ov_lower}" MATCHES "executable") + set(detected_type PROGRAMS) + set(detected_dir bin) + # detect position independent executables on Linux, + # where "file" gives "dynamically linked (uses shared libraries)" + elseif("${file_ov_lower}" MATCHES "dynamically linked.*\(uses shared libs\)") + set(detected_type FILES) + set(detected_dir lib) + # detect position independent executables on Linux, + # where "file" gives "shared object ... (uses shared libraries)" + elseif("${file_ov_lower}" MATCHES "shared object.*\(uses shared libs\)") + set(detected_type FILES) + set(detected_dir lib) + # detect shared libraries on Linux, + # where "file" gives "ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped" + elseif("${file_ov_lower}" MATCHES "elf.*shared object.*version") + set(detected_type FILES) + set(detected_dir lib) + # "file" version 5.22 does not print "(used shared libraries)" + # but uses "interpreter" + elseif("${file_ov_lower}" MATCHES "shared object.*interpreter") + set(detected_type FILES) + set(detected_dir lib) + # detect shared libraries on Mac OSX + # where "file" gives "Mach-O 64-bit x86_64 dynamically linked shared library" + elseif("${file_ov_lower}" MATCHES "mach-o.*dynamically linked shared library") + set(detected_type FILES) + set(detected_dir lib) + #below check is redundant. detect executables on Mac OSX + # where "file" gives "Mach-O 64-bit x86_64 executable" + elseif("${file_ov_lower}" MATCHES "mach-o.*executable") + set(detected_type PROGRAMS) + set(detected_dir bin) + # detect shared libraries on Mac OSX + # where "file" gives "Mach-O 64-bit x86_64 bundle" + elseif("${file_ov_lower}" MATCHES "mach-o.*bundle") + set(detected_type FILES) + set(detected_dir lib) + elseif("${file_ov_lower}" MATCHES "mach-o.*bundle") + set(detected_type FILES) + set(detected_dir lib) + elseif("${file_ov_lower}" MATCHES "symbolic link") + #this will do a symlink check again using but that's okay! + + #set type to symlink we are going to resolve it anyway + set(detected_type "symlink") + + set(is_this_a_symbolic_link FALSE) + set(target_file) + isfile_symlink("${input_file}" is_this_a_symbolic_link target_file) + if(is_this_a_symbolic_link) + + if(target_file) + set(libdir "lib") + setif_value_in_list(is_gtk_lib "${input_file_NAME}" GTK_LIB_LIST_1) + if(is_gtk_lib) + set(libdir "lib/gtk") + endif() + file(APPEND + ${CMAKE_BINARY_DIR}/make_symlinks + "ln -sf \"$OUT_DIR/${libdir}/${target_file}\" \"$OUT_DIR/${libdir}/${input_file_NAME}\" \n" + ) + endif() #target_file + endif() #is_this_a_symbolic_link + else() #if("${file_ov_lower}" MATCHES ...) + #we are out of options at this point. throw error! + message(FATAL_ERROR "unknown/untracked file type found: ${input_file}") + endif() #if("${file_ov_lower}" MATCHES ...) + + #message("detected_type=${detected_type}") + set(${result_type} "${detected_type}" PARENT_SCOPE) + set(${result_dir} "${detected_dir}" PARENT_SCOPE) +endfunction() diff --git a/Packaging/get_variables_ending_with.cmake b/Packaging/get_variables_ending_with.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8998aff47eef25ab47d94a91280159d88bf719e2 --- /dev/null +++ b/Packaging/get_variables_ending_with.cmake @@ -0,0 +1,24 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function (get_variables_ending_with suffix result) + get_cmake_property(all_cmake_vars VARIABLES) + string (REGEX MATCHALL "(^|;)[A-Za-z0-9_\\.\\-]*(${suffix})" _matchedVars "${all_cmake_vars}") + set(${result} ${_matchedVars} PARENT_SCOPE) +endfunction() diff --git a/Packaging/howto_update_makeself b/Packaging/howto_update_makeself new file mode 100644 index 0000000000000000000000000000000000000000..97df2547a2f72f046ce976408ea49bbd6c80d8f3 --- /dev/null +++ b/Packaging/howto_update_makeself @@ -0,0 +1,11 @@ +HOW TO UPDATE MAKESELF + +#If makEself version with your required bug fix is 2.3.1 +# cd to otb/sources/Packaging/ + +wget https://github.com/megastep/makeself/archive/release-2.3.1.tar.gz +tar xzf release-2.3.1.tar.gz +mv makeself-release-2.3.1 makeself +rm -fr release-2.3.1.tar.gz + +run git diff to check if everything is in place and git commit diff --git a/Packaging/install_cmake_files.cmake b/Packaging/install_cmake_files.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ca63afb0f6203fa8295aece0e09dcc8a03f15939 --- /dev/null +++ b/Packaging/install_cmake_files.cmake @@ -0,0 +1,34 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +include(patch_cmake_files.cmake) + +function(install_cmake_files) + patch_cmake_files(NAME "ITK" + VERSION "${PKG_ITK_SB_VERSION}" + MATCH_STRING "${CMAKE_INSTALL_PREFIX}" + REPLACE_VAR "ITK_INSTALL_PREFIX" + ) + + patch_cmake_files(NAME "OTB" + VERSION "${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}" + MATCH_STRING "${CMAKE_INSTALL_PREFIX}" + REPLACE_VAR "OTB_INSTALL_PREFIX" + ) +endfunction() diff --git a/Packaging/install_importlibs.cmake b/Packaging/install_importlibs.cmake new file mode 100644 index 0000000000000000000000000000000000000000..5a68caff7cf580c8ef97b59c4e57a459e4287f3a --- /dev/null +++ b/Packaging/install_importlibs.cmake @@ -0,0 +1,43 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +# +# This is more messed up that you might think. +# On windows we cannot track dependency on .lib files like dll +function(install_importlibs) + if(NOT WIN32) + return() + endif() + + #ALL .lib files are required for building + #eg: gdal.dll will have gdal_i.lib which is + #needed when you do cmake configure for projects + #using OTB. Hence the *.lib regex is non optional + #and cannot be optimized at any level. + #Only thing you can control is to create only those + #required .lib files in install directory. + file(GLOB import_lib_files + "${SUPERBUILD_INSTALL_DIR}/lib/*.lib" + "${SUPERBUILD_INSTALL_DIR}/bin/itk*.dll" + ) + foreach( import_lib_file ${import_lib_files}) + install_rule(${import_lib_file}) + endforeach() + +endfunction() diff --git a/Packaging/install_include_dirs.cmake b/Packaging/install_include_dirs.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1a243ae60d6b5b4a3a8f0f762b1629b115d6ab99 --- /dev/null +++ b/Packaging/install_include_dirs.cmake @@ -0,0 +1,36 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_include_dirs) + # #install ${SUPERBUILD_INSTALL_DIR}/include directory. + file(GLOB ALL_IN_INCLUDE_DIR "${SUPERBUILD_INSTALL_DIR}/include/*") + foreach(INCLUDE_DIR_ITEM ${ALL_IN_INCLUDE_DIR}) + get_filename_component(INCLUDE_DIR_ITEM_name ${INCLUDE_DIR_ITEM} NAME) + if( IS_DIRECTORY ${INCLUDE_DIR_ITEM}) + install(CODE + "message(STATUS \"Installing: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}/include/${INCLUDE_DIR_ITEM_name}/\")" ) + install(DIRECTORY "${INCLUDE_DIR_ITEM}" + DESTINATION "${PKG_STAGE_DIR}/include/" + MESSAGE_NEVER) + else() + install(FILES "${INCLUDE_DIR_ITEM}" + DESTINATION "${PKG_STAGE_DIR}/include/" ) + endif() #if( IS_DIRECTORY + endforeach() +endfunction() diff --git a/Packaging/install_otbapp_wrapper_scripts.cmake b/Packaging/install_otbapp_wrapper_scripts.cmake new file mode 100644 index 0000000000000000000000000000000000000000..bba639a281ffe426390004917e0c366044f20a7d --- /dev/null +++ b/Packaging/install_otbapp_wrapper_scripts.cmake @@ -0,0 +1,58 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_otbapp_wrapper_scripts otbapp_libfile) + ########### install cli and gui script for each application ########### + set(my_script_ext "") + if(WIN32) + set(my_script_ext ".bat") + endif() + get_filename_component(otbapp_libfile_WE ${otbapp_libfile} NAME_WE) + #just remove otbapp_ first. we will add otbcli_ or otbgui_ later + set(otbapp_name) + string(REPLACE "otbapp_" "" otbapp_name ${otbapp_libfile_WE}) + + #now define cli_script with valid name otbcli_<APPNAME><EXT> + set(cli_script "otbcli_${otbapp_name}${my_script_ext}") + if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${cli_script}") + #report error! + message(FATAL_ERROR "Cannot find ${cli_script} for ${otbapp_libfile}") + endif() + #install file + install( + PROGRAMS "${SUPERBUILD_INSTALL_DIR}/bin/${cli_script}" + DESTINATION ${PKG_STAGE_DIR}/bin + ) + + #Do the same for otbgui script but only if HAVE_QT4 is set. + if(NOT HAVE_QT4) + return() + endif() + + #now define gui_script_actual with valid name otbgui_<APPNAME><EXT> + set(gui_script "otbgui_${otbapp_name}${my_script_ext}") + if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${gui_script}") + #report error + message(FATAL_ERROR "Cannot find ${gui_script} for ${otbapp_libfile}") + endif() + #install script file + install( + PROGRAMS "${SUPERBUILD_INSTALL_DIR}/bin/${gui_script}" + DESTINATION ${PKG_STAGE_DIR}/bin ) +endfunction() diff --git a/Packaging/install_python_bindings.cmake b/Packaging/install_python_bindings.cmake new file mode 100644 index 0000000000000000000000000000000000000000..451894bb09aa00a844d46f985419cd3955322400 --- /dev/null +++ b/Packaging/install_python_bindings.cmake @@ -0,0 +1,27 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_python_bindings) + if(HAVE_PYTHON) + install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/lib/otb/python + DESTINATION ${PKG_STAGE_DIR}/lib + PATTERN "*.pyc" EXCLUDE + ) + endif() +endfunction() diff --git a/Packaging/install_qtdev_files.cmake b/Packaging/install_qtdev_files.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a615b02d0a2b28896360888f3b7a59fca9b391f1 --- /dev/null +++ b/Packaging/install_qtdev_files.cmake @@ -0,0 +1,46 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_qtdev_files) + if(NOT HAVE_QT4) + return() + endif() +set(QT_REQ_DIRS) + if(MSVC) + file(GLOB ALL_LIB_FILES "${SUPERBUILD_INSTALL_DIR}/lib/*.lib") + endif() + foreach(LIB_FILE ${LIB_FILES}) + install_rule(${LIB_FILE}) + endforeach() + list(APPEND QT_REQ_DIRS imports) + list(APPEND QT_REQ_DIRS mkspecs) + list(APPEND QT_REQ_DIRS plugins) + list(APPEND QT_REQ_DIRS translations) + foreach(QT_REQ_DIR ${QT_REQ_DIRS} ) + if(EXISTS "${SUPERBUILD_INSTALL_DIR}/${QT_REQ_DIR}") + install_without_message("${SUPERBUILD_INSTALL_DIR}/${QT_REQ_DIR}" "") + endif() + endforeach() + + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/Files/qt.conf + DESTINATION ${PKG_STAGE_DIR}/bin + ) + +endfunction() diff --git a/Packaging/install_rule.cmake b/Packaging/install_rule.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e404a59fe6ea212d03a5055a08b3a0cc2321d0f9 --- /dev/null +++ b/Packaging/install_rule.cmake @@ -0,0 +1,121 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +# +# This is one big fat if-elseif ladder +# that will detect a type and destination to use in +# install(.. + +function(install_rule src_file) + + get_filename_component(src_file_EXT ${src_file} EXT) + get_filename_component(src_file_NAME ${src_file} NAME) + get_filename_component(src_file_NAME_WE ${src_file} NAME_WE) + get_filename_component(src_file_PATH ${src_file} PATH) + + file(GLOB src_file_star "${src_file_PATH}/${src_file_NAME_WE}*") + foreach(sfile ${src_file_star}) + get_filename_component(sfile_NAME ${sfile} NAME) + string(TOLOWER "${sfile_NAME}" sfile_NAME_LOWER) + + get_filename_component(sfile_ABS "${sfile}" ABSOLUTE) + string(TOLOWER "${sfile_ABS}" sfile_ABS_LOWER) + set(install_type) + set(install_dir) + if ("${sfile_NAME_LOWER}" MATCHES "^(otb|mvd)([a-z0-9]+)test*.*" ) + if(PKG_DEBUG) + message("SKIP INSTALL for ${sfile_NAME_LOWER}") + endif() + continue() + elseif ("${sfile_NAME_LOWER}" MATCHES "headertest" ) + # special case for remote modules which has executables + # like MosiacHeaderTest1.exe. This ideally should be + # fixed in remote modules like OTBMosiacHeaderTest1.exe + if(PKG_DEBUG) + message("SKIP INSTALL for ${sfile_NAME_LOWER}") + endif() + continue() + elseif("${sfile_ABS_LOWER}" MATCHES "(\\.exe)$") + set(install_type PROGRAMS) + set(install_dir bin) + elseif("${sfile_ABS_LOWER}" MATCHES "(\\.dll)$") + set(install_type FILES) + set(install_dir bin) + elseif("${sfile_ABS_LOWER}" MATCHES "(\\.lib)$") + set(install_type FILES) + set(install_dir lib) + elseif("${sfile_ABS_LOWER}" MATCHES "(\\.pyd)$") + #python bindings are installed in install_python_bindings + continue() + elseif( "${sfile_NAME_LOWER}" MATCHES "^_otbapplication") + # _otbApplication.so matched below; so we explicit skip it + # because it's already handled in install_python_bindings.cmake + continue() + elseif("${sfile_ABS_LOWER}" MATCHES "\\.lnk$") + #we don't install symlink on windows. issue a warning + set(install_type "symlink") + set(install_dir) + elseif("${sfile_ABS_LOWER}" MATCHES "(\\.a)$") + set(install_type FILES) + set(install_dir lib) + elseif("${sfile_ABS_LOWER}" MATCHES "\\.prl$") + continue() + elseif("${sfile_ABS_LOWER}" MATCHES "\\.la$") + continue() + else() + if(UNIX) + #the last else() loop where we run a 'file' command to find file type and directory + set(install_type) + set(install_dir) + #this is whole other story + detect_using_file_command(${sfile_ABS} install_type install_dir) + endif(UNIX) + endif() + + if(install_type STREQUAL "symlink") + #we don't install symlink on windows. issue a warning and continue + if(PKG_DEBUG) + message("${sfile_ABS} is a symbolic link and this will be excluded from package") + endif() + continue() + endif() + + # This check comes outside the first if-elseif ladder + # because no matter what extension of file type, otbapp_* must go + # into lib/otb/applications + if("${sfile_NAME_LOWER}" MATCHES "^otbapp_") + install_otbapp_wrapper_scripts(${sfile_NAME}) + set(install_dir "lib/otb/applications") + set(install_type PROGRAMS) + endif() + + if(NOT install_type OR NOT install_dir) + #throw fatal error and return + message(FATAL_ERROR "sfile_ABS=${sfile_ABS}.\ninstall_type=${install_type}\ninstall_dir=${install_dir}") + return() + endif() + + install(${install_type} "${sfile}" + DESTINATION + "${PKG_STAGE_DIR}/${install_dir}" + ) + + endforeach() +endfunction() + diff --git a/Packaging/install_share_dirs.cmake b/Packaging/install_share_dirs.cmake new file mode 100644 index 0000000000000000000000000000000000000000..62f18e2e50be56c808d1d594d015bfe567904358 --- /dev/null +++ b/Packaging/install_share_dirs.cmake @@ -0,0 +1,97 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_share_dirs) + + #a convenient cmake var for storing <prefix>/bin + set(PKG_STAGE_BIN_DIR "${PKG_STAGE_DIR}/bin") + + #<prefix>/share for gdal data files + set(PKG_SHARE_DEST_DIR ${PKG_STAGE_DIR}/share) + + set(PKG_SHARE_SOURCE_DIR ${SUPERBUILD_INSTALL_DIR}/share) + + + ####################### install mvd i18N ############################ + # OTB i18n directory is different from qt's i18N directory + #which is <prefix>/share/qt4/translations by default on linux. + + # To install otb i18n directory correctly, we need to find + #Monteverdi_INSTALL_DATA_DIR. Value of this is a defined in ConfigureMonteverdi.h + # and default value is "share/OTB-X.Y" + #... + # #define Monteverdi_INSTALL_DATA_DIR + #... + #Instead of parsing ConfigureMonteverdi.h, + #we simply use default and add a check for this directory! + + #define Monteverdi_INSTALL_DATA_DIR "share/OTB-X.Y" + + set(OTB_I18N_DIRNAME OTB-${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}/i18n) + set(MVD_I18N_SOURCE_DIR ${PKG_SHARE_SOURCE_DIR}/${OTB_I18N_DIRNAME}) + if(NOT EXISTS "${MVD_I18N_SOURCE_DIR}") + message(FATAL_ERROR "Error ${MVD_I18N_SOURCE_DIR} not exists") + endif() + set(MVD_I18N_DEST_DIR ${PKG_SHARE_DEST_DIR}/${OTB_I18N_DIRNAME}) + file(GLOB MVD_APP_TS_FILES ${PACKAGE_OTB_SRC_DIR}/i18n/*.ts) # qm files + foreach(APP_TS_FILE ${APP_TS_FILES}) + get_filename_component(APP_TS_FILENAME ${APP_TS_FILE} NAME_WE) + install(FILES ${MVD_I18N_SOURCE_DIR}/${APP_TS_FILENAME}.qm + DESTINATION ${MVD_I18N_DEST_DIR} + ) + endforeach() + + ####################### install GDAL data ############################ + set(GDAL_DATA_DIR ${PKG_SHARE_SOURCE_DIR}/gdal) + #MSVC install gdal-data in in a different directory. So we don't spoil it + if(MSVC) + set(GDAL_DATA_DIR ${SUPERBUILD_INSTALL_DIR}/data) + endif() + if(NOT EXISTS "${GDAL_DATA_DIR}/epsg.wkt") + message(FATAL_ERROR + "Cannot generate package without GDAL_DATA : ${GDAL_DATA_DIR}") + endif() + install_without_message("${GDAL_DATA_DIR}" "share" ) + + ####################### install GeoTIFF data ######################## + install_without_message("${PKG_SHARE_SOURCE_DIR}/epsg_csv" "share" ) + + ####################### install OSSIM data ########################## + install_without_message("${PKG_SHARE_SOURCE_DIR}/ossim" "share" ) + + ####################### install proj share ########################## + if(EXISTS ${PKG_SHARE_SOURCE_DIR}/proj) + install_without_message("${PKG_SHARE_SOURCE_DIR}/proj" "share" ) + endif() + + ####################### Install copyrights ########################## + #install license for packages + install_without_message("${PKG_SHARE_SOURCE_DIR}/copyright" "share" ) + install(FILES ${PKG_SHARE_SOURCE_DIR}/copyright/LICENSE + DESTINATION ${PKG_STAGE_DIR}) + + ####################### Install VERSION ########################## + set(PKG_VERSION_FILE + "${SUPERBUILD_INSTALL_DIR}/share/doc/${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}/VERSION") + if(EXISTS ${PKG_VERSION_FILE} ) + install(FILES ${PKG_VERSION_FILE} DESTINATION ${PKG_STAGE_DIR}) + endif() + +endfunction() + diff --git a/Packaging/install_vstudio_files.cmake b/Packaging/install_vstudio_files.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8630dd8081e9d233348c6f8a14e5dfafe5d49c3d --- /dev/null +++ b/Packaging/install_vstudio_files.cmake @@ -0,0 +1,27 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_vstudio_files) +if(MSVC) + install(FILES + "Files/OTB Project.zip" + "Files/start_devenv.bat" + DESTINATION "${PKG_STAGE_DIR}" ) + endif() +endfunction() diff --git a/Packaging/install_without_message.cmake b/Packaging/install_without_message.cmake new file mode 100644 index 0000000000000000000000000000000000000000..947e8d9b66da373a2e788c934ad73bc10b037df9 --- /dev/null +++ b/Packaging/install_without_message.cmake @@ -0,0 +1,40 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(install_without_message src_dir dst_dir_suffix) + set (extra_func_args ${ARGN}) + list(LENGTH extra_func_args num_extra_args) + if (${num_extra_args} GREATER 0) + list(GET extra_func_args 0 optional_msg) + endif() + + if( "${dst_dir_suffix}" STREQUAL "") + set(dst_dir "${PKG_STAGE_DIR}") + else() + set(dst_dir "${PKG_STAGE_DIR}/${dst_dir_suffix}") + endif() + + get_filename_component(src_dir_name ${src_dir} NAME) + set(install_msg "message(STATUS \"Installing: ${CMAKE_INSTALL_PREFIX}/${dst_dir}/${src_dir_name} ${optional_msg}\")") + install(CODE "${install_msg}" ) + install( + DIRECTORY ${src_dir} + DESTINATION ${dst_dir} + MESSAGE_NEVER ) +endfunction() #install_without_message diff --git a/Packaging/installer_files.cmake b/Packaging/installer_files.cmake new file mode 100644 index 0000000000000000000000000000000000000000..941f7f8cdfbf8caa17e8f52e3553a65bd25b6ab9 --- /dev/null +++ b/Packaging/installer_files.cmake @@ -0,0 +1,133 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +macro(installer_files) + + #configure README from rst docs + set(RSTDOC_DIR "${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst") + if(APPLE) + set(README_FILE ${RSTDOC_DIR}/Installation_Macx.txt) + elseif(LINUX) #not osx + set(README_FILE ${RSTDOC_DIR}/Installation_Linux.txt) + elseif(WIN32) #windows + set(README_FILE ${RSTDOC_DIR}/Installation_Windows.txt) + endif() + configure_file("${README_FILE}" ${CMAKE_BINARY_DIR}/README ) + install(FILES ${CMAKE_BINARY_DIR}/README DESTINATION ${PKG_STAGE_DIR} ) + + + #configure pkgsetup for mac and linux + if(LINUX) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Files/linux_pkgsetup.in + ${CMAKE_CURRENT_BINARY_DIR}/pkgsetup @ONLY + ) + endif() + + if(APPLE) + set(ORIGINAL_RPATH_TO_REPLACE ${SUPERBUILD_INSTALL_DIR}/lib) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Files/macx_pkgsetup.in + ${CMAKE_CURRENT_BINARY_DIR}/pkgsetup @ONLY + ) + + #install icon file for .app file. Monteverdi and Mapla has same icon! + install(FILES + Files/Monteverdi.icns DESTINATION ${PKG_STAGE_DIR}) + endif() + + #start installing script and other stuff related to package + if(UNIX) + install( PROGRAMS + ${CMAKE_BINARY_DIR}/pkgsetup + ${CMAKE_BINARY_DIR}/make_symlinks + Files/setup_python.sh + Files/otbenv.profile + DESTINATION ${PKG_STAGE_DIR} + ) + endif() + + # We also need wrapper script to start mapla & monteverdi + #if(NOT HAVE_MVD) + # message(FATAL_ERROR "not have mvd") + #endif() + if(HAVE_MVD) + install(PROGRAMS + Files/mapla${SCRIPT_EXT} + Files/monteverdi${SCRIPT_EXT} + DESTINATION ${PKG_STAGE_DIR} + ) + + #for mac osx, we have a template.app which is + # later processed in pkgsetup (macx_pkgsetup.in) + if(APPLE) + install(DIRECTORY Files/template.app + DESTINATION "${PKG_STAGE_DIR}") + endif() + endif() #HAVE_MVD + + #my_file_ext is required for otbcli and otbgui files which has + # no extension on linux. (hence we cannot use SCRIPT_EXT + + #For windows otbenv.bash and otbenv.bat is required. + # Former is for windows shell users and latter is for other + # linux emulator such as bash for windows or mobxterm + set(my_file_ext "") + if(WIN32) + set(my_file_ext ".bat") + install( PROGRAMS + Files/otbenv.bat + Files/otbenv.bash + DESTINATION ${PKG_STAGE_DIR} + ) + endif() + + #these scripts are not auto-installed in PKG_STAGE_DIR + #could this be move them to somewhere else? + install(PROGRAMS + "${SUPERBUILD_INSTALL_DIR}/bin/otbcli${my_file_ext}" + "${SUPERBUILD_INSTALL_DIR}/bin/otbgui${my_file_ext}" + DESTINATION ${PKG_STAGE_DIR}/bin) + + install(PROGRAMS + Files/selftester${SCRIPT_EXT} + Files/uninstall_otb${SCRIPT_EXT} + DESTINATION ${PKG_STAGE_DIR}/tools) + + # only required for linux. + # THIS WILL BE REMOVED ONCE INSTALLATION IS DONE + # USE --noexec option when running .run file to keep this file + # along with other installation files + if(LINUX) + install(PROGRAMS + "${PATCHELF_PROGRAM}" + DESTINATION ${PKG_STAGE_DIR}) + endif() + + install(FILES + Files/build_examples.cmake + DESTINATION ${PKG_STAGE_DIR}/tools) + + + #add otb_loader + add_executable(otb_loader ${CMAKE_CURRENT_SOURCE_DIR}/Files/otb_loader.cxx) + target_link_libraries(otb_loader ${CMAKE_DL_LIBS}) + install(TARGETS otb_loader DESTINATION ${PKG_STAGE_DIR}/tools) + add_dependencies(otb_loader PATCHELF) +endmacro() diff --git a/Packaging/isfile_symlink.cmake b/Packaging/isfile_symlink.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0d3b490d6bf866d6780cc9ec69eda1535c90f588 --- /dev/null +++ b/Packaging/isfile_symlink.cmake @@ -0,0 +1,89 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(isfile_symlink file result_var1 result_var2) + # + # A file is not executable until proven otherwise: + # + set(${result_var1} 0 PARENT_SCOPE) + set(${result_var2} "" PARENT_SCOPE) + + get_filename_component(file_full "${file}" ABSOLUTE) + string(TOLOWER "${file_full}" file_full_lower) + + # If file name ends in .lnk on Windows, + # *assume* symlink a.k.a shortcut. + # + if(WIN32 AND NOT UNIX) + if("${file_full_lower}" MATCHES "\\.lnk$") + set(${result_var1} 1 PARENT_SCOPE) + #Assuming the file is linked to a file + #with same name without .lnk extension + get_filename_component(file_full_name_we "${file_full}" NAME_WE) + set(${result_var2} "${file_full_name_we}" PARENT_SCOPE) + return() + endif() + + # A clause could be added here that uses output or return value of dumpbin + # to determine ${result_var}. In 99%+? practical cases, the exe name + # match will be sufficient... + # + endif() + + #if we are not on a unix or unix-like platform, + #then we don't have any business after this line. + if(NOT UNIX) + return() + endif() + + # Use the information returned from the Unix shell command "file" to + # determine if ${file_full} should be considered an executable file... + # + # If the file command's output contains "executable" and does *not* contain + # "text" then it is likely an executable suitable for prerequisite analysis + # via the get_prerequisites macro. + + execute_process(COMMAND "${READLINK}" "${file_full}" + RESULT_VARIABLE readlink_rv + OUTPUT_VARIABLE readlink_ov + ERROR_VARIABLE readlink_ev + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(PKG_DEBUG) + message("${READLINK} on '${file_full} has output: '${readlink_ov}'\nreadlink_ev=${readlink_ev}") + endif() + + if(readlink_rv STREQUAL "1") + set(${result_var1} 0 PARENT_SCOPE) + set(${result_var2} "" PARENT_SCOPE) + return() + endif() + + #got a symlink!. set result_var1 to TRUE + set(${result_var1} 1 PARENT_SCOPE) + + #Now get the resolved link to result_var2 + set(symlinked_to) + string(STRIP ${readlink_ov} symlinked_to) + set(${result_var2} "${symlinked_to}" PARENT_SCOPE) + + return() + +endfunction() diff --git a/Packaging/makeself/COPYING b/Packaging/makeself/COPYING new file mode 100644 index 0000000000000000000000000000000000000000..d159169d1050894d3ea3b98e1c965c4058208fe1 --- /dev/null +++ b/Packaging/makeself/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Packaging/makeself/README.md b/Packaging/makeself/README.md new file mode 100644 index 0000000000000000000000000000000000000000..04b9de80bbc0a71f0d1df86bd7453f1019704c36 --- /dev/null +++ b/Packaging/makeself/README.md @@ -0,0 +1,220 @@ +[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +[](https://travis-ci.org/megastep/makeself) + +# makeself - Make self-extractable archives on Unix + +[makeself.sh][1] is a small shell script that generates a self-extractable +compressed tar archive from a directory. The resulting file appears as a shell script +(many of those have a **.run** suffix), and can be launched as is. The archive +will then uncompress itself to a temporary directory and an optional arbitrary +command will be executed (for example an installation script). This is pretty +similar to archives generated with WinZip Self-Extractor in the Windows world. +Makeself archives also include checksums for integrity self-validation (CRC +and/or MD5 checksums). + +The makeself.sh script itself is used only to create the archives from a +directory of files. The resultant archive is actually a compressed (using +gzip, bzip2, or compress) TAR archive, with a small shell script stub at the +beginning. This small stub performs all the steps of extracting the files, +running the embedded command, and removing the temporary files when done. +All the user has to do to install the software contained in such an +archive is to "run" the archive, i.e **sh nice-software.run**. I recommend +using the ".run" (which was introduced by some Makeself archives released by +Loki Software) or ".sh" suffix for such archives not to confuse the users, +so that they will know they are actually shell scripts (with quite a lot of binary data +attached to them though!). + +I am trying to keep the code of this script as portable as possible, i.e it is +not relying on any bash-specific features and only calls commands that are +installed on any functioning UNIX-compatible system. This script as well as +the archives it generates should run on any Unix flavor, with any compatible +Bourne shell, provided of course that the compression programs are available. + +As of version 2.1, Makeself has been rewritten and tested on the following +platforms : + + * Linux (all distributions) + * Sun Solaris (8 and above) + * HP-UX (tested on 11.0 and 11i on HPPA RISC) + * SCO OpenUnix and OpenServer + * IBM AIX 5.1L + * macOS (Darwin) + * SGI IRIX 6.5 + * FreeBSD + * UnicOS / Cray + * Cygwin (Windows) + +If you successfully run Makeself and/or archives created with it on another +system, then please [let me know][2]! + +Examples of publicly available archives made using makeself are : + + * Game patches and installers for [Id Software][3] games like Quake 3 for Linux or Return To Castle Wolfenstein ; + * All game patches released by [Loki Software][4] for the Linux version of popular games ; + * The [nVidia drivers][5] for Linux + * The installer for the Linux version of [Google Earth][6] + * The [VirtualBox][7] installers for Linux + * The [Makeself][1] distribution itself ;-) + * and countless others... + +**Important note for Apache users:** By default, most Web servers will think that Makeself archives are regular text files and thus they may show up as text in a Web browser. The correct way to prevent this is to add a MIME type for this file format, like so (in httpd.conf) : + +`AddType application/x-makeself .run` + +**Important note for certain GNU/Linux distributions:** Archives created with Makeself prior to v2.1.2 were using an old syntax for the _head_ and _tail_ Unix commands that is being progressively obsoleted in their GNU forms. Therefore you may have problems uncompressing some of these archives. A workaround for this is to set the environment variable $_POSIX2_VERSION to enable the old syntax, i.e. : + +`export _POSIX2_VERSION=199209` + +## Usage + +The syntax of makeself is the following: + +``` +makeself.sh [args] archive_dir file_name label startup_script [script_args] +``` + + * _args_ are optional options for Makeself. The available ones are : + + * **--version** : Prints the version number on stdout, then exits immediately + * **--gzip** : Use gzip for compression (the default on platforms on which gzip is commonly available, like Linux) + * **--bzip2** : Use bzip2 instead of gzip for better compression. The bzip2 command must be available in the command path. It is recommended that the archive prefix be set to something like '.bz2.run', so that potential users know that they'll need bzip2 to extract it. + * **--pbzip2** : Use pbzip2 instead of gzip for better and faster compression on machines having multiple CPUs. The pbzip2 command must be available in the command path. It is recommended that the archive prefix be set to something like '.bz2.run', so that potential users know that they'll need bzip2 to extract it. + * **--xz** : Use xz instead of gzip for better compression. The xz command must be available in the command path. It is recommended that the archive prefix be set to something like '.xz.run' for the archive, so that potential users know that they'll need xz to extract it. + * **--lzo** : Use lzop instead of gzip for better compression. The lzop command must be available in the command path. It is recommended that the archive prefix be set to something like '.lzo.run' for the archive, so that potential users know that they'll need lzop to extract it. + * **--lz4** : Use lz4 instead of gzip for better compression. The lz4 command must be available in the command path. It is recommended that the archive prefix be set to something like '.lz4.run' for the archive, so that potential users know that they'll need lz4 to extract it. + * **--pigz** : Use pigz for compression. + * **--base64** : Encode the archive to ASCII in Base64 format instead of compressing (base64 command required). + * **--gpg-encrypt** : Encrypt the archive using `gpg -ac -z $COMPRESS_LEVEL`. This will prompt for a password to encrypt with. Assumes that potential users have `gpg` installed. + * **--ssl-encrypt** : Encrypt the archive using `openssl aes-256-cbc -a -salt`. This will prompt for a password to encrypt with. Assumes that the potential users have the OpenSSL tools installed. + * **--compress** : Use the UNIX `compress` command to compress the data. This should be the default on all platforms that don't have gzip available. + * **--nocomp** : Do not use any compression for the archive, which will then be an uncompressed TAR. + * **--complevel** : Specify the compression level for gzip, bzip2, pbzip2, xz, lzo or lz4. (defaults to 9) + * **--notemp** : The generated archive will not extract the files to a temporary directory, but in a new directory created in the current directory. This is better to distribute software packages that may extract and compile by themselves (i.e. launch the compilation through the embedded script). + * **--current** : Files will be extracted to the current directory, instead of in a subdirectory. This option implies `--notemp` above. + * **--follow** : Follow the symbolic links inside of the archive directory, i.e. store the files that are being pointed to instead of the links themselves. + * **--append** _(new in 2.1.x)_: Append data to an existing archive, instead of creating a new one. In this mode, the settings from the original archive are reused (compression type, label, embedded script), and thus don't need to be specified again on the command line. + * **--header** : Makeself 2.0 uses a separate file to store the header stub, called `makeself-header.sh`. By default, it is assumed that it is stored in the same location as makeself.sh. This option can be used to specify its actual location if it is stored someplace else. + * **--copy** : Upon extraction, the archive will first extract itself to a temporary directory. The main application of this is to allow self-contained installers stored in a Makeself archive on a CD, when the installer program will later need to unmount the CD and allow a new one to be inserted. This prevents "Filesystem busy" errors for installers that span multiple CDs. + * **--nox11** : Disable the automatic spawning of a new terminal in X11. + * **--nowait** : When executed from a new X11 terminal, disable the user prompt at the end of the script execution. + * **--nomd5** and **--nocrc** : Disable the creation of a MD5 / CRC checksum for the archive. This speeds up the extraction process if integrity checking is not necessary. + * **--lsm _file_** : Provide and LSM file to makeself, that will be embedded in the generated archive. LSM files are describing a software package in a way that is easily parseable. The LSM entry can then be later retrieved using the `--lsm` argument to the archive. An example of a LSM file is provided with Makeself. + * **--tar-extra opt** : Append more options to the tar command line. + + For instance, in order to exclude the `.git` directory from the packaged archive directory using the GNU `tar`, one can use `makeself.sh --tar-extra "--exclude=.git" ...` + + * **--keep-umask** : Keep the umask set to shell default, rather than overriding when executing self-extracting archive. + * **--packaging-date date** : Use provided string as the packaging date instead of the current date. + * **--license** : Append a license file. + * **--nooverwrite** : Do not extract the archive if the specified target directory already exists. + * **--header file** : Specify the location of the header script file (default `makeself-header.sh`) + * **--help-header file** : Add a header to the archive's `--help` output. + * _archive_dir_ is the name of the directory that contains the files to be archived + * _file_name_ is the name of the archive to be created + * _label_ is an arbitrary text string describing the package. It will be displayed while extracting the files. + * _startup_script_ is the command to be executed _from within_ the directory of extracted files. Thus, if you wish to execute a program contain in this directory, you must prefix your command with `./`. For example, `./program` will be fine. The _script_args_ are additionnal arguments for this command. + +Here is an example, assuming the user has a package image stored in a **/home/joe/mysoft**, and he wants to generate a self-extracting package named +**mysoft.sh**, which will launch the "setup" script initially stored in /home/joe/mysoft : + +`makeself.sh /home/joe/mysoft mysoft.sh "Joe's Nice Software Package" ./setup +` + +Here is also how I created the [makeself.run][9] archive which contains the Makeself distribution : + +`makeself.sh --notemp makeself makeself.run "Makeself by Stephane Peter" echo "Makeself has extracted itself" ` + +Archives generated with Makeself can be passed the following arguments: + + * _--keep_ : Prevent the files to be extracted in a temporary directory that will be removed after the embedded script's execution. The files will then be extracted in the current working directory and will stay here until you remove them. + * _--verbose_ : Will prompt the user before executing the embedded command + * _--target dir_ : Allows to extract the archive in an arbitrary place. + * _--nox11_ : Do not spawn a X11 terminal. + * _--confirm_ : Prompt the user for confirmation before running the embedded command. + * _--info_ : Print out general information about the archive (does not extract). + * _--lsm_ : Print out the LSM entry, if it is present. + * _--list_ : List the files in the archive. + * _--check_ : Check the archive for integrity using the embedded checksums. Does not extract the archive. + * _--nochown_ : By default, a `chown -R` command is run on the target directory after extraction, so that all files belong to the current user. This is mostly needed if you are running as root, as tar will then try to recreate the initial user ownerships. You may disable this behavior with this flag. + * _--tar_ : Run the tar command on the contents of the archive, using the following arguments as parameter for the command. + * _--noexec_ : Do not run the embedded script after extraction. + * _--nodiskspace_ : Do not check for available disk space before attempting to extract. + +Any subsequent arguments to the archive will be passed as additional arguments to the embedded command. You must explicitly use the _--_ special command-line construct before any such options to make sure that Makeself will not try to interpret them. + +## Maven Usage + +Makeself is now supported by the following maven plugin [makeself-maven-plugin](https://github.com/hazendaz/makeself-maven-plugin). Please refer to project for usage and report any bugs in regards to maven plugin on that project. + +## License + +Makeself is covered by the [GNU General Public License][8] (GPL) version 2 and above. Archives generated by Makeself don't have to be placed under this license (although I encourage it ;-)), since the archive itself is merely data for Makeself. + +## Contributing + +I will gladly consider merging your pull requests on the [GitHub][10] repository. However, please keep the following in mind: + + * One of the main purposes of Makeself is portability. Do not submit patches that will break supported platforms. The more platform-agnostic, the better. + * Please explain clearly what the purpose of the patch is, and how you achieved it. + +## Download + +Get the latest official distribution [here][9] (version 2.3.1). + +The latest development version can be grabbed from [GitHub][10]. Feel free to submit any patches there through the fork and pull request process. + +## Version history + + * **v1.0:** Initial public release + * **v1.1:** The archive can be passed parameters that will be passed on to the embedded script, thanks to John C. Quillan + * **v1.2:** Cosmetic updates, support for bzip2 compression and non-temporary archives. Many ideas thanks to Francois Petitjean. + * **v1.3:** More patches from Bjarni R. Einarsson and Francois Petitjean: Support for no compression (--nocomp), script is no longer mandatory, automatic launch in an xterm, optional verbose output, and -target archive option to indicate where to extract the files. + * **v1.4:** Many patches from Francois Petitjean: improved UNIX compatibility, automatic integrity checking, support of LSM files to get info on the package at run time.. + * **v1.5.x:** A lot of bugfixes, and many other patches, including automatic verification through the usage of checksums. Version 1.5.5 was the stable release for a long time, even though the Web page didn't get updated ;-). Makeself was also officially made a part of the [Loki Setup installer][11], and its source is being maintained as part of this package. + * **v2.0:** Complete internal rewrite of Makeself. The command-line parsing was vastly improved, the overall maintenance of the package was greatly improved by separating the stub from makeself.sh. Also Makeself was ported and tested to a variety of Unix platforms. + * **v2.0.1:** First public release of the new 2.0 branch. Prior versions are officially obsoleted. This release introduced the '--copy' argument that was introduced in response to a need for the [UT2K3][12] Linux installer. + * **v2.1.0:** Big change : Makeself can now support multiple embedded tarballs, each stored separately with their own checksums. An existing archive can be updated with the --append flag. Checksums are also better managed, and the --nochown option for archives appeared. + * **v2.1.1:** Fixes related to the Unix compression (compress command). Some Linux distributions made the insane choice to make it unavailable, even though gzip is capable of uncompressing these files, plus some more bugfixes in the extraction and checksum code. + * **v2.1.2:** Some bug fixes. Use head -n to avoid problems with POSIX conformance. + * **v2.1.3:** Bug fixes with the command line when spawning terminals. Added --tar, --noexec for archives. Added --nomd5 and --nocrc to avoid creating checksums in archives. The embedded script is now run through "eval". The --info output now includes the command used to create the archive. A man page was contributed by Bartosz Fenski. + * **v2.1.4:** Fixed --info output. Generate random directory name when extracting files to . to avoid problems. Better handling of errors with wrong permissions for the directory containing the files. Avoid some race conditions, Unset the $CDPATH variable to avoid problems if it is set. Better handling of dot files in the archive directory. + * **v2.1.5:** Made the md5sum detection consistent with the header code. Check for the presence of the archive directory. Added --encrypt for symmetric encryption through gpg (Eric Windisch). Added support for the digest command on Solaris 10 for MD5 checksums. Check for available disk space before extracting to the target directory (Andreas Schweitzer). Allow extraction to run asynchronously (patch by Peter Hatch). Use file descriptors internally to avoid error messages (patch by Kay Tiong Khoo). + * **v2.1.6:** Replaced one dot per file progress with a realtime progress percentage and a spining cursor. Added --noprogress to prevent showing the progress during the decompression. Added --target dir to allow extracting directly to a target directory. (Guy Baconniere) + * **v2.2.0:** First major new release in years! Includes many bugfixes and user contributions. Please look at the [project page on Github][10] for all the details. + * **v2.3.0:** Support for archive encryption via GPG or OpenSSL. Added LZO and LZ4 compression support. Options to set the packaging date and stop the umask from being overriden. Optionally ignore check for available disk space when extracting. New option to check for root permissions before extracting. + * **v2.3.1:** Various compatibility updates. Added unit tests for Travis CI in the GitHub repo. New --tar-extra, --untar-extra, --gpg-extra, --gpg-asymmetric-encrypt-sign options. + +## Links + + * Check out the ["Loki Setup"][11] installer, used to install many Linux games and other applications, and of which I am the co-author. Since the demise of Loki, I am now the official maintainer of the project, and it is now being hosted here on GitHub. + * Bjarni R. Einarsson also wrote the **setup.sh** installer script, inspired by Makeself. [Check it out !][14] + +## Contact + +This script was written by [Stéphane Peter][15] (megastep at megastep.org). Any enhancements and suggestions are welcome. + +Contributions were included from John C. Quillan, Bjarni R. Einarsson, +Francois Petitjean, Ryan C. Gordon, and many contributors on GitHub. If you think I forgot +your name, don't hesitate to contact me. + +This project is now hosted on GitHub. Feel free to submit patches and bug reports on the [project page][10]. + +* * * + +[Stephane Peter][2] + + [1]: http://makeself.io/ + [2]: mailto:megastep@megastep.org + [3]: http://www.idsoftware.com/ + [4]: http://www.lokigames.com/products/myth2/updates.php3 + [5]: http://www.nvidia.com/ + [6]: http://earth.google.com/ + [7]: http://www.virtualbox.org/ + [8]: http://www.gnu.org/copyleft/gpl.html + [9]: https://github.com/megastep/makeself/releases/download/release-2.3.1/makeself-2.3.1.run + [10]: https://github.com/megastep/makeself + [11]: https://github.com/megastep/loki_setup/ + [12]: http://www.unrealtournament2003.com/ + [13]: http://www.icculus.org/ + [14]: http://bre.klaki.net/programs/setup.sh/ + [15]: https://stephanepeter.com/ diff --git a/Packaging/makeself/makeself-header.sh b/Packaging/makeself/makeself-header.sh new file mode 100755 index 0000000000000000000000000000000000000000..83131a17c261c94746da9df54c754ccb4f4b10ab --- /dev/null +++ b/Packaging/makeself/makeself-header.sh @@ -0,0 +1,553 @@ +cat << EOF > "$archname" +#!/bin/sh +# This script was generated using Makeself $MS_VERSION + +ORIG_UMASK=\`umask\` +if test "$KEEP_UMASK" = n; then + umask 077 +fi + +CRCsum="$CRCsum" +MD5="$MD5sum" +TMPROOT=\${TMPDIR:=/tmp} +USER_PWD="\$PWD"; export USER_PWD + +label="$LABEL" +script="$SCRIPT" +scriptargs="$SCRIPTARGS" +licensetxt="$LICENSE" +helpheader='$HELPHEADER' +targetdir="$archdirname" +filesizes="$filesizes" +keep="$KEEP" +nooverwrite="$NOOVERWRITE" +quiet="n" +accept="n" +nodiskspace="n" +export_conf="$EXPORT_CONF" + +print_cmd_arg="" +if type printf > /dev/null; then + print_cmd="printf" +elif test -x /usr/ucb/echo; then + print_cmd="/usr/ucb/echo" +else + print_cmd="echo" +fi + +if test -d /usr/xpg4/bin; then + PATH=/usr/xpg4/bin:\$PATH + export PATH +fi + +unset CDPATH + +MS_Printf() +{ + \$print_cmd \$print_cmd_arg "\$1" +} + +MS_PrintLicense() +{ + if test x"\$licensetxt" != x; then + echo "\$licensetxt" + if test x"\$accept" != xy; then + while true + do + MS_Printf "Please type y to accept, n otherwise: " + read yn + if test x"\$yn" = xn; then + keep=n + eval \$finish; exit 1 + break; + elif test x"\$yn" = xy; then + break; + fi + done + fi + fi +} + +MS_diskspace() +{ + ( + df -kP "\$1" | tail -1 | awk '{ if (\$4 ~ /%/) {print \$3} else {print \$4} }' + ) +} + +MS_dd() +{ + blocks=\`expr \$3 / 1024\` + bytes=\`expr \$3 % 1024\` + dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\ + { test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\ + test \$bytes -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null +} + +MS_dd_Progress() +{ + if test x"\$noprogress" = xy; then + MS_dd \$@ + return \$? + fi + file="\$1" + offset=\$2 + length=\$3 + pos=0 + bsize=4194304 + while test \$bsize -gt \$length; do + bsize=\`expr \$bsize / 4\` + done + blocks=\`expr \$length / \$bsize\` + bytes=\`expr \$length % \$bsize\` + ( + dd ibs=\$offset skip=1 2>/dev/null + pos=\`expr \$pos \+ \$bsize\` + MS_Printf " 0%% " 1>&2 + if test \$blocks -gt 0; then + while test \$pos -le \$length; do + dd bs=\$bsize count=1 2>/dev/null + pcent=\`expr \$length / 100\` + pcent=\`expr \$pos / \$pcent\` + if test \$pcent -lt 100; then + MS_Printf "\b\b\b\b\b\b\b" 1>&2 + if test \$pcent -lt 10; then + MS_Printf " \$pcent%% " 1>&2 + else + MS_Printf " \$pcent%% " 1>&2 + fi + fi + pos=\`expr \$pos \+ \$bsize\` + done + fi + if test \$bytes -gt 0; then + dd bs=\$bytes count=1 2>/dev/null + fi + MS_Printf "\b\b\b\b\b\b\b" 1>&2 + MS_Printf " 100%% " 1>&2 + ) < "\$file" +} + +MS_Help() +{ + cat << EOH >&2 +\${helpheader}Makeself version $MS_VERSION + 1) Getting help or info about \$0 : + \$0 --help Print this message + \$0 --info Print embedded info : title, default target directory, embedded script ... + \$0 --lsm Print embedded lsm entry (or no LSM) + \$0 --list Print the list of files in the archive + \$0 --check Checks integrity of the archive + + 2) Running \$0 : + \$0 [options] [--] [additional arguments to embedded script] + with following options (in that order) + --confirm Ask before running embedded script + --quiet Do not print anything except error messages + --accept Accept the license + --noexec Do not run embedded script + --keep Do not erase target directory after running + the embedded script + --noprogress Do not show the progress during the decompression + --nox11 Do not spawn an xterm + --nochown Do not give the extracted files to the current user + --nodiskspace Do not check for available disk space + --target dir Extract directly to a target directory + directory path can be either absolute or relative + --tar arg1 [arg2 ...] Access the contents of the archive through the tar command + -- Following arguments will be passed to the embedded script +EOH +} + +MS_Check() +{ + OLD_PATH="\$PATH" + PATH=\${GUESS_MD5_PATH:-"\$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"} + MD5_ARG="" + MD5_PATH=\`exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum\` + test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which md5 || command -v md5 || type md5\` + test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which digest || command -v digest || type digest\` + PATH="\$OLD_PATH" + + if test x"\$quiet" = xn; then + MS_Printf "Verifying archive integrity..." + fi + offset=\`head -n $SKIP "\$1" | wc -c | tr -d " "\` + verb=\$2 + i=1 + for s in \$filesizes + do + crc=\`echo \$CRCsum | cut -d" " -f\$i\` + if test -x "\$MD5_PATH"; then + if test x"\`basename \$MD5_PATH\`" = xdigest; then + MD5_ARG="-a md5" + fi + md5=\`echo \$MD5 | cut -d" " -f\$i\` + if test x"\$md5" = x00000000000000000000000000000000; then + test x"\$verb" = xy && echo " \$1 does not contain an embedded MD5 checksum." >&2 + else + md5sum=\`MS_dd_Progress "\$1" \$offset \$s | eval "\$MD5_PATH \$MD5_ARG" | cut -b-32\`; + if test x"\$md5sum" != x"\$md5"; then + echo "Error in MD5 checksums: \$md5sum is different from \$md5" >&2 + exit 2 + else + test x"\$verb" = xy && MS_Printf " MD5 checksums are OK." >&2 + fi + crc="0000000000"; verb=n + fi + fi + if test x"\$crc" = x0000000000; then + test x"\$verb" = xy && echo " \$1 does not contain a CRC checksum." >&2 + else + sum1=\`MS_dd_Progress "\$1" \$offset \$s | CMD_ENV=xpg4 cksum | awk '{print \$1}'\` + if test x"\$sum1" = x"\$crc"; then + test x"\$verb" = xy && MS_Printf " CRC checksums are OK." >&2 + else + echo "Error in checksums: \$sum1 is different from \$crc" >&2 + exit 2; + fi + fi + i=\`expr \$i + 1\` + offset=\`expr \$offset + \$s\` + done + if test x"\$quiet" = xn; then + echo " All good." + fi +} + +UnTAR() +{ + if test x"\$quiet" = xn; then + tar \$1vf - $UNTAR_EXTRA 2>&1 || { echo " ... Extraction failed." > /dev/tty; kill -15 \$$; } + else + tar \$1f - $UNTAR_EXTRA 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 \$$; } + fi +} + +finish=true +xterm_loop= +noprogress=$NOPROGRESS +nox11=$NOX11 +copy=$COPY +ownership=y +verbose=n + +initargs="\$@" + +while true +do + case "\$1" in + -h | --help) + MS_Help + exit 0 + ;; + -q | --quiet) + quiet=y + noprogress=y + shift + ;; + --accept) + accept=y + shift + ;; + --info) + echo Identification: "\$label" + echo Target directory: "\$targetdir" + echo Uncompressed size: $USIZE KB + echo Compression: $COMPRESS + echo Date of packaging: $DATE + echo Built with Makeself version $MS_VERSION on $OSTYPE + echo Build command was: "$MS_COMMAND" + if test x"\$script" != x; then + echo Script run after extraction: + echo " " \$script \$scriptargs + fi + if test x"$copy" = xcopy; then + echo "Archive will copy itself to a temporary location" + fi + if test x"$NEED_ROOT" = xy; then + echo "Root permissions required for extraction" + fi + if test x"$KEEP" = xy; then + echo "directory \$targetdir is permanent" + else + echo "\$targetdir will be removed after extraction" + fi + exit 0 + ;; + --dumpconf) + echo LABEL=\"\$label\" + echo SCRIPT=\"\$script\" + echo SCRIPTARGS=\"\$scriptargs\" + echo archdirname=\"$archdirname\" + echo KEEP=$KEEP + echo NOOVERWRITE=$NOOVERWRITE + echo COMPRESS=$COMPRESS + echo filesizes=\"\$filesizes\" + echo CRCsum=\"\$CRCsum\" + echo MD5sum=\"\$MD5\" + echo OLDUSIZE=$USIZE + echo OLDSKIP=`expr $SKIP + 1` + exit 0 + ;; + --lsm) +cat << EOLSM +EOF +eval "$LSM_CMD" +cat << EOF >> "$archname" +EOLSM + exit 0 + ;; + --list) + echo Target directory: \$targetdir + offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\` + for s in \$filesizes + do + MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | UnTAR t + offset=\`expr \$offset + \$s\` + done + exit 0 + ;; + --tar) + offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\` + arg1="\$2" + if ! shift 2; then MS_Help; exit 1; fi + for s in \$filesizes + do + MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | tar "\$arg1" - "\$@" + offset=\`expr \$offset + \$s\` + done + exit 0 + ;; + --check) + MS_Check "\$0" y + exit 0 + ;; + --confirm) + verbose=y + shift + ;; + --noexec) + script="" + shift + ;; + --keep) + keep=y + shift + ;; + --target) + keep=y + targetdir=\${2:-.} + if ! shift 2; then MS_Help; exit 1; fi + ;; + --noprogress) + noprogress=y + shift + ;; + --nox11) + nox11=y + shift + ;; + --nochown) + ownership=n + shift + ;; + --nodiskspace) + nodiskspace=y + shift + ;; + --xwin) + if test "$NOWAIT" = n; then + finish="echo Press Return to close this window...; read junk" + fi + xterm_loop=1 + shift + ;; + --phase2) + copy=phase2 + shift + ;; + --) + shift + break ;; + -*) + echo Unrecognized flag : "\$1" >&2 + MS_Help + exit 1 + ;; + *) + break ;; + esac +done + +if test x"\$quiet" = xy -a x"\$verbose" = xy; then + echo Cannot be verbose and quiet at the same time. >&2 + exit 1 +fi + +if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then + echo "Administrative privileges required for this archive (use su or sudo)" >&2 + exit 1 +fi + +if test x"\$copy" \!= xphase2; then + MS_PrintLicense +fi + +case "\$copy" in +copy) + tmpdir=\$TMPROOT/makeself.\$RANDOM.\`date +"%y%m%d%H%M%S"\`.\$\$ + mkdir "\$tmpdir" || { + echo "Could not create temporary directory \$tmpdir" >&2 + exit 1 + } + SCRIPT_COPY="\$tmpdir/makeself" + echo "Copying to a temporary location..." >&2 + cp "\$0" "\$SCRIPT_COPY" + chmod +x "\$SCRIPT_COPY" + cd "\$TMPROOT" + exec "\$SCRIPT_COPY" --phase2 -- \$initargs + ;; +phase2) + finish="\$finish ; rm -rf \`dirname \$0\`" + ;; +esac + +if test x"\$nox11" = xn; then + if tty -s; then # Do we have a terminal? + : + else + if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then # No, but do we have X? + if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable + GUESS_XTERMS="xterm gnome-terminal rxvt dtterm eterm Eterm xfce4-terminal lxterminal kvt konsole aterm terminology" + for a in \$GUESS_XTERMS; do + if type \$a >/dev/null 2>&1; then + XTERM=\$a + break + fi + done + chmod a+x \$0 || echo Please add execution rights on \$0 + if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal! + exec \$XTERM -title "\$label" -e "\$0" --xwin "\$initargs" + else + exec \$XTERM -title "\$label" -e "./\$0" --xwin "\$initargs" + fi + fi + fi + fi +fi + +if test x"\$targetdir" = x.; then + tmpdir="." +else + if test x"\$keep" = xy; then + if test x"\$nooverwrite" = xy && test -d "\$targetdir"; then + echo "Target directory \$targetdir already exists, aborting." >&2 + exit 1 + fi + if test x"\$quiet" = xn; then + echo "Creating directory \$targetdir" >&2 + fi + tmpdir="\$targetdir" + dashp="-p" + else + tmpdir="\$TMPROOT/selfgz\$\$\$RANDOM" + dashp="" + fi + mkdir \$dashp \$tmpdir || { + echo 'Cannot create target directory' \$tmpdir >&2 + echo 'You should try option --target dir' >&2 + eval \$finish + exit 1 + } +fi + +location="\`pwd\`" +if test x"\$SETUP_NOCHECK" != x1; then + MS_Check "\$0" +fi +offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\` + +if test x"\$verbose" = xy; then + MS_Printf "About to extract $USIZE KB in \$tmpdir ... Proceed ? [Y/n] " + read yn + if test x"\$yn" = xn; then + eval \$finish; exit 1 + fi +fi + +if test x"\$quiet" = xn; then + MS_Printf "Uncompressing \$label" +fi +res=3 +if test x"\$keep" = xn; then + trap 'echo Signal caught, cleaning up >&2; cd \$TMPROOT; /bin/rm -rf \$tmpdir; eval \$finish; exit 15' 1 2 3 15 +fi + +if test x"\$nodiskspace" = xn; then + leftspace=\`MS_diskspace \$tmpdir\` + if test -n "\$leftspace"; then + if test "\$leftspace" -lt $USIZE; then + echo + echo "Not enough space left in "\`dirname \$tmpdir\`" (\$leftspace KB) to decompress \$0 ($USIZE KB)" >&2 + echo "Use --nodiskspace option to skip this check and proceed anyway" >&2 + if test x"\$keep" = xn; then + echo "Consider setting TMPDIR to a directory with more free space." + fi + eval \$finish; exit 1 + fi + fi +fi + +for s in \$filesizes +do + if MS_dd_Progress "\$0" \$offset \$s | eval "$GUNZIP_CMD" | ( cd "\$tmpdir"; umask \$ORIG_UMASK ; UnTAR xp ) 1>/dev/null; then + if test x"\$ownership" = xy; then + (cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .) + fi + else + echo >&2 + echo "Unable to decompress \$0" >&2 + eval \$finish; exit 1 + fi + offset=\`expr \$offset + \$s\` +done +if test x"\$quiet" = xn; then + echo +fi + +cd "\$tmpdir" +res=0 +if test x"\$script" != x; then + if test x"\$export_conf" = x"y"; then + MS_BUNDLE="\$0" + MS_LABEL="\$label" + MS_SCRIPT="\$script" + MS_SCRIPTARGS="\$scriptargs" + MS_ARCHDIRNAME="\$archdirname" + MS_KEEP="\$KEEP" + MS_NOOVERWRITE="\$NOOVERWRITE" + MS_COMPRESS="\$COMPRESS" + export MS_BUNDLE MS_LABEL MS_SCRIPT MS_SCRIPTARGS + export MS_ARCHDIRNAME MS_KEEP MS_NOOVERWRITE MS_COMPRESS + fi + + if test x"\$verbose" = x"y"; then + MS_Printf "OK to execute: \$script \$scriptargs \$* ? [Y/n] " + read yn + if test x"\$yn" = x -o x"\$yn" = xy -o x"\$yn" = xY; then + eval "\"\$script\" \$scriptargs \"\\\$@\""; res=\$?; + fi + else + eval "\"\$script\" \$scriptargs \"\\\$@\""; res=\$? + fi + if test "\$res" -ne 0; then + test x"\$verbose" = xy && echo "The program '\$script' returned an error code (\$res)" >&2 + fi +fi +if test x"\$keep" = xn; then + cd \$TMPROOT + /bin/rm -rf \$tmpdir +fi +eval \$finish; exit \$res +EOF diff --git a/Packaging/makeself/makeself.1 b/Packaging/makeself/makeself.1 new file mode 100644 index 0000000000000000000000000000000000000000..abab2301b720620b1ef54db22e9434ce89f1c34a --- /dev/null +++ b/Packaging/makeself/makeself.1 @@ -0,0 +1,104 @@ +.TH "makeself" "1" "2.1.6" +.SH "NAME" +makeself \- An utility to generate self-extractable archives. +.SH "SYNTAX" +.LP +.B makeself [\fIoptions\fP] archive_dir file_name label +.B [\fIstartup_script\fP] [\fIargs\fP] +.SH "DESCRIPTION" +.LP +This program is a free (GPL) utility designed to create self-extractable +archives from a directory. +.br +.SH "OPTIONS" +.LP +The following options are supported. +.LP +.TP 15 +.B -v, --version +Prints out the makeself version number and exits. +.TP +.B -h, --help +Print out help information. +.TP +.B --tar-quietly +Suppress verbose output from the tar command +.TP +.B --quiet +Do not print any messages other than errors +.TP +.B --gzip +Compress using gzip (default if detected). +.TP +.B --bzip2 +Compress using bzip2. +.TP +.B --pbzip2 +Compress using pbzip2. +.TP +.B --xz +Compress using xz. +.TP +.B --lzo +Compress using lzop. +.TP +.B --lz4 +Compress using lz4. +.TP +.B --compress +Compress using the UNIX 'compress' command. +.TP +.B --nocomp +Do not compress the data. +.TP +.B --complevel lvl +Specify the compression level for gzip,bzip2,pbzui2,xz,lzo or lz4 +.TP +.B --notemp +The archive will create archive_dir in the current directory and +uncompress in ./archive_dir. +.TP +.B --copy +Upon extraction, the archive will first copy itself to a temporary directory. +.TP +.B --append +Append more files to an existing makeself archive. The label and startup scripts will then be ignored. +.TP +.B --current +Files will be extracted to the current directory. Both --current and --target dir imply --notemp. +.TP +.B --target dir +Extract directly to a target directory. Directory path can be either absolute or relative. +.TP +.B --header file +Specify location of the header script. +.TP +.B --follow +Follow the symlinks in the archive. +.TP +.B --noprogress +Do not show the progress during the decompression. +.TP +.B --nox11 +Disable automatic spawn of an xterm if running in X11. +.TP +.B --nowait +Do not wait for user input after executing embedded program from an xterm. +.TP +.B --nomd5 +Do not create a MD5 checksum for the archive. +.TP +.B --nocrc +Do not create a CRC32 checksum for the archive. +.TP +.B --lsm file +LSM file describing the package. +.B --packaging-date date +Use provided string as the packaging date instead of the current date. +.PD +.SH "AUTHORS" +.LP +Makeself has been written by Stéphane Peter <megastep@megastep.org>. +.BR +This man page was originally written by Bartosz Fenski <fenio@o2.pl> for the +Debian GNU/Linux distribution (but it may be used by others). diff --git a/Packaging/makeself/makeself.lsm b/Packaging/makeself/makeself.lsm new file mode 100644 index 0000000000000000000000000000000000000000..e32722ed514c4963b1109f67623ce6d0529fb889 --- /dev/null +++ b/Packaging/makeself/makeself.lsm @@ -0,0 +1,16 @@ +Begin3 +Title: makeself.sh +Version: 2.3.0 +Description: makeself.sh is a shell script that generates a self-extractable + tar.gz archive from a directory. The resulting file appears as a shell + script, and can be launched as is. The archive will then uncompress + itself to a temporary directory and an arbitrary command will be + executed (for example an installation script). This is pretty similar + to archives generated with WinZip Self-Extractor in the Windows world. +Keywords: Installation archive tar winzip +Author: Stephane Peter (megastep@megastep.org) +Maintained-by: Stephane Peter (megastep@megastep.org) +Original-site: http://makeself.io/ +Platform: Unix +Copying-policy: GPL +End diff --git a/Packaging/makeself/makeself.sh b/Packaging/makeself/makeself.sh new file mode 100755 index 0000000000000000000000000000000000000000..a2bb226d1ece2a46139dd6e8a1866100e10b65cb --- /dev/null +++ b/Packaging/makeself/makeself.sh @@ -0,0 +1,620 @@ +#!/bin/sh +# +# Makeself version 2.3.x +# by Stephane Peter <megastep@megastep.org> +# +# Utility to create self-extracting tar.gz archives. +# The resulting archive is a file holding the tar.gz archive with +# a small Shell script stub that uncompresses the archive to a temporary +# directory and then executes a given script from withing that directory. +# +# Makeself home page: http://makeself.io/ +# +# Version 2.0 is a rewrite of version 1.0 to make the code easier to read and maintain. +# +# Version history : +# - 1.0 : Initial public release +# - 1.1 : The archive can be passed parameters that will be passed on to +# the embedded script, thanks to John C. Quillan +# - 1.2 : Package distribution, bzip2 compression, more command line options, +# support for non-temporary archives. Ideas thanks to Francois Petitjean +# - 1.3 : More patches from Bjarni R. Einarsson and Francois Petitjean: +# Support for no compression (--nocomp), script is no longer mandatory, +# automatic launch in an xterm, optional verbose output, and -target +# archive option to indicate where to extract the files. +# - 1.4 : Improved UNIX compatibility (Francois Petitjean) +# Automatic integrity checking, support of LSM files (Francois Petitjean) +# - 1.5 : Many bugfixes. Optionally disable xterm spawning. +# - 1.5.1 : More bugfixes, added archive options -list and -check. +# - 1.5.2 : Cosmetic changes to inform the user of what's going on with big +# archives (Quake III demo) +# - 1.5.3 : Check for validity of the DISPLAY variable before launching an xterm. +# More verbosity in xterms and check for embedded command's return value. +# Bugfix for Debian 2.0 systems that have a different "print" command. +# - 1.5.4 : Many bugfixes. Print out a message if the extraction failed. +# - 1.5.5 : More bugfixes. Added support for SETUP_NOCHECK environment variable to +# bypass checksum verification of archives. +# - 1.6.0 : Compute MD5 checksums with the md5sum command (patch from Ryan Gordon) +# - 2.0 : Brand new rewrite, cleaner architecture, separated header and UNIX ports. +# - 2.0.1 : Added --copy +# - 2.1.0 : Allow multiple tarballs to be stored in one archive, and incremental updates. +# Added --nochown for archives +# Stopped doing redundant checksums when not necesary +# - 2.1.1 : Work around insane behavior from certain Linux distros with no 'uncompress' command +# Cleaned up the code to handle error codes from compress. Simplified the extraction code. +# - 2.1.2 : Some bug fixes. Use head -n to avoid problems. +# - 2.1.3 : Bug fixes with command line when spawning terminals. +# Added --tar for archives, allowing to give arbitrary arguments to tar on the contents of the archive. +# Added --noexec to prevent execution of embedded scripts. +# Added --nomd5 and --nocrc to avoid creating checksums in archives. +# Added command used to create the archive in --info output. +# Run the embedded script through eval. +# - 2.1.4 : Fixed --info output. +# Generate random directory name when extracting files to . to avoid problems. (Jason Trent) +# Better handling of errors with wrong permissions for the directory containing the files. (Jason Trent) +# Avoid some race conditions (Ludwig Nussel) +# Unset the $CDPATH variable to avoid problems if it is set. (Debian) +# Better handling of dot files in the archive directory. +# - 2.1.5 : Made the md5sum detection consistent with the header code. +# Check for the presence of the archive directory +# Added --encrypt for symmetric encryption through gpg (Eric Windisch) +# Added support for the digest command on Solaris 10 for MD5 checksums +# Check for available disk space before extracting to the target directory (Andreas Schweitzer) +# Allow extraction to run asynchronously (patch by Peter Hatch) +# Use file descriptors internally to avoid error messages (patch by Kay Tiong Khoo) +# - 2.1.6 : Replaced one dot per file progress with a realtime progress percentage and a spining cursor (Guy Baconniere) +# Added --noprogress to prevent showing the progress during the decompression (Guy Baconniere) +# Added --target dir to allow extracting directly to a target directory (Guy Baconniere) +# - 2.2.0 : Many bugfixes, updates and contributions from users. Check out the project page on Github for the details. +# - 2.3.0 : Option to specify packaging date to enable byte-for-byte reproducibility. (Marc Pawlowsky) +# +# (C) 1998-2017 by Stephane Peter <megastep@megastep.org> +# +# This software is released under the terms of the GNU GPL version 2 and above +# Please read the license at http://www.gnu.org/copyleft/gpl.html +# + +MS_VERSION=2.3.1 +MS_COMMAND="$0" +unset CDPATH + +for f in "${1+"$@"}"; do + MS_COMMAND="$MS_COMMAND \\\\ + \\\"$f\\\"" +done + +# For Solaris systems +if test -d /usr/xpg4/bin; then + PATH=/usr/xpg4/bin:$PATH + export PATH +fi + +# Procedures + +MS_Usage() +{ + echo "Usage: $0 [params] archive_dir file_name label startup_script [args]" + echo "params can be one or more of the following :" + echo " --version | -v : Print out Makeself version number and exit" + echo " --help | -h : Print out this help message" + echo " --tar-quietly : Suppress verbose output from the tar command" + echo " --quiet | -q : Do not print any messages other than errors." + echo " --gzip : Compress using gzip (default if detected)" + echo " --pigz : Compress with pigz" + echo " --bzip2 : Compress using bzip2 instead of gzip" + echo " --pbzip2 : Compress using pbzip2 instead of gzip" + echo " --xz : Compress using xz instead of gzip" + echo " --lzo : Compress using lzop instead of gzip" + echo " --lz4 : Compress using lz4 instead of gzip" + echo " --compress : Compress using the UNIX 'compress' command" + echo " --complevel lvl : Compression level for gzip pigz xz lzo lz4 bzip2 and pbzip2 (default 9)" + echo " --base64 : Instead of compressing, encode the data using base64" + echo " --gpg-encrypt : Instead of compressing, encrypt the data using GPG" + echo " --gpg-asymmetric-encrypt-sign" + echo " : Instead of compressing, asymmetrically encrypt and sign the data using GPG" + echo " --gpg-extra opt : Append more options to the gpg command line" + echo " --ssl-encrypt : Instead of compressing, encrypt the data using OpenSSL" + echo " --nocomp : Do not compress the data" + echo " --notemp : The archive will create archive_dir in the" + echo " current directory and uncompress in ./archive_dir" + echo " --needroot : Check that the root user is extracting the archive before proceeding" + echo " --copy : Upon extraction, the archive will first copy itself to" + echo " a temporary directory" + echo " --append : Append more files to an existing Makeself archive" + echo " The label and startup scripts will then be ignored" + echo " --target dir : Extract directly to a target directory" + echo " directory path can be either absolute or relative" + echo " --nooverwrite : Do not extract the archive if the specified target directory exists" + echo " --current : Files will be extracted to the current directory" + echo " Both --current and --target imply --notemp" + echo " --tar-extra opt : Append more options to the tar command line" + echo " --untar-extra opt : Append more options to the during the extraction of the tar archive" + echo " --nomd5 : Don't calculate an MD5 for archive" + echo " --nocrc : Don't calculate a CRC for archive" + echo " --header file : Specify location of the header script" + echo " --follow : Follow the symlinks in the archive" + echo " --noprogress : Do not show the progress during the decompression" + echo " --nox11 : Disable automatic spawn of a xterm" + echo " --nowait : Do not wait for user input after executing embedded" + echo " program from an xterm" + echo " --lsm file : LSM file describing the package" + echo " --license file : Append a license file" + echo " --help-header file : Add a header to the archive's --help output" + echo " --packaging-date date" + echo " : Use provided string as the packaging date" + echo " instead of the current date." + echo + echo " --keep-umask : Keep the umask set to shell default, rather than overriding when executing self-extracting archive." + echo " --export-conf : Export configuration variables to startup_script" + echo + echo "Do not forget to give a fully qualified startup script name" + echo "(i.e. with a ./ prefix if inside the archive)." + exit 1 +} + +# Default settings +if type gzip 2>&1 > /dev/null; then + COMPRESS=gzip +else + COMPRESS=Unix +fi +COMPRESS_LEVEL=9 +KEEP=n +CURRENT=n +NOX11=n +NOWAIT=n +APPEND=n +TAR_QUIETLY=n +KEEP_UMASK=n +QUIET=n +NOPROGRESS=n +COPY=none +NEED_ROOT=n +TAR_ARGS=cvf +TAR_EXTRA="" +GPG_EXTRA="" +DU_ARGS=-ks +HEADER=`dirname "$0"`/makeself-header.sh +TARGETDIR="" +NOOVERWRITE=n +DATE=`LC_ALL=C date` +EXPORT_CONF=n + +# LSM file stuff +LSM_CMD="echo No LSM. >> \"\$archname\"" + +while true +do + case "$1" in + --version | -v) + echo Makeself version $MS_VERSION + exit 0 + ;; + --pbzip2) + COMPRESS=pbzip2 + shift + ;; + --bzip2) + COMPRESS=bzip2 + shift + ;; + --gzip) + COMPRESS=gzip + shift + ;; + --pigz) + COMPRESS=pigz + shift + ;; + --xz) + COMPRESS=xz + shift + ;; + --lzo) + COMPRESS=lzo + shift + ;; + --lz4) + COMPRESS=lz4 + shift + ;; + --compress) + COMPRESS=Unix + shift + ;; + --base64) + COMPRESS=base64 + shift + ;; + --gpg-encrypt) + COMPRESS=gpg + shift + ;; + --gpg-asymmetric-encrypt-sign) + COMPRESS=gpg-asymmetric + shift + ;; + --gpg-extra) + GPG_EXTRA="$2" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --ssl-encrypt) + COMPRESS=openssl + shift + ;; + --nocomp) + COMPRESS=none + shift + ;; + --complevel) + COMPRESS_LEVEL="$2" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --notemp) + KEEP=y + shift + ;; + --copy) + COPY=copy + shift + ;; + --current) + CURRENT=y + KEEP=y + shift + ;; + --tar-extra) + TAR_EXTRA="$2" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --untar-extra) + UNTAR_EXTRA="$2" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --target) + TARGETDIR="$2" + KEEP=y + if ! shift 2; then MS_Help; exit 1; fi + ;; + --nooverwrite) + NOOVERWRITE=y + shift + ;; + --needroot) + NEED_ROOT=y + shift + ;; + --header) + HEADER="$2" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --license) + LICENSE=`cat $2` + if ! shift 2; then MS_Help; exit 1; fi + ;; + --follow) + TAR_ARGS=cvhf + DU_ARGS=-ksL + shift + ;; + --noprogress) + NOPROGRESS=y + shift + ;; + --nox11) + NOX11=y + shift + ;; + --nowait) + NOWAIT=y + shift + ;; + --nomd5) + NOMD5=y + shift + ;; + --nocrc) + NOCRC=y + shift + ;; + --append) + APPEND=y + shift + ;; + --lsm) + LSM_CMD="cat \"$2\" >> \"\$archname\"" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --packaging-date) + DATE="$2" + if ! shift 2; then MS_Help; exit 1; fi + ;; + --help-header) + HELPHEADER=`sed -e "s/'/'\\\\\''/g" $2` + if ! shift 2; then MS_Help; exit 1; fi + [ -n "$HELPHEADER" ] && HELPHEADER="$HELPHEADER +" + ;; + --tar-quietly) + TAR_QUIETLY=y + shift + ;; + --keep-umask) + KEEP_UMASK=y + shift + ;; + --export-conf) + EXPORT_CONF=y + shift + ;; + -q | --quiet) + QUIET=y + shift + ;; + -h | --help) + MS_Usage + ;; + -*) + echo Unrecognized flag : "$1" + MS_Usage + ;; + *) + break + ;; + esac +done + +if test $# -lt 1; then + MS_Usage +else + if test -d "$1"; then + archdir="$1" + else + echo "Directory $1 does not exist." >&2 + exit 1 + fi +fi +archname="$2" + +if test "$QUIET" = "y" || test "$TAR_QUIETLY" = "y"; then + if test "$TAR_ARGS" = "cvf"; then + TAR_ARGS="cf" + elif test "$TAR_ARGS" = "cvhf";then + TAR_ARGS="chf" + fi +fi + +if test "$APPEND" = y; then + if test $# -lt 2; then + MS_Usage + fi + + # Gather the info from the original archive + OLDENV=`sh "$archname" --dumpconf` + if test $? -ne 0; then + echo "Unable to update archive: $archname" >&2 + exit 1 + else + eval "$OLDENV" + fi +else + if test "$KEEP" = n -a $# = 3; then + echo "ERROR: Making a temporary archive with no embedded command does not make sense!" >&2 + echo >&2 + MS_Usage + fi + # We don't want to create an absolute directory unless a target directory is defined + if test "$CURRENT" = y; then + archdirname="." + elif test x$TARGETDIR != x; then + archdirname="$TARGETDIR" + else + archdirname=`basename "$1"` + fi + + if test $# -lt 3; then + MS_Usage + fi + + LABEL="$3" + SCRIPT="$4" + test "x$SCRIPT" = x || shift 1 + shift 3 + SCRIPTARGS="$*" +fi + +if test "$KEEP" = n -a "$CURRENT" = y; then + echo "ERROR: It is A VERY DANGEROUS IDEA to try to combine --notemp and --current." >&2 + exit 1 +fi + +case $COMPRESS in +gzip) + GZIP_CMD="gzip -c$COMPRESS_LEVEL" + GUNZIP_CMD="gzip -cd" + ;; +pigz) + GZIP_CMD="pigz -$COMPRESS_LEVEL" + GUNZIP_CMD="gzip -cd" + ;; +pbzip2) + GZIP_CMD="pbzip2 -c$COMPRESS_LEVEL" + GUNZIP_CMD="bzip2 -d" + ;; +bzip2) + GZIP_CMD="bzip2 -$COMPRESS_LEVEL" + GUNZIP_CMD="bzip2 -d" + ;; +xz) + GZIP_CMD="xz -c$COMPRESS_LEVEL" + GUNZIP_CMD="xz -d" + ;; +lzo) + GZIP_CMD="lzop -c$COMPRESS_LEVEL" + GUNZIP_CMD="lzop -d" + ;; +lz4) + GZIP_CMD="lz4 -c$COMPRESS_LEVEL" + GUNZIP_CMD="lz4 -d" + ;; +base64) + GZIP_CMD="base64" + GUNZIP_CMD="base64 -d -i" + ;; +gpg) + GZIP_CMD="gpg $GPG_EXTRA -ac -z$COMPRESS_LEVEL" + GUNZIP_CMD="gpg -d" + ;; +gpg-asymmetric) + GZIP_CMD="gpg $GPG_EXTRA -z$COMPRESS_LEVEL -es" + GUNZIP_CMD="gpg --yes -d" + ;; +openssl) + GZIP_CMD="openssl aes-256-cbc -a -salt" + GUNZIP_CMD="openssl aes-256-cbc -d -a" + ;; +Unix) + GZIP_CMD="compress -cf" + GUNZIP_CMD="exec 2>&-; uncompress -c || test \\\$? -eq 2 || gzip -cd" + ;; +none) + GZIP_CMD="cat" + GUNZIP_CMD="cat" + ;; +esac + +tmpfile="${TMPDIR:=/tmp}/mkself$$" + +if test -f "$HEADER"; then + oldarchname="$archname" + archname="$tmpfile" + # Generate a fake header to count its lines + SKIP=0 + . "$HEADER" + SKIP=`cat "$tmpfile" |wc -l` + # Get rid of any spaces + SKIP=`expr $SKIP` + rm -f "$tmpfile" + if test "$QUIET" = "n";then + echo Header is $SKIP lines long >&2 + fi + + archname="$oldarchname" +else + echo "Unable to open header file: $HEADER" >&2 + exit 1 +fi + +if test "$QUIET" = "n";then + echo +fi + +if test "$APPEND" = n; then + if test -f "$archname"; then + echo "WARNING: Overwriting existing file: $archname" >&2 + fi +fi + +USIZE=`du $DU_ARGS "$archdir" | awk '{print $1}'` + +if test "." = "$archdirname"; then + if test "$KEEP" = n; then + archdirname="makeself-$$-`date +%Y%m%d%H%M%S`" + fi +fi + +test -d "$archdir" || { echo "Error: $archdir does not exist."; rm -f "$tmpfile"; exit 1; } +if test "$QUIET" = "n";then + echo About to compress $USIZE KB of data... + echo Adding files to archive named \"$archname\"... +fi +exec 3<> "$tmpfile" +( cd "$archdir" && ( tar $TAR_EXTRA -$TAR_ARGS - . | eval "$GZIP_CMD" >&3 ) ) || \ + { echo Aborting: archive directory not found or temporary file: "$tmpfile" could not be created.; exec 3>&-; rm -f "$tmpfile"; exit 1; } +exec 3>&- # try to close the archive + +fsize=`cat "$tmpfile" | wc -c | tr -d " "` + +# Compute the checksums + +md5sum=00000000000000000000000000000000 +crcsum=0000000000 + +if test "$NOCRC" = y; then + if test "$QUIET" = "n";then + echo "skipping crc at user request" + fi +else + crcsum=`cat "$tmpfile" | CMD_ENV=xpg4 cksum | sed -e 's/ /Z/' -e 's/ /Z/' | cut -dZ -f1` + if test "$QUIET" = "n";then + echo "CRC: $crcsum" + fi +fi + +if test "$NOMD5" = y; then + if test "$QUIET" = "n";then + echo "skipping md5sum at user request" + fi +else + # Try to locate a MD5 binary + OLD_PATH=$PATH + PATH=${GUESS_MD5_PATH:-"$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"} + MD5_ARG="" + MD5_PATH=`exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum` + test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which md5 || command -v md5 || type md5` + test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which digest || command -v digest || type digest` + PATH=$OLD_PATH + if test -x "$MD5_PATH"; then + if test `basename ${MD5_PATH}`x = digestx; then + MD5_ARG="-a md5" + fi + md5sum=`cat "$tmpfile" | eval "$MD5_PATH $MD5_ARG" | cut -b-32`; + if test "$QUIET" = "n";then + echo "MD5: $md5sum" + fi + else + if test "$QUIET" = "n";then + echo "MD5: none, MD5 command not found" + fi + fi +fi + +if test "$APPEND" = y; then + mv "$archname" "$archname".bak || exit + + # Prepare entry for new archive + filesizes="$filesizes $fsize" + CRCsum="$CRCsum $crcsum" + MD5sum="$MD5sum $md5sum" + USIZE=`expr $USIZE + $OLDUSIZE` + # Generate the header + . "$HEADER" + # Append the original data + tail -n +$OLDSKIP "$archname".bak >> "$archname" + # Append the new data + cat "$tmpfile" >> "$archname" + + chmod +x "$archname" + rm -f "$archname".bak + if test "$QUIET" = "n";then + echo Self-extractable archive \"$archname\" successfully updated. + fi +else + filesizes="$fsize" + CRCsum="$crcsum" + MD5sum="$md5sum" + + # Generate the header + . "$HEADER" + + # Append the compressed tar data after the stub + if test "$QUIET" = "n";then + echo + fi + cat "$tmpfile" >> "$archname" + chmod +x "$archname" + if test "$QUIET" = "n";then + echo Self-extractable archive \"$archname\" successfully created. + fi +fi +rm -f "$tmpfile" diff --git a/Packaging/otb_update_makeself b/Packaging/otb_update_makeself new file mode 100644 index 0000000000000000000000000000000000000000..82405385262f3b28e652661732172ee1002455e3 --- /dev/null +++ b/Packaging/otb_update_makeself @@ -0,0 +1,11 @@ +HOWTO UPDATE MAKESELF + +#If makEself version with your required bug fix is 2.3.1 +# cd to otb/sources/Packaging/ + +wget https://github.com/megastep/makeself/archive/release-2.3.1.tar.gz +tar xzf release-2.3.1.tar.gz +mv makeself-release-2.3.1 makeself +rm -fr release-2.3.1.tar.gz + +run git diff to check if everything is in place and git commit diff --git a/Packaging/patch_cmake_files.cmake b/Packaging/patch_cmake_files.cmake new file mode 100644 index 0000000000000000000000000000000000000000..49ee420898e2aa1f3ecd402bc4d5c66fba27ee87 --- /dev/null +++ b/Packaging/patch_cmake_files.cmake @@ -0,0 +1,63 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(patch_cmake_files) + cmake_parse_arguments(PATCH "" "NAME;VERSION;MATCH_STRING;REPLACE_VAR" "" ${ARGN} ) + + set(PATCH_DIR_NAME ${PATCH_NAME}-${PATCH_VERSION}) + set(PATCH_DIR "${SUPERBUILD_INSTALL_DIR}/lib/cmake/${PATCH_DIR_NAME}") + set(PATCH_STAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/patched/${PATCH_DIR_NAME}) + + ##message("COPY ${PATCH_DIR} to ${PATCH_STAGE_DIR} for patching") + + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory "${PATCH_STAGE_DIR}" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${PATCH_DIR}" "${PATCH_STAGE_DIR}" + ) + + set(DIR_LIST "${PATCH_STAGE_DIR}|${PATCH_STAGE_DIR}/Modules") + + execute_process(COMMAND ${CMAKE_COMMAND} + -DP_DIRS=${DIR_LIST} + -DP_MATCH=${PATCH_MATCH_STRING} + -DP_REPLACE=${PATCH_REPLACE_VAR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/post_install.cmake + RESULT_VARIABLE patch_${PATCH_NAME}_cmake_rv + ) + + if(patch_${PATCH_NAME}_cmake_rv) + message(FATAL_ERROR " execute_process() failed.") + endif() + + install_without_message("${PATCH_STAGE_DIR}" "lib/cmake") + + # file( GLOB otb_opengl + # "${SUPERBUILD_INSTALL_DIR}/lib/cmake/OTB*/Modules/OTBOpenGL.cmake" ) + # if(EXISTS ${otb_opengl}) + # file(STRINGS "${otb_opengl}" otb_opengl_cmake) + # set(otb_opengl_cmake_NEW) + # foreach(line ${otb_opengl_cmake}) + # if( NOT line MATCHES "/usr") + # list(APPEND otb_opengl_cmake_NEW "${line}\n") + # endif() + # endforeach() + # endif() + # file(WRITE "${otb_opengl}" ${otb_opengl_cmake_NEW}) + +endfunction() diff --git a/SuperBuild/CMake/post_install.cmake b/Packaging/post_install.cmake similarity index 60% rename from SuperBuild/CMake/post_install.cmake rename to Packaging/post_install.cmake index 55cff6c48b480593f6fb4a412f96ece2626e5246..29c937e02fcafbfbf7799a00502f3aa1fedf412a 100644 --- a/SuperBuild/CMake/post_install.cmake +++ b/Packaging/post_install.cmake @@ -29,18 +29,18 @@ string(REPLACE "|" ";" P_DIRS ${P_DIRS}) foreach( p_dir ${P_DIRS} ) -set(file_list) -file( GLOB file_list "${p_dir}/*.cmake" ) -list(SORT file_list) -foreach( cmake_file ${file_list} ) - - file(STRINGS "${cmake_file}" MATCH_FOUND REGEX "${P_MATCH}") - if(MATCH_FOUND) - message("Replacing '${P_MATCH}' with '${P_REPLACE}' in ${cmake_file}") - file(STRINGS "${cmake_file}" cmake_file_CONTENTS NEWLINE_CONSUME) - string(REPLACE "${P_MATCH}" "$${}{${P_REPLACE}}" cmake_file_CONTENTS ${cmake_file_CONTENTS}) - file(WRITE "${cmake_file}" "# This file is modified by OTB after installation. + set(file_list) + file( GLOB file_list "${p_dir}/*.cmake" ) + list(SORT file_list) + foreach( cmake_file ${file_list} ) + file(STRINGS "${cmake_file}" MATCH_FOUND REGEX "${P_MATCH}") + if(MATCH_FOUND) + message(STATUS "Patching: ${cmake_file}") + #message("Patch: Replace '${P_MATCH}' with '${P_REPLACE}' in ${cmake_file}") + file(STRINGS "${cmake_file}" cmake_file_CONTENTS NEWLINE_CONSUME) + string(REPLACE "${P_MATCH}" "$${}{${P_REPLACE}}" cmake_file_CONTENTS ${cmake_file_CONTENTS}) + file(WRITE "${cmake_file}" "# This file is modified by OTB after installation. \n${cmake_file_CONTENTS}") - endif() -endforeach() # foreach( cmake_file + endif() + endforeach() # foreach( cmake_file endforeach() # foreach( p_dir diff --git a/Packaging/prepare_file_list.cmake b/Packaging/prepare_file_list.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4d83bc601da079a89f57d98bda00e54a00b08501 --- /dev/null +++ b/Packaging/prepare_file_list.cmake @@ -0,0 +1,99 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(prepare_file_list file_list_result) + + set(file_list) + set(otbapp_launcher "otbApplicationLauncherCommandLine${EXE_EXT}") + #This must exist in any OTB Installation. minimal or full + if(NOT EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${otbapp_launcher}") + message( + FATAL_ERROR + "${SUPERBUILD_INSTALL_DIR}/bin/${otbapp_launcher} not found.") + return() + endif() + + set(file_list "${otbapp_launcher}") + + if(HAVE_QT4) + list(APPEND file_list "otbApplicationLauncherQt${EXE_EXT}") + endif() + + if(HAVE_MVD) + list(APPEND file_list "monteverdi${EXE_EXT}") + list(APPEND file_list "mapla${EXE_EXT}") + endif() + + if(HAVE_PYTHON) + list(APPEND file_list "_otbApplication${PYMODULE_EXT}") + endif() + + foreach(exe_file "iceViewer" "otbTestDriver" "SharkVersion") + if(EXISTS "${SUPERBUILD_INSTALL_DIR}/bin/${exe_file}${EXE_EXT}") + list(APPEND file_list "${exe_file}${EXE_EXT}") + else() + message(STATUS "${exe_file}${EXE_EXT} not found in ${SUPERBUILD_INSTALL_DIR}/bin. (skipping)") + endif() + endforeach() + + #Qt stuff + if(HAVE_QT4) + list(APPEND file_list "lrelease${EXE_EXT}") + list(APPEND file_list "moc${EXE_EXT}") + list(APPEND file_list "qmake${EXE_EXT}") + list(APPEND file_list "rcc${EXE_EXT}") + list(APPEND file_list "uic${EXE_EXT}") + list(APPEND file_list "proj${EXE_EXT}") + list(APPEND file_list "cs2cs${EXE_EXT}") + endif() + + file(GLOB otb_test_exe_list + "${SUPERBUILD_INSTALL_DIR}/bin/gdal*${EXE_EXT}" + "${OTB_BINARY_DIR}/bin/*[T|t]est*${EXE_EXT}" + ) + + #special items to be removed!. hackety-hack + list(REMOVE_ITEM otb_test_exe_list + "${SUPERBUILD_INSTALL_DIR}/bin/gdal-config" + ) + list(REMOVE_ITEM otb_test_exe_list + "${OTB_BINARY_DIR}/bin/otbcli_TestApplication") + + list(REMOVE_ITEM otb_test_exe_list + "${OTB_BINARY_DIR}/bin/otbgui_TestApplication") + + foreach(otb_test_exe ${otb_test_exe_list}) + get_filename_component(otb_test_exe_name ${otb_test_exe} NAME) + list(APPEND file_list ${otb_test_exe_name}) + endforeach() + + # special case for msvc: ucrtbase.dll must be explicitly vetted. + # for proj.dll, see Mantis-1424 + if(MSVC) + list(APPEND file_list "ucrtbase.dll") + list(APPEND file_list "proj.dll") + endif() + + set(otb_applications_dir "${SUPERBUILD_INSTALL_DIR}/lib/otb/applications") + file(GLOB OTB_APPS_LIST "${otb_applications_dir}/otbapp_*${LIB_EXT}") # /lib/otb + list(APPEND file_list ${OTB_APPS_LIST}) + + + set(${file_list_result} ${file_list} PARENT_SCOPE) +endfunction() diff --git a/Packaging/prepare_search_dirs.cmake b/Packaging/prepare_search_dirs.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8f246edd9b072a59ccc4095fccb4718250c1c1bb --- /dev/null +++ b/Packaging/prepare_search_dirs.cmake @@ -0,0 +1,59 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(prepare_search_dirs search_dirs_result) + + set(search_dirs) + + if(MSVC) + if(NOT DEFINED ENV{UniversalCRTSdkDir}) + message(FATAL_ERROR "UniversalCRTSdkDir variable not set. Cannot continue") + endif() + if(NOT DEFINED ENV{VCINSTALLDIR}) + message(FATAL_ERROR "VCINSTALLDIR variable not set. Cannot continue.") + endif() + endif() + + if(MSVC) + file(TO_CMAKE_PATH "$ENV{UniversalCRTSdkDir}" UCRT_SDK_DIR) + list(APPEND search_dirs "${UCRT_SDK_DIR}/Redist/ucrt/DLLs/${OTB_TARGET_SYSTEM_ARCH}") #ucrt dlls + + #additional msvc redist dll from VCINSTALLDIR + file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}" PKG_VCINSTALLDIR) + list(APPEND search_dirs + "${PKG_VCINSTALLDIR}/redist/${OTB_TARGET_SYSTEM_ARCH}/Microsoft.VC140.CRT" + "${PKG_VCINSTALLDIR}/redist/${OTB_TARGET_SYSTEM_ARCH}/Microsoft.VC140.OPENMP" + ) +endif() + +#superbuild .so /.dylib +list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/lib") +#all executables gdalinfo etc.. +list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/bin") +#common for all platforms. +list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/lib/otb/applications") + +#_otbApplication.so +list(APPEND search_dirs "${SUPERBUILD_INSTALL_DIR}/lib/otb/python") + +#for otbtest executables. +list(APPEND search_dirs ${OTB_BINARY_DIR}/bin) + +set(${search_dirs_result} ${search_dirs} PARENT_SCOPE) +endfunction() diff --git a/Packaging/process_file_recurse.cmake b/Packaging/process_file_recurse.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b83616ad864c070e3d3b390b809d20dca00303df --- /dev/null +++ b/Packaging/process_file_recurse.cmake @@ -0,0 +1,141 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(process_file_recurse input_file) + set(input_file_full_path) + search_library(${input_file} PKG_SEARCHDIRS input_file_full_path) + if(NOT input_file_full_path) + if(LINUX) + setif_value_in_list(is_gtk_lib "${input_file}" ALLOWED_SYSTEM_DLLS) + if(is_gtk_lib) + search_library(${input_file} PKG_GTK_SEARCHDIRS input_file_full_path) + if( NOT input_file_full_path) + message(FATAL_ERROR "${input_file} not found. searched in ${PKG_GTK_SEARCHDIRS}") + endif() + endif() + if( NOT input_file_full_path) + message(FATAL_ERROR "${input_file} not found. searched in ${PKG_SEARCHDIRS}") + endif() + endif(LINUX) + + endif() #if(NOT input_file_full_path) + + if(NOT PKG_DEBUG) + message("Processing ${input_file_full_path}") + endif() + + # Install the file with install_rule(). + # This function has specific "rules" to decide wheather and where to install file + install_rule(${input_file_full_path}) + + set(raw_items) + + execute_process( + COMMAND ${LOADER_PROGRAM} ${LOADER_ARGS} "${input_file_full_path}" + RESULT_VARIABLE loader_rv + OUTPUT_VARIABLE loader_ov + ERROR_VARIABLE loader_ev + ) + + if(loader_rv) + message(FATAL_ERROR "loader_ev=${loader_ev}\n PACKAGE-OTB: result_variable is '${loader_rv}'") + endif() + + string(REPLACE ";" "\\;" candidates "${loader_ov}") + string(REPLACE "\n" "${LOADER_REGEX_EOL};" candidates "${candidates}") + + get_filename_component(bn_name ${input_file_full_path} NAME) + set(${bn_name}_USED TRUE CACHE INTERNAL "") + + if(PKG_DEBUG) + message("Processing ${input_file} started. Set ${bn_name}_USED=${${bn_name}_USED}") + endif() + + foreach(candidate ${candidates}) + if(NOT candidate) + continue() + endif() + + if(NOT "${candidate}" MATCHES "${LOADER_REGEX}") + continue() + endif() + + string(REGEX REPLACE "${LOADER_REGEX}" "\\1" raw_item "${candidate}") + + if(NOT raw_item) + continue() + endif() + + string(STRIP ${raw_item} raw_item) + set(is_system FALSE) + setif_value_in_list(is_system "${raw_item}" SYSTEM_DLLS) + if(APPLE AND NOT is_system) + if("${raw_item}" MATCHES "@rpath") + string(REGEX REPLACE "@rpath." "" raw_item "${raw_item}") + else() + message(FATAL_ERROR "'${raw_item}' does not have @rpath") + endif() + endif() + + if(PKG_DEBUG AND ${raw_item}_RESOLVED) + message("${raw_item} is already resolved [${raw_item}_RESOLVED=${${raw_item}_RESOLVED}]") + endif() + + if(PKG_DEBUG) + message("raw_item='${raw_item}'\tis_system='${is_system}'") + endif() + if(is_system OR ${raw_item}_RESOLVED OR ${raw_item}_USED) + continue() + endif() + + list(APPEND raw_items ${raw_item}) + + endforeach() + + if(PKG_DEBUG) + string(REPLACE ";" "\n" raw_items_pretty_print "${raw_items}") + # message(FATAL_ERROR "raw_items=${raw_items_pretty_print}") + endif(PKG_DEBUG) + + if(raw_items) + list(REVERSE raw_items) + foreach(item ${raw_items}) + search_library(${item} PKG_SEARCHDIRS item_full_path) + set(is_a_symlink FALSE) + set(item_target_file) + isfile_symlink("${item_full_path}" is_a_symlink item_target_file) + if(is_a_symlink) + set(${item}_RESOLVED TRUE CACHE INTERNAL "") + set(item ${item_target_file}) + endif() + if(PKG_DEBUG) + message("${bn_name} depends on '${item}'. So we now process '${item}'") # [ ${item}_USED=${${item}_USED} ${item}_RESOLVED=${${item}_RESOLVED}]") + endif() + process_file_recurse(${item}) + endforeach() + endif() + + set(${bn_name}_RESOLVED TRUE CACHE INTERNAL "") + if(PKG_DEBUG) + message("All dependencies of ${bn_name} are processed. Install file and set ${bn_name}_RESOLVED=${${bn_name}_RESOLVED}") + endif() + + #install_rule(${input_file_full_path}) + +endfunction() #function(process_file_recurse infile) diff --git a/Packaging/search_library.cmake b/Packaging/search_library.cmake new file mode 100644 index 0000000000000000000000000000000000000000..500bbb9acf1585cdff4bcfd54c8d29ba35095c10 --- /dev/null +++ b/Packaging/search_library.cmake @@ -0,0 +1,39 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(search_library input_file pkg_searchdirs result) + set(${result} "" PARENT_SCOPE) + foreach(pkg_searchdir ${${pkg_searchdirs}}) + + if(EXISTS ${pkg_searchdir}/${input_file} ) + if(PKG_DEBUG) + message("Found '${pkg_searchdir}/${input_file}' (return)") + endif() + set(${result} "${pkg_searchdir}/${input_file}" PARENT_SCOPE) + return() + endif() + + #check for file with lowercase + string(TOLOWER "${input_file}" input_file_lower ) + if(EXISTS ${pkg_searchdir}/${input_file_lower}) + set(${result} "${pkg_searchdir}/${input_file_lower}" PARENT_SCOPE) + return() + endif() + endforeach() +endfunction() diff --git a/Packaging/setif_value_in_list.cmake b/Packaging/setif_value_in_list.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7ae6820de3ae6c49c9d87d95818dac9145546a38 --- /dev/null +++ b/Packaging/setif_value_in_list.cmake @@ -0,0 +1,32 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +function(setif_value_in_list matched VALUE list) + set(${matched} FALSE PARENT_SCOPE) + string(TOLOWER ${VALUE} value) + foreach (PATTERN ${${list}}) + string(TOLOWER ${PATTERN} pattern) + if("${value}" MATCHES "${pattern}") + set(${matched} TRUE PARENT_SCOPE) + #we found a match. return from loop. + return() + endif() + endforeach() + #message("'${value}' not found in ${list}") +endfunction() diff --git a/Packaging/testing.cmake b/Packaging/testing.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c7dce464d1cc6c4e7afc46d35cfddea42dd4f8fa --- /dev/null +++ b/Packaging/testing.cmake @@ -0,0 +1,85 @@ +# +# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# +# add_test(NAME <name> COMMAND <command> [<arg>...] +# [CONFIGURATIONS <config>...] +# [WORKING_DIRECTORY <dir>]) + +set(testing_dir ${CMAKE_BINARY_DIR}/tests) +if(EXISTS "${testing_dir}") + execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${testing_dir}) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${testing_dir}) +else() + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${testing_dir}) +endif() + +set(install_package_ARGS) +set(selftester_ARGS) +set(pkg_extracted_dir "${testing_dir}/${PKG_STAGE_DIR}") +if(WIN32) + set(install_package_ARGS "x;${PACKAGE_OUTPUT_FILE}") + set(install_package_CMD "${ZIP_EXECUTABLE}") + #selftester + set(selftester_CMD ${pkg_extracted_dir}/tools/selftester.bat) + set(selftester_ARGS "/q") + #uninstall OTB + set(uninstall_otb_CMD ${pkg_extracted_dir}/tools/uninstall_otb.bat) +else() + set(install_package_ARGS "--noprogress;--nox11;--target;${pkg_extracted_dir}") + set(install_package_CMD "${PACKAGE_OUTPUT_FILE}") + #selftester + set(selftester_CMD ${pkg_extracted_dir}/tools/selftester.sh) + set(selftester_ARGS) + #uninstall OTB + set(uninstall_otb_CMD ${pkg_extracted_dir}/tools/uninstall_otb.sh) +endif() +add_test( + NAME Tu_install_package + COMMAND ${install_package_CMD} ${install_package_ARGS} + WORKING_DIRECTORY ${testing_dir} + ) + +add_test( + NAME Tu_selftester + COMMAND ${selftester_CMD} ${selftester_ARGS} + WORKING_DIRECTORY ${pkg_extracted_dir} + ) + +add_test( + NAME Tu_build_examples + COMMAND ${CMAKE_COMMAND} + -DSRC_DIR=${CMAKE_SOURCE_DIR}/../Examples + -P ${pkg_extracted_dir}/tools/build_examples.cmake + WORKING_DIRECTORY ${testing_dir} + ) + +add_test( + NAME Tu_uninstall_otb + COMMAND ${uninstall_otb_CMD} + WORKING_DIRECTORY ${testing_dir} + ) + +#configure test dependencies.. +set_tests_properties ( Tu_selftester PROPERTIES DEPENDS Tu_install_package) +set_tests_properties ( Tu_build_examples PROPERTIES DEPENDS Tu_selftester) +set_tests_properties ( Tu_uninstall_otb PROPERTIES DEPENDS Tu_build_examples) + +#if(UNIX) + #TODO: add test with shellcheck for script files +#endif() diff --git a/SuperBuild/CMake/External_fftw.cmake b/SuperBuild/CMake/External_fftw.cmake index ce1bdbea7f377f3402465e0d31867f46bb05922f..e500caa48039476663f99d2ae0982b547a161ec3 100644 --- a/SuperBuild/CMake/External_fftw.cmake +++ b/SuperBuild/CMake/External_fftw.cmake @@ -54,6 +54,7 @@ ExternalProject_Add(FFTWF --disable-fortran --disable-dependency-tracking DEPENDS ${FFTW_DEPENDENCIES} + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 @@ -84,7 +85,7 @@ ExternalProject_Add(FFTWD LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 - LOG_INSTALL 1 + LOG_INSTALL 1 ) diff --git a/SuperBuild/CMake/External_geotiff.cmake b/SuperBuild/CMake/External_geotiff.cmake index 3bb24a3202b39db9724a8261da78bf7fdfdf86fc..cc557b761129c10cca2209856cb1684a592a526f 100644 --- a/SuperBuild/CMake/External_geotiff.cmake +++ b/SuperBuild/CMake/External_geotiff.cmake @@ -49,7 +49,7 @@ ExternalProject_Add(GEOTIFF -DBUILD_TESTING:BOOL=OFF -DPROJ4_OSGEO4W_HOME:PATH=${SB_INSTALL_PREFIX} ${GEOTIFF_SB_CONFIG} - CMAKE_COMMAND ${SB_CMAE_COMMAND} + CMAKE_COMMAND ${SB_CMAKE_COMMAND} LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 diff --git a/SuperBuild/CMake/External_itk.cmake b/SuperBuild/CMake/External_itk.cmake index a96dc75196ce61766cb5e8ad9f491e83a163cb63..d0337bb39acc561ec6ae2080ed8264de35412f46 100644 --- a/SuperBuild/CMake/External_itk.cmake +++ b/SuperBuild/CMake/External_itk.cmake @@ -126,11 +126,8 @@ if (WIN32) list(APPEND ITK_SB_CONFIG -DUSE_FFTWF:BOOL=OFF -DUSE_FFTWD:BOOL=OFF + -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS:BOOL=ON ) - if(MSVC AND BUILD_SHARED_LIBS) - list(APPEND ITK_SB_CONFIG - -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS:BOOL=TRUE) - endif() else() list(APPEND ITK_SB_CONFIG -DUSE_FFTWF:BOOL=ON @@ -140,16 +137,6 @@ else() ADD_SUPERBUILD_CMAKE_VAR(ITK FFTW_INCLUDE_PATH) endif() -# forward compilation flags -set(ITK_SB_COMPILATION_FLAGS - -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} - -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} - -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} - -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} - -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} - -DCMAKE_STATIC_LINKER_FLAGS:STRING=${CMAKE_STATIC_LINKER_FLAGS} - ) - #variables are later used in packaging set(SB_ITK_VERSION_MAJOR "4") set(SB_ITK_VERSION_MINOR "12") @@ -166,7 +153,6 @@ ExternalProject_Add(ITK DOWNLOAD_DIR ${DOWNLOAD_LOCATION} CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} - ${ITK_SB_COMPILATION_FLAGS} -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF ${ITK_MODULES_CMAKE_CACHE} -DITKGroup_Core:BOOL=OFF diff --git a/SuperBuild/CMake/External_muparserx.cmake b/SuperBuild/CMake/External_muparserx.cmake index e67b3974ad51cb504eb75cd31aa8f64153acde72..8ab61cc0bded8540f42049b166b2fca5b6ddc2ee 100644 --- a/SuperBuild/CMake/External_muparserx.cmake +++ b/SuperBuild/CMake/External_muparserx.cmake @@ -22,12 +22,11 @@ INCLUDE_ONCE_MACRO(MUPARSERX) SETUP_SUPERBUILD(MUPARSERX) -#Don't build muparserx examples -set(MUPARSERX_FLAGS) -list(APPEND MUPARSERX_FLAGS -DBUILD_EXAMPLES:BOOL=OFF) - +set(MUPARSERX_SB_CONFIG) if(MSVC AND BUILD_SHARED_LIBS) - list(APPEND MUPARSERX_FLAGS -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS:BOOL=ON) + list(APPEND + MUPARSERX_SB_CONFIG + -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS:BOOL=TRUE) endif() ExternalProject_Add(MUPARSERX @@ -39,7 +38,8 @@ ExternalProject_Add(MUPARSERX DOWNLOAD_DIR ${DOWNLOAD_LOCATION} CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} - ${MUPARSERX_FLAGS} + -DBUILD_EXAMPLES:BOOL=OFF + ${MUPARSERX_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} DEPENDS ${MUPARSERX_DEPENDENCIES} LOG_DOWNLOAD 1 diff --git a/SuperBuild/CMake/External_openssl.cmake b/SuperBuild/CMake/External_openssl.cmake index 7e20c05fb4fd4698ca683c638914d840de68ff64..80dbcccca0c781b33783ea50c2dafbfc9616c8dc 100644 --- a/SuperBuild/CMake/External_openssl.cmake +++ b/SuperBuild/CMake/External_openssl.cmake @@ -50,16 +50,12 @@ if(MSVC) BINARY_DIR ${OPENSSL_SB_SRC} INSTALL_DIR ${SB_INSTALL_PREFIX} DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - PATCH_COMMAND - ${SB_ENV_CONFIGURE_CMD} - ${PERL_COMMAND} ${OPENSSL_SB_SRC}/Configure + PATCH_COMMAND ${PERL_COMMAND} ${OPENSSL_SB_SRC}/Configure ${OPENSSL_BUILD_ARCH} no-asm "--prefix=${SB_INSTALL_PREFIX_NATIVE}" "--openssldir=${SB_INSTALL_PREFIX_NATIVE}" - CONFIGURE_COMMAND - ${SB_ENV_CONFIGURE_CMD} - ${OPENSSL_CONFIGURE_CMD} + CONFIGURE_COMMAND ${OPENSSL_CONFIGURE_CMD} BUILD_COMMAND nmake -f "${OPENSSL_SB_SRC}/ms/ntdll.mak" INSTALL_COMMAND nmake -f "${OPENSSL_SB_SRC}/ms/ntdll.mak" install LOG_DOWNLOAD 1 diff --git a/SuperBuild/CMake/External_otb.cmake b/SuperBuild/CMake/External_otb.cmake index 7960b53e44e89d7537ec3ee2e7991f7202e6e356..465683a9b48222947d20f7fdf5354dc4d8f6c0ce 100644 --- a/SuperBuild/CMake/External_otb.cmake +++ b/SuperBuild/CMake/External_otb.cmake @@ -128,23 +128,16 @@ ADD_SUPERBUILD_CMAKE_VAR(OTB TINYXML_LIBRARY) ADD_SUPERBUILD_CMAKE_VAR(OTB Boost_INCLUDE_DIR) ADD_SUPERBUILD_CMAKE_VAR(OTB Boost_LIBRARY_DIR) - -# forward compilation flags -set(OTB_SB_C_FLAGS "${SB_PRIOR_INCLUDE_FLAGS} ${CMAKE_C_FLAGS} ") -set(OTB_SB_CXX_FLAGS "${SB_PRIOR_INCLUDE_FLAGS} ${CMAKE_CXX_FLAGS}") -if(MSVC) - set(OTB_SB_CXX_FLAGS "${OTB_SB_CXX_FLAGS} /EHsc /DNOMINMAX") +set(OTB_MODULES_CONFIG) +if(WITH_REMOTE_MODULES) + foreach(remote_module SertitObject Mosaic otbGRM) + list(APPEND OTB_MODULES_CONFIG -DModule_${remote_module}:BOOL=ON) + endforeach() +else() + set(OTB_MODULES_CONFIG) endif() -set(OTB_SB_COMPILATION_FLAGS - -DCMAKE_C_FLAGS:STRING=${OTB_SB_C_FLAGS} - -DCMAKE_CXX_FLAGS:STRING=${OTB_SB_CXX_FLAGS} - -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} - -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} - -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} - -DCMAKE_STATIC_LINKER_FLAGS:STRING=${CMAKE_STATIC_LINKER_FLAGS} - ) add_custom_command(OUTPUT otb_depends_done.txt COMMAND cmake -E touch otb_depends_done.txt @@ -169,7 +162,7 @@ ExternalProject_Add(OTB DOWNLOAD_DIR ${DOWNLOAD_LOCATION} CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS} - ${OTB_SB_COMPILATION_FLAGS} + ${OTB_MODULES_CONFIG} -DBUILD_TESTING:BOOL=${BUILD_TESTING} -DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES} -DOTB_DATA_ROOT:STRING=${OTB_DATA_ROOT} @@ -191,10 +184,9 @@ ExternalProject_Add(OTB -DOTB_USE_GLFW:BOOL=${OTB_USE_GLFW} -DOTB_USE_GLUT:BOOL=${OTB_USE_GLUT} -DOTB_USE_QWT:BOOL=${OTB_USE_QWT} + -DOTB_USE_OPENMP:BOOL=${OTB_USE_OPENMP} -DOTB_WRAP_PYTHON:BOOL=${OTB_WRAP_PYTHON} -DOTB_WRAP_JAVA:BOOL=${OTB_WRAP_JAVA} - -DGENERATE_PACKAGE:BOOL=OFF - -DGENERATE_XDK:BOOL=OFF ${OTB_ADDITIONAL_CACHE} CMAKE_ARGS ${OTB_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} diff --git a/SuperBuild/CMake/External_pkgtools.cmake b/SuperBuild/CMake/External_pkgtools.cmake deleted file mode 100644 index 0d137545280063561a6091367bb5a0e99bd222c8..0000000000000000000000000000000000000000 --- a/SuperBuild/CMake/External_pkgtools.cmake +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -set(PKGTOOLS_SB_PREFIX_DIR "${CMAKE_BINARY_DIR}/PACKAGE-TOOLS") - -set(PATCHELF_SOURCE_DIR "${PKGTOOLS_SB_PREFIX_DIR}/src/patchelf") -# PATCHELF_BINARY_DIR is same as PATCHELF_SOURCE_DIR -set(PATCHELF_INSTALL_DIR "${PKGTOOLS_SB_PREFIX_DIR}/install/patchelf") -set(PATCHELF_STAMP_DIR "${PKGTOOLS_SB_PREFIX_DIR}/stamp/patchelf") -set(PATCHELF_TMP_DIR "${PKGTOOLS_SB_PREFIX_DIR}/tmp/patchelf") - -#This variable is referenced in CreateCMakeProjects.cmake -set(PATCHELF_PROGRAM "${PATCHELF_SOURCE_DIR}/src/patchelf") - - -set(MAKESELF_SOURCE_DIR "${PKGTOOLS_SB_PREFIX_DIR}/src/makeself") -# MAKESELF_SOURCE_DIR is same as MAKESELF_BINARY_DIR and MAKESELF_INSTALL_DIR -set(MAKESELF_STAMP_DIR "${PKGTOOLS_SB_PREFIX_DIR}/stamp/makeself") -set(MAKESELF_TMP_DIR "${PKGTOOLS_SB_PREFIX_DIR}/tmp/makeself") - -#This variable is referenced in CreateCMakeProjects.cmake -set(MAKESELF_SCRIPT "${MAKESELF_SOURCE_DIR}/makeself.sh") - -if( __EXTERNAL_PACKAGE_TOOLS__) - return() -else() - set(__EXTERNAL_PACKAGE_TOOLS__ 1) -endif() - -if(WIN32) - add_custom_target(PACKAGE-TOOLS) - return() -endif() - -include(ExternalProject) - - -if(APPLE) - add_custom_target(PATCHELF) -else() - ExternalProject_Add(PATCHELF - PREFIX "${PKGTOOLS_SB_PREFIX_DIR}" - URL "http://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2" - URL_MD5 d02687629c7e1698a486a93a0d607947 - DOWNLOAD_DIR "${DOWNLOAD_LOCATION}" - SOURCE_DIR "${PATCHELF_SOURCE_DIR}" - BINARY_DIR "${PATCHELF_SOURCE_DIR}" - INSTALL_DIR "${PATCHELF_INSTALL_DIR}" - STAMP_DIR "${PATCHELF_STAMP_DIR}" - TMP_DIR "${PATCHELF_TMP_DIR}" - CONFIGURE_COMMAND "./configure" "--prefix" "${PATCHELF_INSTALL_DIR}" - INSTALL_COMMAND "" - ) -endif() - -ExternalProject_Add(MAKESELF - PREFIX "${PKGTOOLS_SB_PREFIX_DIR}" - URL "https://www.orfeo-toolbox.org/packages/makeself-2.2.0.tar.gz" - URL_MD5 3c61df934b0c61ddcd7bd63b391e951d - DOWNLOAD_DIR "${DOWNLOAD_LOCATION}" - SOURCE_DIR "${MAKESELF_SOURCE_DIR}" - BINARY_DIR "${MAKESELF_SOURCE_DIR}" - INSTALL_DIR "${MAKESELF_SOURCE_DIR}" - STAMP_DIR "${MAKESELF_STAMP_DIR}" - TMP_DIR "${MAKESELF_TMP_DIR}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - DEPENDS PATCHELF - ) - -add_custom_target(PACKAGE-TOOLS DEPENDS MAKESELF) diff --git a/SuperBuild/CMake/External_qt4.cmake b/SuperBuild/CMake/External_qt4.cmake index 6d7c12cd52c00e83b0117ef97fd9814c7d20e193..c460c649d5442b758ea2c211d52c2711cca0977b 100644 --- a/SuperBuild/CMake/External_qt4.cmake +++ b/SuperBuild/CMake/External_qt4.cmake @@ -33,10 +33,6 @@ SETUP_SUPERBUILD(QT4) set(QT4_SB_ENABLE_GTK OFF CACHE INTERNAL "Enable GTK+ style with qt using -gtkstlye. Default is OFF") -if(NOT DEFINED git_protocol) - set(git_protocol "git") -endif() - #NOTE: make sure your superbuild install directory does not contain any #Qt files from previous install of superbuild QT. # declare dependencies @@ -137,20 +133,6 @@ add_custom_target(QT4-uninstall LOG_INSTALL 1 ) - - if(MSVC) - #Q: why this copy here?. - #RK: Because QT4 sucks with qmake -query. - ExternalProject_Add_Step(QT4 patches - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${QT4_SB_SRC}/mkspecs ${SB_INSTALL_PREFIX}/mkspecs - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/patches/QT4/qjpeghandler.pri - ${QT4_SB_SRC}/src/gui/image/ - DEPENDEES patch update - DEPENDERS configure ) -endif() - SUPERBUILD_PATCH_SOURCE(QT4) set(_SB_QT_QMAKE_EXECUTABLE ${SB_INSTALL_PREFIX}/bin/qmake) diff --git a/SuperBuild/CMake/External_qwt.cmake b/SuperBuild/CMake/External_qwt.cmake index 847d001b80bdc98c5a842e72acdaa0d7742c727f..e2b6e7c6e05fc8a5dce1bf1ae39c78a851dec517 100644 --- a/SuperBuild/CMake/External_qwt.cmake +++ b/SuperBuild/CMake/External_qwt.cmake @@ -57,9 +57,10 @@ ExternalProject_Add(QWT CONFIGURE_COMMAND ${QWT_SB_CONFIGURE_PROGRAM} ${QWT_SB_BUILD_DIR}/qwt.pro BUILD_COMMAND ${QWT_SB_MAKE_PROGRAM} INSTALL_COMMAND ${QWT_SB_MAKE_PROGRAM} install + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 - LOG_INSTALL 1 + LOG_INSTALL 1 ) set(_SB_QWT_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) diff --git a/SuperBuild/CMake/External_shark.cmake b/SuperBuild/CMake/External_shark.cmake index 4fa164d29259d33037ad8c85ee6327ba6e8a0f85..ce8486db084935352b4266fc384f40be3604a29c 100644 --- a/SuperBuild/CMake/External_shark.cmake +++ b/SuperBuild/CMake/External_shark.cmake @@ -44,6 +44,7 @@ ExternalProject_Add(SHARK -DBUILD_TESTING:BOOL=OFF -DENABLE_HDF5:BOOL=OFF -DENABLE_CBLAS:BOOL=OFF + -DENABLE_OPENMP:BOOL=${OTB_USE_OPENMP} ${SHARK_SB_CONFIG} CMAKE_COMMAND ${SB_CMAKE_COMMAND} LOG_DOWNLOAD 1 diff --git a/SuperBuild/CMake/SuperBuild_Macro.cmake b/SuperBuild/CMake/SuperBuild_Macro.cmake index 85cc6e2a3be6dab17601bb20360aeaf3bffc294a..4e572e4dbd11096d62b959d205fca6faec710af7 100644 --- a/SuperBuild/CMake/SuperBuild_Macro.cmake +++ b/SuperBuild/CMake/SuperBuild_Macro.cmake @@ -151,7 +151,7 @@ macro(SUPERBUILD_PATCH_SOURCE project) endif() if(DOT_DIFF_FILES) - message(STATUS " Custom patches required for ${project}") + message(STATUS "Custom patches required for ${project}") ExternalProject_Add_Step(${project} ${project}_custom_patch COMMAND ${CMAKE_COMMAND} diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 6d47c1185ec61de953820d854367b956dfb3a960..4a6a28242a24ec484c1cd725b83ed54d869b7f20 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -41,9 +41,15 @@ include(ExternalProject) include(OTBCheckTargetSystemArch) +set(LINUX FALSE) +if( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(LINUX TRUE) +endif() + option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON) option(BUILD_STATIC_LIBS "Build with static libraries." OFF) - +option(WITH_REMOTE_MODULES "Build with specific list of remote modules." OFF) +option(OTB_USE_OPENMP "use openmp" OFF) set(OTB_ADDITIONAL_CACHE "" CACHE STRING "Additional cmake option for OTB -DVAR:TYPE=VALUE ...") if(APPLE) @@ -91,7 +97,6 @@ if(OTB_DATA_USE_LARGEINPUT) mark_as_advanced(OTB_DATA_LARGEINPUT_ROOT) endif() - option(BUILD_EXAMPLES " Build the OTB Examples directory" OFF) option(USE_DEFAULT_INSTALL_PREFIX "Install superbuild to default prefix /usr/local for unix" OFF) @@ -147,7 +152,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /Ox /FC /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE") if(MSVC_VERSION GREATER 1310) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() @@ -178,6 +183,24 @@ if(UNIX) list(APPEND SB_CMAKE_CACHE_ARGS "-DCMAKE_INSTALL_RPATH:PATH=${CMAKE_INSTALL_RPATH}") endif() +foreach(cmake_var + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + CMAKE_EXE_LINKER_FLAGS + CMAKE_SHARED_LINKER_FLAGS + CMAKE_MODULE_LINKER_FLAGS + CMAKE_STATIC_LINKER_FLAGS + ) + if(${cmake_var}) + list(APPEND SB_CMAKE_CACHE_ARGS "-D${cmake_var}:STRING=${${cmake_var}}") + list(APPEND SB_CMAKE_CACHE_ARGS "-D${cmake_var}:STRING=${${cmake_var}}") + endif() +endforeach() + +if(CMAKE_VERBOSE_MAKEFILE) + list(APPEND SB_CMAKE_CACHE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON") +endif() + set(SB_CMAKE_ARGS "-G${CMAKE_GENERATOR}") set(SB_CONFIGURE_ARGS) @@ -216,6 +239,25 @@ else() #windows set(SB_CMAKE_COMMAND ${CMAKE_COMMAND} ${SB_CMAKE_ARGS}) endif() + +if(CMAKE_C_FLAGS) + list(APPEND SB_ENV_CONFIGURE_CMD "CFLAGS=${CMAKE_C_FLAGS}") +endif() +if(CMAKE_CXX_FLAGS) + list(APPEND SB_ENV_CONFIGURE_CMD "CXXFLAGS=${CMAKE_CXX_FLAGS}") +endif() +if(CMAKE_EXE_LINKER_FLAGS) + list(APPEND SB_ENV_CONFIGURE_CMD "LDFLAGS=${CMAKE_EXE_LINKER_FLAGS}") +endif() +if(CMAKE_SHARED_LINKER_FLAGS) + list(APPEND SB_ENV_CONFIGURE_CMD "LDFLAGS=${CMAKE_SHARED_LINKER_FLAGS}") +endif() +if(CMAKE_MODULE_LINKER_FLAGS) + list(APPEND SB_ENV_CONFIGURE_CMD "LDFLAGS=${CMAKE_MODULE_LINKER_FLAGS}") +endif() + +list(REMOVE_DUPLICATES SB_ENV_CONFIGURE_CMD) + message(STATUS "Environment setup for CMake (SB_CMAKE_COMMAND) : ${SB_CMAKE_COMMAND}") set(FROM_SYSTEM_LIST) @@ -276,29 +318,31 @@ option(OTB_USE_QT4 "Enable module QT4 in OTB" ON) option(OTB_USE_SIFTFAST "Enable module Siftfast in OTB" ON) option(OTB_USE_OPENGL "Enable module OpenGL in OTB" ON) option(OTB_USE_GLEW "Enable module GLEW in OTB" ON) -option(OTB_USE_GLFW "Enable module GLFW in OTB" ON) #Cannot activate GLUT on OSX. See manits issue #1194") +# do not activate GLFW by default on osx. see failing test +# https://dash.orfeo-toolbox.org/testDetails.php?test=59844554&build=287120 if(APPLE) option(OTB_USE_GLUT "Enable module GLUT in OTB" OFF) + option(OTB_USE_GLFW "Enable module GLFW in OTB" OFF) else() option(OTB_USE_GLUT "Enable module GLUT in OTB" ON) + option(OTB_USE_GLFW "Enable module GLFW in OTB" ON) endif() option(OTB_USE_SHARK "Enable module Shark in OTB" ON) option(OTB_USE_QWT "Enable module QWT in OTB" ON) # set OTB_DATA_ROOT to run test -find_path(OTB_DATA_ROOT README-OTB-Data PATHS $ENV{OTB_DATA_ROOT} ${OTB-SuperBuild_SOURCE_DIR}/../../OTB-Data) - +find_path(OTB_DATA_ROOT README-OTB-Data + PATHS + $ENV{OTB_DATA_ROOT} + ${OTB-SuperBuild_SOURCE_DIR}/../../OTB-Data) # SWIG Wrapping -option(OTB_WRAP_PYTHON "Enable python wrappers for OTB applications (requires SWIG)" OFF) +option(OTB_WRAP_PYTHON "Enable python wrappers for OTB applications (requires SWIG)" ON) option(OTB_WRAP_JAVA "Enable java wrappers for OTB applications (requires SWIG)" OFF) -option(GENERATE_PACKAGE "Generate a portable .run package of OTB (only Unix)." OFF) -option(GENERATE_XDK "Generate an XDK. This files provides all headers and libraries to build and or develop OTB (only Unix)." OFF) - configure_file(${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake @ONLY) @@ -324,27 +368,23 @@ endforeach() include(External_otb) - -if(UNIX OR MSVC) - add_subdirectory(Packaging) -endif() - if(FROM_SYSTEM_LIST) list(SORT FROM_SYSTEM_LIST) foreach( item ${FROM_SYSTEM_LIST}) - message(STATUS " Using system version of ${item}") + message(STATUS "Using system version of ${item}") endforeach() endif() if(FROM_SUPERBUILD_LIST) list(SORT FROM_SUPERBUILD_LIST) foreach( item ${FROM_SUPERBUILD_LIST}) - message(STATUS " Using SuperBuild version of ${item}") + message(STATUS "Using SuperBuild version of ${item}") endforeach() endif() message(STATUS "OTB_TARGET_SYSTEM_ARCH=${OTB_TARGET_SYSTEM_ARCH}") message(STATUS "OTB_TARGET_SYSTEM_ARCH_IS_X64=${OTB_TARGET_SYSTEM_ARCH_IS_X64}") + if(DOWNLOAD_LOCATION) message(STATUS "DOWNLOAD_LOCATION=${DOWNLOAD_LOCATION}") message(STATUS "Source archives for dependencies will be taken from '${DOWNLOAD_LOCATION}'") diff --git a/SuperBuild/Packaging/CMakeLists.txt b/SuperBuild/Packaging/CMakeLists.txt deleted file mode 100644 index 9c58a5bbc40ff7fc62b18338d6d197ac5a6fab2e..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/CMakeLists.txt +++ /dev/null @@ -1,219 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -# cpack has a built-in target called 'package'. In our case we create two standalone installers with -# and uses a custom target named packages. - -# stop generation of msvc packages for windows. 04-apr-2016. point OTB. - -##### check if standalone project ###### -set(OUT_OF_SOURCE_BUILD FALSE) -if(NOT PROJECT_NAME) - cmake_minimum_required(VERSION 2.6) - include(CMakeParseArguments) - project(OTBPackaging) - - option(GENERATE_PACKAGE "Generate OTB package" ON) - option(GENERATE_XDK "Generate XDK for OTB development" OFF) - - set(OUT_OF_SOURCE_BUILD TRUE) - - if(BUILD_TESTING) - include(CTest) - endif() - - if(NOT PACKAGE_OTB_SRC_DIR) - get_filename_component(PACKAGE_OTB_SRC_DIR ${OTBPackaging_SOURCE_DIR} PATH) - get_filename_component(PACKAGE_OTB_SRC_DIR ${PACKAGE_OTB_SRC_DIR} PATH) - endif() - - option(OTB_WRAP_PYTHON "enable python wrapping" ON) - if(OTB_WRAP_PYTHON AND NOT PYTHON_EXECUTABLE) - find_package ( PythonInterp REQUIRED ) - mark_as_advanced(PYTHON_INCLUDE_DIR) - mark_as_advanced(PYTHON_LIBRARY) - endif() - - if(OTB_MINGW) - set(OTB_BINARY_DIR "" CACHE PATH "OTB binary directory") - set(OTB_INSTALL_DIR "" CACHE PATH "OTB install directory") - else() - set(SUPERBUILD_BINARY_DIR "" CACHE PATH "path to superbuild binary directory") - set(SUPERBUILD_INSTALL_DIR "" CACHE PATH "path to superbuild install directory") - set(DOWNLOAD_LOCATION "" CACHE PATH "path to superbuild download archives") - endif() - -else() #if(NOT PROJECT_NAME) - - # SUPERBUILD_BINARY_DIR is only set in Packaging/CMakeLists.txt and not available - # in the parent scope like others. So we need to set it as CMAKE_BINARY_DIR - # if doing packages from source tree. - set( SUPERBUILD_BINARY_DIR ${CMAKE_BINARY_DIR} ) - set( SUPERBUILD_INSTALL_DIR ${SB_INSTALL_PREFIX} ) - set( OTB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} ) - - if(NOT PACKAGE_OTB_SRC_DIR) - get_filename_component(PACKAGE_OTB_SRC_DIR ${OTB-SuperBuild_SOURCE_DIR} PATH) - endif() - -endif() - -if(NOT GENERATE_PACKAGE AND NOT GENERATE_XDK) - #well. we don't have any businees here. Let's move on.. - return() -endif() - -set(LINUX FALSE) -set(OTB_MINGW FALSE) -if(WIN32 AND NOT MSVC) - set(OTB_MINGW TRUE) -else() - if( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(LINUX TRUE) - endif() -endif() - -find_program(FILE_COMMAND "file") -mark_as_advanced(FILE_COMMAND) - -set(SUPERBUILD_SOURCE_DIR ${PACKAGE_OTB_SRC_DIR}/SuperBuild) - -include(${SUPERBUILD_SOURCE_DIR}/CMake/SuperBuild_Macro.cmake) -include(${PACKAGE_OTB_SRC_DIR}/CMake/OTBCheckTargetSystemArch.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/CreateCMakeProjects.cmake) - -if(WIN32) - set(ZIP_EXE_NAMES 7z 7za) - find_program(ZIP_EXECUTABLE NAMES ${ZIP_EXE_NAMES}) - if(NOT ZIP_EXECUTABLE) - message(FATAL_ERROR "Cannot find 7z executable. searched names ${ZIP_EXE_NAMES}. Please add it to your path") - endif() -endif() - -if(OTB_MINGW) - set(required_vars - OTB_BINARY_DIR - OTB_INSTALL_DIR - MXE_TARGET_DIR - ) -else() - set(required_vars - SUPERBUILD_BINARY_DIR - SUPERBUILD_INSTALL_DIR - SUPERBUILD_SOURCE_DIR - ) -endif() - -foreach(req - ${required_vars} - PACKAGE_OTB_SRC_DIR - OTB_TARGET_SYSTEM_ARCH - OTB_TARGET_SYSTEM_ARCH_IS_X64 - ) - if(NOT DEFINED ${req} OR "${${req}}" STREQUAL "") - message(FATAL_ERROR "you must set ${req}") - endif() - set(vars "${vars} ${req}=[${${req}}]\n") -endforeach(req) - -message("\n${vars}\n") - -set(PKG_DEBUG OFF) - -set(EXTRA_CACHE_CONFIG) - -set(CMAKE_INSTALL_PREFIX "${SUPERBUILD_INSTALL_DIR}") - -set(PACKAGE_LONG_NAME OrfeoToolBox) - -# Make up part of output package file -set(NAME_SUFFIX "" CACHE STRING "extra suffix for package name") - -set(PACKAGE_NAME OTB) - -if(NAME_SUFFIX) - set(PACKAGE_NAME OTB${NAME_SUFFIX}) -endif() - -if(APPLE) - set(PACKAGE_PLATFORM_NAME "Darwin") -elseif(WIN32) - set(PACKAGE_PLATFORM_NAME "win") -elseif(LINUX) - set(PACKAGE_PLATFORM_NAME "Linux") -endif() - -set(PACKAGE_ARCH "32") -if(OTB_TARGET_SYSTEM_ARCH_IS_X64) -set(PACKAGE_ARCH "64") -endif() - -if(OTB_MINGW) - get_filename_component(MXE_MXEROOT ${MXE_TARGET_DIR} PATH) - get_filename_component(MXE_MXEROOT ${MXE_MXEROOT} PATH) - set(EXTRA_CACHE_CONFIG - "set(CMAKE_CROSSCOMPILING TRUE) - set(WIN32 TRUE) - set(MINGW TRUE) - set(MXE_MXEROOT \"${MXE_MXEROOT}\")" - ) - set(CMAKE_INSTALL_PREFIX "${OTB_INSTALL_DIR}") -endif() - -# get itk version from External_itk.cmake if not on mingw -# because mxe has different version -if(NOT OTB_MINGW) - get_version( - INPUT_FILE "${SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake" - MATCH_STRINGS "SB_ITK_VERSION_MAJOR" "SB_ITK_VERSION_MINOR" - PREFIX PKG - ) -endif() - -set(PKG_ITK_SB_VERSION "${PKG_SB_ITK_VERSION_MAJOR}.${PKG_SB_ITK_VERSION_MINOR}") - -#get version of OTB from source_dir/CMakeLists.txt -get_version( - INPUT_FILE "${PACKAGE_OTB_SRC_DIR}/CMakeLists.txt" - MATCH_STRINGS "OTB_VERSION_MAJOR" "OTB_VERSION_MINOR" "OTB_VERSION_PATCH" - PREFIX PKG - ) - -set(PKG_OTB_VERSION_STRING - ${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}.${PKG_OTB_VERSION_PATCH}) - -if(OTB_MINGW) - set(OTB_BINARY_DIR "${OTB_BINARY_DIR}") - set(OTB_INSTALL_DIR "${OTB_INSTALL_DIR}") - set(DEPENDENCIES_INSTALL_DIR "${MXE_MXEROOT}/usr/${OTB_TARGET_SYSTEM_ARCH}-w64-mingw32.shared") - set(QT_PLUGINS_DIR "${DEPENDENCIES_INSTALL_DIR}/qt/plugins") - set(QT_TRANSLATIONS_DIR "${DEPENDENCIES_INSTALL_DIR}/qt/translations") -else() #unixes - set(OTB_BINARY_DIR "${SUPERBUILD_BINARY_DIR}/OTB/build") - set(OTB_INSTALL_DIR "${SUPERBUILD_INSTALL_DIR}") - set(DEPENDENCIES_INSTALL_DIR "${SUPERBUILD_INSTALL_DIR}") - set(QT_PLUGINS_DIR "${SUPERBUILD_INSTALL_DIR}/plugins") - set(QT_TRANSLATIONS_DIR "${SUPERBUILD_INSTALL_DIR}/translations") -endif() - -macro_setup_cmake_project(OTB) -if(GENERATE_XDK) - macro_setup_cmake_project(XDK) -endif() diff --git a/SuperBuild/Packaging/CreateCMakeProjects.cmake b/SuperBuild/Packaging/CreateCMakeProjects.cmake deleted file mode 100644 index 6d0cb47f31eefbc1eb07173d188eb65ebc1483d6..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/CreateCMakeProjects.cmake +++ /dev/null @@ -1,200 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -macro(macro_setup_cmake_project pkg) - - message( "-- Configuring ${pkg} package") - - set(PATCHELF_PROGRAM) - set(MAKESELF_SCRIPT) - include(${SUPERBUILD_SOURCE_DIR}/CMake/External_pkgtools.cmake) - - #reset it again in macro(macro_create_targets_for_package pkg) - #because that's the cmake macros way. - set(PACKAGE_PROJECT_DIR ${CMAKE_BINARY_DIR}/PACKAGE-${pkg}) - execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${PACKAGE_PROJECT_DIR}/build") - - if("${pkg}" STREQUAL "XDK") - set(PKG_GENERATE_XDK ON) - else() - set(PKG_GENERATE_XDK OFF) - endif() - - if(PKG_GENERATE_XDK) - set(archive_name ${PACKAGE_NAME}-${PKG_OTB_VERSION_STRING}-xdk-${PACKAGE_PLATFORM_NAME}${PACKAGE_ARCH}) - else() - set(archive_name ${PACKAGE_NAME}-${PKG_OTB_VERSION_STRING}-${PACKAGE_PLATFORM_NAME}${PACKAGE_ARCH}) - endif() - - #set archive name inside loop - file(WRITE "${PACKAGE_PROJECT_DIR}/src/CMakeLists.txt" - "cmake_minimum_required(VERSION 3.2) - include(CMakeParseArguments) - include(CMakeDetermineSystem) - set(CMAKE_BUILD_TYPE Release) - set(PACKAGE_OTB_SRC_DIR \"${PACKAGE_OTB_SRC_DIR}\") - set(SUPERBUILD_BINARY_DIR \"${SUPERBUILD_BINARY_DIR}\") - set(OTB_BINARY_DIR \"${OTB_BINARY_DIR}\") - set(OTB_INSTALL_DIR \"${OTB_INSTALL_DIR}\") - set(QT_PLUGINS_DIR \"${QT_PLUGINS_DIR}\") - set(QT_TRANSLATIONS_DIR \"${QT_TRANSLATIONS_DIR}\") - set(DEPENDENCIES_INSTALL_DIR \"${DEPENDENCIES_INSTALL_DIR}\") - set(PACKAGE_SUPPORT_FILES_DIR \"${PACKAGE_OTB_SRC_DIR}/SuperBuild/Packaging/Files\") - set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\") - set(PKG_ITK_SB_VERSION \"${PKG_ITK_SB_VERSION}\") - set(PKG_OTB_VERSION_MAJOR \"${PKG_OTB_VERSION_MAJOR}\") - set(PKG_OTB_VERSION_MINOR \"${PKG_OTB_VERSION_MINOR}\") - set(PKG_OTB_VERSION_PATCH \"${PKG_OTB_VERSION_PATCH}\") - set(PKG_OTB_VERSION_STRING \"${PKG_OTB_VERSION_STRING}\") - set(PYTHON_EXECUTABLE \"${PYTHON_EXECUTABLE}\") - set(PATCHELF_PROGRAM \"${PATCHELF_PROGRAM}\") - set(PKG_GENERATE_XDK ${PKG_GENERATE_XDK}) - set(OTB_TARGET_SYSTEM_ARCH ${OTB_TARGET_SYSTEM_ARCH}) - set(OTB_TARGET_SYSTEM_ARCH_IS_X64 ${OTB_TARGET_SYSTEM_ARCH_IS_X64}) - set(OTB_WRAP_PYTHON ${OTB_WRAP_PYTHON}) - set(PKG_DEBUG ${PKG_DEBUG}) - set(FILE_COMMAND \"${FILE_COMMAND}\") - ${EXTRA_CACHE_CONFIG} - include(${SUPERBUILD_SOURCE_DIR}/Packaging/PackageMacros.cmake) - include(${SUPERBUILD_SOURCE_DIR}/Packaging/PackageHelper.cmake) - include(${SUPERBUILD_SOURCE_DIR}/Packaging/InstallSupportFiles.cmake) - include(${SUPERBUILD_SOURCE_DIR}/Packaging/PackageGlobals.cmake) - macro_super_package(STAGE_DIR \"${archive_name}\")" - ) - -set(README_FILE_SUFFIX) -if(PKG_GENERATE_XDK) - set(README_FILE_SUFFIX "_xdk") -endif() -if(APPLE) - set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Macx${README_FILE_SUFFIX}.txt) -elseif(LINUX) #not osx - set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Linux${README_FILE_SUFFIX}.txt) -elseif(WIN32) #windows - set(README_FILE ${PACKAGE_OTB_SRC_DIR}/Documentation/Cookbook/rst/Installation_Windows${README_FILE_SUFFIX}.txt) -endif() - -configure_file( - "${README_FILE}" - ${PACKAGE_PROJECT_DIR}/src/README - ) - -macro_create_targets_for_package(${pkg}) - -endmacro() - -macro(macro_create_targets_for_package pkg) - - if(WIN32 AND NOT MSVC) - - add_custom_target(PACKAGE-${pkg}-check - COMMAND ${CMAKE_COMMAND} --build "." --target install - WORKING_DIRECTORY "${OTB_BINARY_DIR}" - ) - else() #Using SuperBuild - #For out of source build, - #we assume the otb is built correctly with superbuild - if(OUT_OF_SOURCE_BUILD) - add_custom_target(PACKAGE-${pkg}-check - COMMAND ${CMAKE_COMMAND} -E echo "Building PACKAGE-${pkg}-check") - else(OUT_OF_SOURCE_BUILD) - add_custom_target(PACKAGE-${pkg}-check - COMMAND ${CMAKE_COMMAND} -E echo "Building PACKAGE-${pkg}-check" - DEPENDS OTB - WORKING_DIRECTORY ${SUPERBUILD_BINARY_DIR} - ) - endif(OUT_OF_SOURCE_BUILD) - endif() - - add_dependencies(PACKAGE-${pkg}-check PACKAGE-TOOLS) -# add_dependencies(PACKAGE-${pkg}-check PACKAGE-${pkg}-clean) - - - if(NOT archive_name) - message(FATAL_ERROR "archive_name not set. Cannot continue") - endif() - - set(PACKAGE_PROJECT_DIR ${CMAKE_BINARY_DIR}/PACKAGE-${pkg}) - - if(WIN32) - set(PACKAGE_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${archive_name}.zip") - else() - set(PACKAGE_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${archive_name}.run") - endif() - - #configure - add_custom_target(PACKAGE-${pkg}-configure - COMMAND ${CMAKE_COMMAND} -E remove "${PACKAGE_OUTPUT_FILE}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${PACKAGE_PROJECT_DIR}/build" - WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}" - COMMAND ${CMAKE_COMMAND} "-G${CMAKE_GENERATOR}" - "${PACKAGE_PROJECT_DIR}/src" - WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}/build" - DEPENDS PACKAGE-${pkg}-check - ) -# COMMAND ${CMAKE_COMMAND} -E remove_directory "${PACKAGE_PROJECT_DIR}" - #build - add_custom_target(PACKAGE-${pkg}-build - COMMAND ${CMAKE_COMMAND} - "--build" "${PACKAGE_PROJECT_DIR}/build" "--target" "install" - WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}/build" - DEPENDS PACKAGE-${pkg}-configure - ) - - #create package - # creation of package is different from windows and unix like - # WORKING_DIRECTORY must be CMAKE_INSTALL_PREFIX and not - # CMAKE_CURRENT_BINARY_DIR like in unix - if(WIN32) - add_custom_target(PACKAGE-${pkg} - COMMAND ${ZIP_EXECUTABLE} "a" "-r" "-y" - "${PACKAGE_OUTPUT_FILE}" "${archive_name}/*" - WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}" - DEPENDS PACKAGE-${pkg}-build - COMMENT "Creating ${PACKAGE_OUTPUT_FILE}" - ) - else() - add_custom_target(PACKAGE-${pkg} - COMMAND ${MAKESELF_SCRIPT} - "--quiet" - "--target" - "${archive_name}" - "${CMAKE_INSTALL_PREFIX}/${archive_name}" - "${archive_name}.run" - "${PACKAGE_LONG_NAME} ${PKG_OTB_VERSION_STRING}" - "./pkgsetup" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - DEPENDS PACKAGE-${pkg}-build - COMMENT "Creating ${PACKAGE_OUTPUT_FILE}" - ) - endif() - - - - #clean - add_custom_target(PACKAGE-${pkg}-clean - COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/PACKAGE-${pkg}" - COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/PACKAGE-TOOLS" - COMMAND ${CMAKE_COMMAND} -E remove "${PACKAGE_OUTPUT_FILE}" - COMMAND ${CMAKE_COMMAND} "${CMAKE_BINARY_DIR}" - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - ) - -endmacro(macro_create_targets_for_package) diff --git a/SuperBuild/Packaging/Files/linux_pkgsetup.in b/SuperBuild/Packaging/Files/linux_pkgsetup.in deleted file mode 100644 index fcdc13fa0fe83abec1d8c1c4a2ed0dff65fc394c..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/Files/linux_pkgsetup.in +++ /dev/null @@ -1,347 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - - -DIRNAME_0=$(dirname "$0") -cd "$DIRNAME_0" - -# NOTE: $OUT_DIR is also used in make_sylinks script (see below) -# Avoid any pre-mature optimization on variable names here. - -OUT_DIR=$(pwd) - -PATCH_ELF_EXE="$OUT_DIR/patchelf" - -# No no interference with LD_LIBRARY_PATH -LD_LIBRARY_PATH= - -echo "Configuring..." -#see next call below for otb applications -BINARY_FILES=$(find $OUT_DIR/lib $OUT_DIR/bin -maxdepth 1 -type f -exec file {} \; | grep -i elf|cut -f1 -d':') - -# run patchelf -for bin_file in $BINARY_FILES; do - #echo "adding rpath to $bin_file" - if [ -f "$bin_file" ]; then - "$PATCH_ELF_EXE" "--set-rpath" "$OUT_DIR/lib" "$bin_file" - fi -done - -I_AM_XDK=@IS_XDK@ - -# if [ "$I_AM_XDK" = true ] ; then -# sed -i "s,@DEPENDENCIES_INSTALL_DIR@,$OUT_DIR,g" lib/cmake/ITK-@PKG_ITK_SB_VERSION@/Modules/ITKZLIB.cmake -# sed -i "s,@DEPENDENCIES_INSTALL_DIR@,$OUT_DIR,g" lib/cmake/ITK-@PKG_ITK_SB_VERSION@/ITKConfig.cmake -# sed -i "s,@DEPENDENCIES_INSTALL_DIR@,$OUT_DIR,g" lib/cmake/ITK-@PKG_ITK_SB_VERSION@/ITKTargets-release.cmake -# else - -if [ "$I_AM_XDK" = false ] ; then -OTB_APP_FILES=$(find $OUT_DIR/lib/otb/applications -maxdepth 1 -type f -exec file {} \; | grep -i elf|cut -f1 -d':') - # run patchelf -for app_file in $OTB_APP_FILES; do - #echo "adding rpath to $app_file" - if [ -f "$app_file" ]; then - "$PATCH_ELF_EXE" "--set-rpath" "$OUT_DIR/lib" "$app_file" - fi -done - -cat > "$OUT_DIR/monteverdi.sh" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - - -. $OUT_DIR/otbenv.profile - -$OUT_DIR/bin/monteverdi "\$@" -EOF - -chmod +x "$OUT_DIR/monteverdi.sh" - -cat > "$OUT_DIR/mapla.sh" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - - -. $OUT_DIR/otbenv.profile - -$OUT_DIR/bin/mapla "\$@" -EOF - -chmod +x "$OUT_DIR/mapla.sh" - -cat > "$OUT_DIR/otbenv.profile" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - - -# 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 - -# unset any existing LD_LIBRARY_PATH -unset LD_LIBRARY_PATH - -# if OTB_USE_LOCAL_GTK is set to one, -# we must include <OUT_DIR>/lib/gtk because glib files are -# installed there. - -# OTB_USE_LOCAL_GTK is not set by default (use GTK system) -if [ "\$OTB_USE_LOCAL_GTK" = "1" ]; then - LD_LIBRARY_PATH=$OUT_DIR/lib/gtk - export LD_LIBRARY_PATH -fi - -# 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=\$(readlink -f "\$OTB_APPLICATION_PATH") - if ! [ "\$OTB_APPLICATION_PATH" = "$OUT_DIR/lib/otb/applications" ]; then - OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications:\$OTB_APPLICATION_PATH - fi -fi - -# Add bin direcotory to system PATH -PATH=$OUT_DIR/bin:\$PATH - -# export PYTHONPATH to import otbApplication.py -PYTHONPATH=$OUT_DIR/lib/python:\$PYTHONPATH - -# set numeric locale to C -LC_NUMERIC=C - -# set GDAL_DATA variable used by otb application -GDAL_DATA=$OUT_DIR/share/gdal - -# set GEOTIFF_CSV variable used by otb application -GEOTIFF_CSV=$OUT_DIR/share/epsg_csv - -# export variables -export LC_NUMERIC -export GDAL_DATA -export GEOTIFF_CSV -export OTB_APPLICATION_PATH -export PATH -export PYTHONPATH - -EOF - - -chmod +x "$OUT_DIR/otbenv.profile" - -else - -cat > "$OUT_DIR/xdkenv.profile" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - - -# The below environment variables only affect current shell -# So if you run again from a terminal. you need to run the script again - -# unset any existing LD_LIBRARY_PATH -unset LD_LIBRARY_PATH - -# Add bin direcotory to system PATH -PATH=$OUT_DIR/bin:\$PATH - -# set numeric locale to C -LC_NUMERIC=C - -# set GDAL_DATA variable used by otb application -GDAL_DATA=$OUT_DIR/share/gdal - -# set GEOTIFF_CSV variable used by otb application -GEOTIFF_CSV=$OUT_DIR/share/epsg_csv - -CMAKE_PREFIX_PATH=$OUT_DIR - -# export variables -export LC_NUMERIC -export GDAL_DATA -export GEOTIFF_CSV -export CMAKE_PREFIX_PATH -export PATH - -EOF - - -chmod +x "$OUT_DIR/xdkenv.profile" - -fi - -#echo "Creating symbolic links..." -. ./make_symlinks - - -cat > "$OUT_DIR/bin/qt.conf" << EOF -[Paths] -Translations=$OUT_DIR/lib/qt4/translations -Plugins=$OUT_DIR/lib/qt4/plugins -EOF - -WITH_PYTHON=@WITH_PYTHON@ - -if [ "$WITH_PYTHON" = true ] ; then - -if [ ! -f "$OTB_PYTHON_EXE" ] ; then - OTB_PYTHON_EXE=$(which python) -fi - -python_INSTALLED_SONAME=@python_INSTALLED_SONAME@ - -python_major_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[0])") -python_minor_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[1])") -python_patch_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[2])") -python_version="$python_major_version.$python_minor_version.$python_patch_version" - -python_check_failed() { - printf %s\\n "*****Error occurred during installation******" - printf %s\\n "OTB python bindings requires python2.6 or python2.7 but current detected python version is $python_version" - printf %s\\n "If you have python2.6 or Python2.7 installed in your system " - printf %s\\n "You should set OTB_PYTHON_EXE and re-run this installation script." - printf %s\\n "eg: OTB_PYTHON_EXE=/path/to/python2.7 ./OTB-X.Y-Linux64.run" - exit 1; -} -if [ "$python_major_version" -gt 2 ]; then -python_check_failed -fi - -if [ "$python_minor_version" -lt 5 ]; then -python_check_failed -fi - -python_INSTSONAME=$($OTB_PYTHON_EXE -c "import sys; from distutils import sysconfig; print (sysconfig.get_config_var('INSTSONAME'));") - -python_lib_dirs="/usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu" -found_python_lib="0" -python_lib_file_path="" -for list_of_dir in $python_lib_dirs -do - if [ -f "$list_of_dir/$python_INSTSONAME" ]; then - python_lib_file_path="$list_of_dir/$python_INSTSONAME" - found_python_lib="1" - break - fi -done - -if [ "$found_python_lib" -eq "1" ]; then - printf %s\\n "OTB python bindings will be configured for $OTB_PYTHON_EXE ( version: $python_version )" - printf %s\\n "Found python library: $python_lib_file_path" - ln -sf "$python_lib_file_path" "$OUT_DIR/lib/$python_INSTALLED_SONAME" - "$PATCH_ELF_EXE" "--set-rpath" "$OUT_DIR/lib" "$OUT_DIR/lib/python/_otbApplication.so" - printf %s\\n "To use OTB python bindings:" - printf %s\\n "'export PYTHONPATH=$OUT_DIR/lib/python'" - printf %s\\n "To test OTB python bindings:" - printf %s\\n "$OTB_PYTHON_EXE -c 'import otbApplication'" -else - printf %s\\n "*****Error occurred during installation******" - printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )" - printf %s\\n "$python_INSTSONAME cannot be found in any of search directories." - printf %s\\n "We had searched following directories $python_lib_dirs" - printf %s\\n "If you don't have python-dev package installed, install it and make a symlink" - printf %s\\n "If you don't have python headers and so installed on a custom location, then make a symlink" - printf %s\\n "eg: ln -s /usr/lib/x86_64-linux-gnu/$python_INSTSONAME $OUT_DIR/lib/$python_INSTALLED_SONAME" -fi - -fi; - -# PKG_OTB_VERSION_STRING=@PKG_OTB_VERSION_STRING@ -sed -i "s,|release|,@PKG_OTB_VERSION_STRING@,g" "$OUT_DIR/README" - -rm -fr "$OUT_DIR/tools" - -rm -f "$OUT_DIR/pkgsetup" - -rm -f "$OUT_DIR/make_symlinks" - diff --git a/SuperBuild/Packaging/Files/macx_pkgsetup.in b/SuperBuild/Packaging/Files/macx_pkgsetup.in deleted file mode 100644 index dde59b5b45543375982a2bfb01b72809cc21c416..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/Files/macx_pkgsetup.in +++ /dev/null @@ -1,266 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - - -DIRNAME_0=$(dirname "$0") -cd "$DIRNAME_0" - -# NOTE: $OUT_DIR is also used in make_sylinks script (see below) -# Avoid any pre-mature optimization on variable names here. - -OUT_DIR=$(pwd) - -# find install_name_tool -INSTALL_NAME_TOOL=$(which install_name_tool) -if [ -z "$INSTALL_NAME_TOOL" ]; then - echo "install_name_tool does not exists.." - echo "please install install_name_tool and make sure it can be found from PATH" - exit 1; -fi - -# no interference with DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH -DYLD_LIBRARY_PATH= -DYLD_FALLBACK_LIBRARY_PATH= - -echo "Configuring..." - -LIBRARY_FILES=$(find "$OUT_DIR/lib" -maxdepth 1 -type f) -EXE_FILES=$(find "$OUT_DIR/bin" -type f -exec file {} \; | grep -i "Mach-O*.*executable"|cut -d ':' -f1) -# run install_name_tool -for lib_file in $LIBRARY_FILES $EXE_FILES; do - #echo "adding rpath to $OUT_DIR/$lib_file" - if [ -f "$lib_file" ]; then - lib_file_original_rpaths=$(otool -l "$lib_file" | grep -A 3 "LC_RPATH" | grep -oE 'path .* \(offset' | cut -d ' ' -f 2) - for original_rpath in $lib_file_original_rpaths; do - $INSTALL_NAME_TOOL "-delete_rpath" "$original_rpath" "$lib_file" - done - $INSTALL_NAME_TOOL "-add_rpath" "$OUT_DIR/lib" "$lib_file" - fi -done - - -LONG_VERSION_STRING=@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@.@Monteverdi_VERSION_PATCH@ -SHORT_VERSION_STRING=@Monteverdi_VERSION_MAJOR@.@Monteverdi_VERSION_MINOR@ - -I_AM_XDK=@IS_XDK@ - - -# if [ "$I_AM_XDK" = true ] ; then - -# sed -i "" "s,@DEPENDENCIES_INSTALL_DIR@,$OUT_DIR,g" lib/cmake/ITK-@PKG_ITK_SB_VERSION@/Modules/ITKZLIB.cmake -# sed -i "" "s,@DEPENDENCIES_INSTALL_DIR@,$OUT_DIR,g" lib/cmake/ITK-@PKG_ITK_SB_VERSION@/ITKConfig.cmake -# sed -i "" "s,@DEPENDENCIES_INSTALL_DIR@,$OUT_DIR,g" lib/cmake/ITK-@PKG_ITK_SB_VERSION@/ITKTargets-release.cmake -# else -if [ "$I_AM_XDK" = false ] ; then - OTB_APP_FILES=$(find "$OUT_DIR/lib/otb/applications" -maxdepth 1 -type f) - # run install_name_tool - for app_file in $OTB_APP_FILES; do - #echo "adding rpath to $app_file" - if [ -f "$app_file" ]; then - $INSTALL_NAME_TOOL "-rpath" "@ORIGINAL_RPATH_TO_REPLACE@" "$OUT_DIR/lib" "$app_file" - fi - done - if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ]; then - $INSTALL_NAME_TOOL "-rpath" "@ORIGINAL_RPATH_TO_REPLACE@" "$OUT_DIR/lib" "$OUT_DIR/lib/python/_otbApplication.so" - fi - - rm -fr "Mapla.app" - rm -fr "Monteveridi.app" - - mkdir -p "Mapla.app/Contents/MacOS" - mkdir -p "Mapla.app/Contents/Resources" - mkdir -p "Monteverdi.app/Contents/MacOS" - mkdir -p "Monteverdi.app/Contents/Resources" - - cat > "Mapla.app/Contents/Info.plist" << EOF -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> - <dict> - <key>CFBundleExecutable</key> - <string>STARTUP_FILE</string> - <key>CFBundleIconFile</key> - <string>Monteverdi.icns</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleLongVersionString</key> - <string>LONG_VERSION</string> - <key>CFBundleShortVersionString</key> - <string>SHORT_VERSION</string> - </dict> -</plist> -EOF - - cat > "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -export LC_NUMERIC=C -export OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications -export GDAL_DATA=$OUT_DIR/share/gdal -export GEOTIFF_CSV=$OUT_DIR/share/epsg_csv -$OUT_DIR/bin/mapla "\$@" -EOF - - chmod +x "$OUT_DIR/Mapla.app/Contents/MacOS/Mapla" - - cat > "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -export LC_NUMERIC=C -export OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications -export GDAL_DATA=$OUT_DIR/share/gdal -export GEOTIFF_CSV=$OUT_DIR/share/epsg_csv -$OUT_DIR/bin/monteverdi "\$@" -EOF - - cat > "$OUT_DIR/Monteverdi.app/Contents/Resources/qt.conf" << EOF -[Paths] -Translations=$OUT_DIR/lib/qt4/translations -Plugins=$OUT_DIR/lib/qt4/plugins -EOF - - cat > "$OUT_DIR/Mapla.app/Contents/Resources/qt.conf" << EOF -[Paths] -Translations=$OUT_DIR/lib/qt4/translations -Plugins=$OUT_DIR/lib/qt4/plugins -EOF - - cat > "$OUT_DIR/bin/qt.conf" << EOF -[Paths] -Translations=$OUT_DIR/lib/qt4/translations -Plugins=$OUT_DIR/lib/qt4/plugins -EOF - - - chmod +x "$OUT_DIR/Monteverdi.app/Contents/MacOS/Monteverdi" - - cp "Mapla.app/Contents/Info.plist" "Monteverdi.app/Contents/Info.plist" - cp "$OUT_DIR/Monteverdi.icns" "Monteverdi.app/Contents/Resources/" - cp "$OUT_DIR/Monteverdi.icns" "Mapla.app/Contents/Resources/" - - sed -i "" "s,STARTUP_FILE,Mapla,g" "Mapla.app/Contents/Info.plist" - sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Mapla.app/Contents/Info.plist" - sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Mapla.app/Contents/Info.plist" - - sed -i "" "s,STARTUP_FILE,Monteverdi,g" "Monteverdi.app/Contents/Info.plist" - sed -i "" "s,LONG_VERSION,$LONG_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist" - sed -i "" "s,SHORT_VERSION,$SHORT_VERSION_STRING,g" "Monteverdi.app/Contents/Info.plist" - -cat > "$OUT_DIR/otbenv.profile" << EOF -#!/usr/bin/env bash -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -PATH=$OUT_DIR/bin:\$PATH -PYTHONPATH=$OUT_DIR/lib/python:\$PYTHONPATH -GDAL_DATA=$OUT_DIR/share/gdal -GEOTIFF_CSV=$OUT_DIR/share/epsg_csv -if [ -z "\$OTB_APPLICATION_PATH" ] || [ "\$OTB_APPLICATION_PATH" = "" ]; then - OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications -else - OTB_APPLICATION_PATH=\$(cd "\$OTB_APPLICATION_PATH" 2>/dev/null && pwd -P) - if ! [ "\$OTB_APPLICATION_PATH" = "$OUT_DIR/lib/otb/applications" ]; then - OTB_APPLICATION_PATH=$OUT_DIR/lib/otb/applications:\$OTB_APPLICATION_PATH - fi -fi - -export LC_NUMERIC=C -export PATH -export GDAL_DATA -export GEOTIFF_CSV -export PYTHONPATH -export OTB_APPLICATION_PATH -EOF - -chmod +x "$OUT_DIR/otbenv.profile" - -fi - - -# echo "Creating symbolic links..." -. "./make_symlinks" - -rm -f "$OUT_DIR/Monteverdi.icns" - -rm -f "$OUT_DIR/pkgsetup" - -rm -f "$OUT_DIR/make_symlinks" - -rm -fr "$OUT_DIR/tools" - -open "$OUT_DIR" diff --git a/SuperBuild/Packaging/Files/mapla.bat b/SuperBuild/Packaging/Files/mapla.bat deleted file mode 100644 index 77358001e1f7fb692503c5f265d9a70f9a31882b..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/Files/mapla.bat +++ /dev/null @@ -1,19 +0,0 @@ -::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Mapla launcher to set up proper environment -::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -@echo off -setlocal - -:: Get the directory of the current script -set CURRENT_SCRIPT_DIR=%~dp0 - -:: Setup environment -call %CURRENT_SCRIPT_DIR%otbenv.cmd - -:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access -cd %HOMEDRIVE%%HOMEPATH% - -:: Start Monteverdi -start "Monteverdi Application Launcher" /B "%CURRENT_SCRIPT_DIR%bin\mapla.exe" %* - -endlocal diff --git a/SuperBuild/Packaging/Files/monteverdi.bat b/SuperBuild/Packaging/Files/monteverdi.bat deleted file mode 100644 index 3f1b301f97d85083119ec4e12205f2fdf1158f1e..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/Files/monteverdi.bat +++ /dev/null @@ -1,19 +0,0 @@ -::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Monteverdi launcher to set up proper environment -::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -@echo off -setlocal - -:: Get the directory of the current script -set CURRENT_SCRIPT_DIR=%~dp0 - -:: Setup environment -call %CURRENT_SCRIPT_DIR%otbenv.cmd - -:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access -cd %HOMEDRIVE%%HOMEPATH% - -:: Start Monteverdi -start "Monteverdi Viewer" /B "%CURRENT_SCRIPT_DIR%bin\monteverdi.exe" %* - -endlocal diff --git a/SuperBuild/Packaging/Files/otbenv.bash b/SuperBuild/Packaging/Files/otbenv.bash deleted file mode 100644 index 3eedd8eb822b9567b900f28310fb548e06785ee2..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/Files/otbenv.bash +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P)") - -unset LD_LIBRARY_PATH - -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 -GDAL_DRIVER_PATH="disable" -LC_NUMERIC=C - -export PATH -export GDAL_DATA -export GEOTIFF_CSV -export PYTHONPATH -export OTB_APPLICATION_PATH -export LC_NUMERIC diff --git a/SuperBuild/Packaging/Files/otbenv.cmd b/SuperBuild/Packaging/Files/otbenv.cmd deleted file mode 100644 index a9d5035027c7d99e99b0aa343a4ba9429858a35a..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/Files/otbenv.cmd +++ /dev/null @@ -1,11 +0,0 @@ -:: Setup environment for OTB package -set CURRENT_SCRIPT_DIR=%~dp0 - -set PATH=%CURRENT_SCRIPT_DIR%bin;%PATH% -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 numeric locale to C -set LC_NUMERIC=C diff --git a/SuperBuild/Packaging/InstallSupportFiles.cmake b/SuperBuild/Packaging/InstallSupportFiles.cmake deleted file mode 100644 index da2559ae0067bb48a76f01f482d4d117bff35153..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/InstallSupportFiles.cmake +++ /dev/null @@ -1,442 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -# Get the translation files coming with Qt, and install them in the bundle -# They are loaded by Monteverdi. -function(get_qt_translation_files RESULT) - # These files are the "qt_<localename>.qm" files - # They are located in QT_TRANSLATIONS_DIR, which comes from FindQt4 - file(GLOB translation_files ${QT_TRANSLATIONS_DIR}/qt_*) - - # We need to remove the "qt_help_<localename>.qm" files from this list - foreach(translation_item ${translation_files}) - if(${translation_item} MATCHES "qt_help") - list(REMOVE_ITEM translation_files ${translation_item}) - endif() - endforeach() - - set(${RESULT} ${translation_files} PARENT_SCOPE) - endfunction() - - -function(func_install_xdk_files) - - #The list of REQ_SHARE_DIR is made up from <mxe-target-dir>/share/ - #It may vary in future. I prefer not to glob on the share dir and - #end up distributing man, info etc.. which ar irrelvant for windows - - #TODO: cleaup this function. current - # code is bit of picking each .lib and .dll for now - # see opencv, itk, - foreach(REQ_SHARE_DIR - aclocal - Armadillo - applications - cmake - dbus-1 - fontconfig - libgta - locale - xml - applications - cmake - icons - OpenCV - pixmaps - pkgconfig - ) - if(EXISTS "${DEPENDENCIES_INSTALL_DIR}/share/${REQ_SHARE_DIR}") - func_install_without_message("${DEPENDENCIES_INSTALL_DIR}/share/${REQ_SHARE_DIR}" "share") - endif() - endforeach() - - set(ITK_CMAKE_DIR "${DEPENDENCIES_INSTALL_DIR}/lib/cmake/ITK-${PKG_ITK_SB_VERSION}") - message("COPY ${DEPENDENCIES_INSTALL_DIR}/lib/cmake/ITK-${PKG_ITK_SB_VERSION} to ${CMAKE_CURRENT_BINARY_DIR}/_tmp/ to patch") - execute_process( - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/_tmp/ - COMMAND ${CMAKE_COMMAND} - -E copy_directory - ${ITK_CMAKE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION} - ) - - #reset ITK_CMAKE_DIR - set(ITK_CMAKE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION}") - - set(DIR_LIST "${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION}|${CMAKE_CURRENT_BINARY_DIR}/_tmp/ITK-${PKG_ITK_SB_VERSION}/Modules") - - #SUPERBUILD_INSTALL_DIR - execute_process( - COMMAND ${CMAKE_COMMAND} - -DP_DIRS=${DIR_LIST} - -DP_MATCH=${CMAKE_INSTALL_PREFIX} - -DP_REPLACE=ITK_INSTALL_PREFIX - -P ${PACKAGE_OTB_SRC_DIR}/SuperBuild/CMake/post_install.cmake - RESULT_VARIABLE patch_itk_cmake_rv - ) - - file(STRINGS "${SUPERBUILD_BINARY_DIR}/ITK/build/CMakeCache.txt" - MATCH_FOUND REGEX "ITK_USE_SYSTEM_ZLIB:BOOL=ON") - if(MATCH_FOUND) - find_package(ZLIB QUIET) - get_filename_component(ZLIB_PREFIX ${ZLIB_LIBRARY} PATH) - execute_process( - COMMAND ${CMAKE_COMMAND} - -DP_DIRS=${DIR_LIST} - -DP_MATCH=${ZLIB_PREFIX} - -DP_REPLACE=ITK_INSTALL_PREFIX - -P ${PACKAGE_OTB_SRC_DIR}/SuperBuild/CMake/post_install.cmake - ) - - endif() - - func_install_without_message("${ITK_CMAKE_DIR}" "lib/cmake") - - set(QT_REQ_DIRS) - if(WIN32) - #only affects windows due to regex on dll - #.lib are not taken when processing dependencies. - # We just get .dlls which is enough for binary package - # For XDK, we need .lib files when building OTB using xdk - # For Linux. we get .so.X.Y.Z by finding the 'target' - # of any .so file. So there is no need for such a copy on - # Linux and OSX - if(MSVC) - file(GLOB LIB_FILES "${DEPENDENCIES_INSTALL_DIR}/lib/*.lib") - else() - file(GLOB LIB_FILES "${DEPENDENCIES_INSTALL_DIR}/lib/*dll.*") - endif() - - foreach(LIB_FILE ${LIB_FILES}) - pkg_install_rule(${LIB_FILE}) - endforeach() - - #qt/bin is also a special case for mxe. - file(GLOB QT_EXTRA_DLL_FILES "${DEPENDENCIES_INSTALL_DIR}/qt/bin/*.dll") - install(FILES ${QT_EXTRA_DLL_FILES} DESTINATION ${PKG_STAGE_DIR}/bin) - - #list(APPEND QT_REQ_DIRS lib) - list(APPEND QT_REQ_DIRS include) - list(APPEND QT_REQ_DIRS imports) - - #mxe installs qt in a separate directory under install prefix. So.. - set(QT_INSTALL_DIR "${DEPENDENCIES_INSTALL_DIR}/qt") - else() - set(QT_INSTALL_DIR "${DEPENDENCIES_INSTALL_DIR}") - - endif(WIN32) - - list(APPEND QT_REQ_DIRS mkspecs) - list(APPEND QT_REQ_DIRS plugins) - list(APPEND QT_REQ_DIRS translations) - foreach(QT_REQ_DIR ${QT_REQ_DIRS} ) - if(EXISTS "${QT_INSTALL_DIR}/${QT_REQ_DIR}") - func_install_without_message("${QT_INSTALL_DIR}/${QT_REQ_DIR}" "") - endif() - endforeach() - - # #install ${DEPENDENCIES_INSTALL_DIR}/include directory. Attention to OTB includes - file(GLOB ALL_IN_INCLUDE_DIR "${DEPENDENCIES_INSTALL_DIR}/include/*") - foreach(INCLUDE_DIR_ITEM ${ALL_IN_INCLUDE_DIR}) - get_filename_component(INCLUDE_DIR_ITEM_name ${INCLUDE_DIR_ITEM} NAME) - get_filename_component(INCLUDE_DIR_ITEM_name_we ${INCLUDE_DIR_ITEM} NAME_WE) - if(NOT "${INCLUDE_DIR_ITEM_name_we}" MATCHES "OTB|otb") - if( IS_DIRECTORY ${INCLUDE_DIR_ITEM}) - install(CODE - "message(STATUS \"Installing: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}/include/${INCLUDE_DIR_ITEM_name}/\")" ) - install( - DIRECTORY "${INCLUDE_DIR_ITEM}" - DESTINATION "${PKG_STAGE_DIR}/include/" - MESSAGE_NEVER - ) - else() - install( - FILES "${INCLUDE_DIR_ITEM}" - DESTINATION "${PKG_STAGE_DIR}/include/" - ) - endif() #if( IS_DIRECTORY - endif() #if (NOT - endforeach() - -endfunction() #func_install_xdk_files - -function(func_install_support_files) - - #a convenient cmake var for storing <prefix>/bin - set(PKG_STAGE_BIN_DIR "${PKG_STAGE_DIR}/bin") - - #<prefix>/share for gdal data files - set(PKG_SHARE_DEST_DIR ${PKG_STAGE_DIR}/share) - - set(PKG_SHARE_SOURCE_DIR ${DEPENDENCIES_INSTALL_DIR}/share) - - set(GDAL_DATA ${PKG_SHARE_SOURCE_DIR}/gdal) - #MSVC install gdal-data in in a different directory. So we don't spoil it - if(MSVC) - set(GDAL_DATA ${DEPENDENCIES_INSTALL_DIR}/data) - endif() - - # Just check if required variables are defined. - foreach(req - DEPENDENCIES_INSTALL_DIR - PKG_STAGE_DIR - PACKAGE_SUPPORT_FILES_DIR - OTB_INSTALL_DIR - ) - if(NOT DEFINED ${req}) - message(FATAL_ERROR "you must set ${req} before calling this method") - endif() - set(vars "${vars} ${req}=[${${req}}]\n") - endforeach(req) - - # one for debugging.. - # install(CODE "message(\"CMake/PackageHelper.cmake:install_supoport_files(${outdir})\n${vars}\n\")") - if(NOT PKG_GENERATE_XDK) - func_install_otb_support_files() - - #check if monteverdi executable is built? - if(EXISTS "${OTB_INSTALL_DIR}/bin/monteverdi${EXE_EXT}") - func_install_monteverdi_support_files() - endif() - - endif() #NOT PKG_GENERATE_XDK - - ####################### install GDAL data ############################ - if(NOT EXISTS "${GDAL_DATA}/epsg.wkt") - message(FATAL_ERROR - "Cannot generate package without GDAL_DATA : ${GDAL_DATA} ${DEPENDENCIES_INSTALL_DIR}") - endif() - - - # install( - # DIRECTORY ${GDAL_DATA} - # DESTINATION ${PKG_SHARE_DEST_DIR} - # ) - - func_install_without_message("${GDAL_DATA}" "share" ) - ####################### install GeoTIFF data ######################## - #install( DIRECTORY ${PKG_SHARE_SOURCE_DIR}/epsg_csv DESTINATION ${PKG_SHARE_DEST_DIR} ) - - func_install_without_message("${PKG_SHARE_SOURCE_DIR}/epsg_csv" "share" ) - - ####################### install OSSIM data ########################## - #install( DIRECTORY ${PKG_SHARE_SOURCE_DIR}/ossim DESTINATION ${PKG_SHARE_DEST_DIR}) - - func_install_without_message("${PKG_SHARE_SOURCE_DIR}/ossim" "share" ) - - ####################### install proj share ########################## - if(EXISTS ${PKG_SHARE_SOURCE_DIR}/proj) - #install(DIRECTORY ${PKG_SHARE_SOURCE_DIR}/proj DESTINATION ${PKG_SHARE_DEST_DIR}) - func_install_without_message("${PKG_SHARE_SOURCE_DIR}/proj" "share" ) - endif() - - ####################### Install copyrights ########################## - #install license for windows package - #install(DIRECTORY ${PKG_SHARE_SOURCE_DIR}/copyright DESTINATION ${PKG_SHARE_DEST_DIR} ) - func_install_without_message("${PKG_SHARE_SOURCE_DIR}/copyright" "share" ) - install(FILES ${PKG_SHARE_SOURCE_DIR}/copyright/LICENSE DESTINATION ${PKG_STAGE_DIR}) - - ####################### Install VERSION ########################## - - set(PKG_VERSION_FILE - "${OTB_INSTALL_DIR}/share/doc/${PKG_OTB_VERSION_MAJOR}.${PKG_OTB_VERSION_MINOR}/VERSION") - if(EXISTS ${PKG_VERSION_FILE} ) - install(FILES ${PKG_VERSION_FILE} DESTINATION ${PKG_STAGE_DIR}) - endif() - -endfunction() - -function(func_install_otb_support_files) - foreach(req - PKG_STAGE_DIR - OTB_INSTALL_DIR - DEPENDENCIES_INSTALL_DIR - ) - if(NOT DEFINED ${req}) - message(FATAL_ERROR "you must set ${req} before calling this method") - endif() - set(vars "${vars} ${req}=[${${req}}]\n") - endforeach(req) - - #a convenient cmake var for storing <prefix>/bin - set(PKG_STAGE_BIN_DIR "${PKG_STAGE_DIR}/bin") - - #<prefix>/share for gdal data files - set(PKG_SHARE_DEST_DIR ${PKG_STAGE_DIR}/share) - - set(PKG_SHARE_SOURCE_DIR ${DEPENDENCIES_INSTALL_DIR}/share) - - #For Unixes we make them in the *pkgsetup.in - ##################### install environment setup file ########################## - if(WIN32) - install( - FILES ${PACKAGE_SUPPORT_FILES_DIR}/otbenv.cmd - DESTINATION ${PKG_STAGE_DIR} - ) - - install( - FILES ${PACKAGE_SUPPORT_FILES_DIR}/otbenv.bash - DESTINATION ${PKG_STAGE_DIR} - ) - - #we need startup files for mapla monteverdi in the root directory - #For Unixes, we make them inside pkgsetup script! - foreach(exe_file mapla monteverdi) - install( - PROGRAMS ${PACKAGE_SUPPORT_FILES_DIR}/${exe_file}.bat - DESTINATION "${PKG_STAGE_DIR}" - ) - endforeach() - endif() - - ####################### install cli and gui scripts ########################### - file(GLOB PKG_APP_SCRIPTS - ${OTB_INSTALL_DIR}/bin/otbcli* - ${OTB_INSTALL_DIR}/bin/otbgui*) # - - list(LENGTH PKG_APP_SCRIPTS PKG_APP_SCRIPTS_LENGTH) - if (PKG_APP_SCRIPTS_LENGTH LESS 1) - message(WARNING "PKG_APP_SCRIPTS is empty: ${PKG_APP_SCRIPTS}") - endif() - - ##################### install cli and gui scripts ####################### - install(PROGRAMS ${PKG_APP_SCRIPTS} DESTINATION ${PKG_STAGE_BIN_DIR}) - - ########################## selftest script ############################## - if(WIN32) - set(PACKAGE_SELFTEST_SCRIPT selftester.bat) - else() - set(PACKAGE_SELFTEST_SCRIPT selftester.sh) - endif() - install( - FILES ${PACKAGE_SUPPORT_FILES_DIR}/${PACKAGE_SELFTEST_SCRIPT} - DESTINATION ${PKG_STAGE_BIN_DIR} - ) - - -endfunction() - -function(func_install_monteverdi_support_files) - - #name/ext of qt's sqlite plugin. Varies with platform/OS - if(WIN32) - set(PKG_QTSQLITE_FILENAME "qsqlite4.dll") - elseif(APPLE) - set(PKG_QTSQLITE_FILENAME "libqsqlite.dylib") - elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(PKG_QTSQLITE_FILENAME "libqsqlite.so") - else() - message(FATAL_ERROR "func_install_monteverdi_support_files: Unknown OS/Platform") - endif() - - #root folder where qt plugins are installed - set(PKG_QTPLUGINS_DIR "${PKG_STAGE_DIR}/lib/qt4/plugins") - - #qt4's distributes some translation of common message string used in Qt. - #This are provided with any qt installation. We reuse them in otb package - #so as not to reinvent the wheels. - set(PKG_QT_TRANSLATIONS_DIR "${PKG_STAGE_DIR}/lib/qt4/translations") - - #<prefix>/share for otb i18n directory. This is different from qt's i18N directory - #which is <prefix>/share/qt4/translations. - #set(PKG_xxOTB_Ixxx18N_DIR "${PKG_STAGE_DIR}/${PKG_OTB_INSTALL_DATA_DIR}/i18n") - # we find this value by parsing ConfigureMonteverdi.h - set(ConfigureMonteverdi_H "${OTB_BINARY_DIR}/Modules/Visualization/MonteverdiCore/ConfigureMonteverdi.h") - if(NOT EXISTS "${ConfigureMonteverdi_H}") - #maybe deactivate monteverdi? - message(FATAL_ERROR "${ConfigureMonteverdi_H} does not exists. Cannot continue") - endif() - - file( - STRINGS "${ConfigureMonteverdi_H}" - ConfigureMonteverdi_H_CONTENTS - REGEX "^#define.Monteverdi_INSTALL_DATA_DIR") - - string(REGEX REPLACE - "^#define.Monteverdi_INSTALL_DATA_DIR" "" - ConfigureMonteverdi_H_CONTENTS - ${ConfigureMonteverdi_H_CONTENTS} ) - - if(NOT ConfigureMonteverdi_H_CONTENTS) - message(FATAL_ERROR "Parse error in ${ConfigureMonteverdi_H}. Cannot continue") - endif() - - string( - REGEX REPLACE "\"" "" - PKG_OTB_INSTALL_DATA_DIR - "${ConfigureMonteverdi_H_CONTENTS}") - - if(NOT PKG_OTB_INSTALL_DATA_DIR) - message(FATAL_ERROR "parse error in ${ConfigureMonteverdi_H_CONTENTS}. Cannot continue") - endif() - - string(STRIP "${PKG_OTB_INSTALL_DATA_DIR}" PKG_OTB_INSTALL_DATA_DIR) - - set(PKG_OTB_TRANSLATIONS_DIRNAME "${PKG_OTB_INSTALL_DATA_DIR}/i18n") - - # Just check if required variables are defined. - foreach(req - PACKAGE_OTB_SRC_DIR - PACKAGE_SUPPORT_FILES_DIR - QT_PLUGINS_DIR - PKG_STAGE_BIN_DIR - PKG_QTSQLITE_FILENAME - PKG_QTPLUGINS_DIR - PKG_QT_TRANSLATIONS_DIR - PKG_OTB_TRANSLATIONS_DIRNAME - ) - if(NOT DEFINED ${req} OR "${${req}}" STREQUAL "") - message(FATAL_ERROR "you must set ${req} before calling this method") - endif() - set(vars "${vars} ${req}=[${${req}}]\n") - endforeach(req) - - #install icon file for .app file. Monteverdi and Mapla has same icon! - if(APPLE) - install(FILES ${PACKAGE_SUPPORT_FILES_DIR}/Monteverdi.icns - DESTINATION ${PKG_STAGE_DIR}) - endif() - - ####################### install sqldriver plugin ######################## - install(FILES ${QT_PLUGINS_DIR}/sqldrivers/${PKG_QTSQLITE_FILENAME} - DESTINATION ${PKG_QTPLUGINS_DIR}/sqldrivers) - - ####################### install qt4 translations ########################### - #get all translations already distributed with qt4 - get_qt_translation_files(QT_TRANSLATIONS_FILES) - - #install all files in ${QT_TRANSLATIONS_FILES} - install(FILES ${QT_TRANSLATIONS_FILES} DESTINATION ${PKG_QT_TRANSLATIONS_DIR}) - - ####################### install monteverdi translations ##################### - #translation of monteverdi specific strings - if(NOT EXISTS "${OTB_INSTALL_DIR}/${PKG_OTB_TRANSLATIONS_DIRNAME}") - message(FATAL_ERROR "Error ${OTB_INSTALL_DIR}/${PKG_OTB_TRANSLATIONS_DIRNAME} not exists") - endif() - - file(GLOB APP_TS_FILES ${PACKAGE_OTB_SRC_DIR}/i18n/*.ts) # qm files - foreach(APP_TS_FILE ${APP_TS_FILES}) - get_filename_component(APP_TS_FILENAME ${APP_TS_FILE} NAME_WE) - install(FILES ${OTB_INSTALL_DIR}/${PKG_OTB_TRANSLATIONS_DIRNAME}/${APP_TS_FILENAME}.qm - DESTINATION ${PKG_STAGE_DIR}/${PKG_OTB_TRANSLATIONS_DIRNAME} - ) - endforeach() - -endfunction() diff --git a/SuperBuild/Packaging/PackageHelper.cmake b/SuperBuild/Packaging/PackageHelper.cmake deleted file mode 100644 index cca27e9a0f1684cea475756bee5fb26453d5a416..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/PackageHelper.cmake +++ /dev/null @@ -1,577 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -macro(macro_super_package) - cmake_parse_arguments(PKG "" "STAGE_DIR" "" ${ARGN} ) - - set(LINUX FALSE) - if( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND NOT MINGW) - set(LINUX TRUE) - endif() - - if("${PKG_STAGE_DIR}" STREQUAL "") - message(FATAL_ERROR "PKG_STAGE_DIR is empty. Just can't continue.") - endif() - - if(NOT DEPENDENCIES_INSTALL_DIR) - message(FATAL_ERROR "DEPENDENCIES_INSTALL_DIR is not set of empty") - endif() - - if(LINUX) - if(NOT FILE_COMMAND) - message(FATAL_ERROR "warning: No 'file' command, cannot continue...") - endif() - - if(NOT PATCHELF_PROGRAM) - message(FATAL_ERROR "PATCHELF_PROGRAM not set") - endif() - endif(LINUX) - - #setting this variable. prints a lot of debug information - #set( PKG_DEBUG 1) - - set(loader_program_PATHS) - set(eol_char "E") - if(MSVC) - set(loader_program_PATHS) - set(loader_program_names "dumpbin") - set(loader_program_args "/DEPENDENTS") - set(loader_program_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$") - elseif(APPLE) - set(loader_program_PATHS) - set(loader_program_names otool) - set(loader_program_args "-l" ) - set(loader_program_regex ".*name.*([ ].*dylib ).*${eol_char}$") - elseif(LINUX) - set(loader_program_PATHS) - set(loader_program_names objdump) - set(loader_program_args "-p" ) - set(loader_program_regex "^..NEEDED.*([ ].*so.*)${eol_char}$") - elseif(MINGW) - set(loader_program_PATHS "${MXE_MXEROOT}/usr/bin") - set(loader_program_names "${OTB_TARGET_SYSTEM_ARCH}-w64-mingw32.shared-objdump") - set(loader_program_args "-p") - set(loader_program_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$") - else() - message(FATAL_ERROR "Unknown platform: ") - endif() - - find_program(LOADER_PROGRAM "${loader_program_names}" PATHS ${loader_program_PATHS}) - if(NOT LOADER_PROGRAM) - message(FATAL_ERROR "${loader_program_names} not found in ${loader_program_PATHS}.") - endif() - - include(GetPrerequisites) - - set(LOADER_PROGRAM_ARGS ${loader_program_args}) - - set(DEST_BIN_DIR bin) - set(DEST_APP_DIR lib/otb/applications) - - set(LIB_PREFIX lib) - set(DEST_LIB_DIR lib) - set(EXE_EXT "") - set(SCR_EXT ".sh") - set(LIB_EXT ".so") - set(PYMODULE_EXT ".so") - if(WIN32) - set(LIB_PREFIX) - set(DEST_LIB_DIR bin) - set(EXE_EXT ".exe") - set(LIB_EXT ".dll") - set(SCR_EXT ".bat") - set(PYMODULE_EXT ".pyd") - elseif(APPLE) - set(LIB_EXT ".dylib") - endif() - - # find_loader_and_args(LOADER_PROGRAM LOADER_PROGRAM_ARGS) - - find_python_soname(python_INSTALLED_SONAME) - - set(PKG_SEARCHDIRS) - if(WIN32) - if(MSVC) - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/bin") #all other dlls - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/lib") #Qt & Qwt dlls - - if(NOT PKG_GENERATE_XDK) - if(DEFINED ENV{UniversalCRTSdkDir}) - file(TO_CMAKE_PATH "$ENV{UniversalCRTSdkDir}" UCRT_SDK_DIR) - list( - APPEND - PKG_SEARCHDIRS - "${UCRT_SDK_DIR}/Redist/ucrt/DLLs/${OTB_TARGET_SYSTEM_ARCH}" - ) #ucrt dlls - else() - message(FATAL_ERROR - "UniversalCRTSdkDir variable not set. call vcvarsall.bat <arch> first before starting build.") - endif() - - #additional msvc redist dll from VCINSTALLDIR - if(DEFINED ENV{VCINSTALLDIR}) - file(TO_CMAKE_PATH "$ENV{VCINSTALLDIR}" PKG_VCINSTALLDIR) - list( - APPEND - PKG_SEARCHDIRS - "${PKG_VCINSTALLDIR}/redist/${OTB_TARGET_SYSTEM_ARCH}/Microsoft.VC140.CRT" - "${PKG_VCINSTALLDIR}/redist/${OTB_TARGET_SYSTEM_ARCH}/Microsoft.VC140.OPENMP" - ) - else() - message(FATAL_ERROR - "VCINSTALLDIR variable not set. call vcvarsall.bat <arch> first before starting build.") - endif() - endif() #NOT PKG_GENERATE_XDK - else() - file(GLOB MXE_GCC_LIB_DIR "${DEPENDENCIES_INSTALL_DIR}/bin/gcc*") - list(APPEND PKG_SEARCHDIRS ${MXE_GCC_LIB_DIR}) - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/qt/bin") #Qt - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/qt/lib") #Qwt - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/bin") #mxe dlls - endif() - else() #unixes - list(APPEND PKG_SEARCHDIRS "${OTB_INSTALL_DIR}/lib") #so - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/lib") #superbuild .so /.dylib - endif() - - #common for all platforms. - set(OTB_APPLICATIONS_DIR "${OTB_INSTALL_DIR}/lib/otb/applications") - list(APPEND PKG_SEARCHDIRS "${DEPENDENCIES_INSTALL_DIR}/bin") #superbuild, mxe binaries - list(APPEND PKG_SEARCHDIRS "${OTB_INSTALL_DIR}/bin") #otbApplicationLauncherCommandLine.. - list(APPEND PKG_SEARCHDIRS "${OTB_APPLICATIONS_DIR}") #otb apps - list(APPEND PKG_SEARCHDIRS "${OTB_INSTALL_DIR}/lib/otb/python") #otbApplication.py - - if(PKG_GENERATE_XDK) - list(APPEND PKG_SEARCHDIRS ${OTB_BINARY_DIR}/bin) - endif() - - macro_empty_package_staging_directory() - - set(PKG_PEFILES) - - func_prepare_package() - - set(program_list) - set(WITH_PYTHON "false") - if(OTB_WRAP_PYTHON) - set(WITH_PYTHON "true") - endif() - - set(IS_XDK "false") - - if(LINUX) - set(PKGSETUP_IN_FILENAME linux_pkgsetup.in) - elseif(APPLE) - set(PKGSETUP_IN_FILENAME macx_pkgsetup.in) - endif() - - if(PKG_GENERATE_XDK) - set(IS_XDK "true") - set(WITH_PYTHON "false") - message(STATUS "OTB_WRAP_PYTHON is set. But this will not be included in XDK") - if("${PKG_ITK_SB_VERSION}" STREQUAL "") - message(FATAL_ERROR "PKG_ITK_SB_VERSION not set. This is required for XDK") - endif() - - func_install_xdk_files() - endif() #PKG_GENERATE_XDK - - ############# install package configure script ################ - #if(UNIX AND NOT WIN32) - if(UNIX AND NOT WIN32) - #avoid OTB stuff inside make_symlinks script - file(STRINGS "${CMAKE_BINARY_DIR}/make_symlinks_temp" make_symlinks_list) -# func_lisp( make_symlinks_list ) - file(WRITE ${CMAKE_BINARY_DIR}/make_symlinks "#!/bin/sh\n") - foreach(make_symlink_cmd ${make_symlinks_list}) - file(APPEND ${CMAKE_BINARY_DIR}/make_symlinks - "${make_symlink_cmd}\n") - endforeach() - - if(APPLE) - set(ORIGINAL_RPATH_TO_REPLACE ${DEPENDENCIES_INSTALL_DIR}/lib) - endif() - - configure_file(${PACKAGE_SUPPORT_FILES_DIR}/${PKGSETUP_IN_FILENAME} - ${CMAKE_BINARY_DIR}/pkgsetup @ONLY) - - list(APPEND program_list "${CMAKE_BINARY_DIR}/pkgsetup") - list(APPEND program_list "${CMAKE_BINARY_DIR}/make_symlinks") - - ########### install patchelf( linux only) ################## - if(LINUX) - list(APPEND program_list "${PATCHELF_PROGRAM}") - endif() - endif() - - foreach(prog ${program_list}) - install( - PROGRAMS ${prog} - DESTINATION ${PKG_STAGE_DIR}) - endforeach() - - ############# otb_loader executable ################ - add_executable(otb_loader ${PACKAGE_SUPPORT_FILES_DIR}/otb_loader.cxx) - target_link_libraries(otb_loader ${CMAKE_DL_LIBS}) - install(TARGETS otb_loader - RUNTIME DESTINATION ${PKG_STAGE_DIR}/bin COMPONENT Runtime) - - # We need qt.conf on windows. for macx and linux we write it - # after extracting package - if(WIN32 AND NOT PKG_GENERATE_XDK) - install(FILES - ${PACKAGE_SUPPORT_FILES_DIR}/qt.conf - DESTINATION ${PKG_STAGE_DIR}/bin - ) - endif() - - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/README - DESTINATION ${PKG_STAGE_DIR}) - -endmacro(macro_super_package) - - -function(func_prepare_package) - - file(WRITE ${CMAKE_BINARY_DIR}/make_symlinks_temp "") - - #This must exist in any OTB Installation. minimal or full - #set(PKG_PEFILES "${OTB_INSTALL_DIR}/bin/otbApplicationLauncherCommandLine${EXE_EXT}") - if(NOT EXISTS "${OTB_INSTALL_DIR}/bin/otbApplicationLauncherCommandLine${EXE_EXT}") - message( - FATAL_ERROR - "${OTB_INSTALL_DIR}/bin/otbApplicationLauncherCommandLine${EXE_EXT} not found.") - endif() - - set(PKG_PEFILES "otbApplicationLauncherCommandLine${EXE_EXT}") - - foreach(exe_file - "otbApplicationLauncherQt" "iceViewer" "otbTestDriver" "monteverdi" "mapla") - if(EXISTS "${OTB_INSTALL_DIR}/bin/${exe_file}${EXE_EXT}") - list(APPEND PKG_PEFILES "${exe_file}${EXE_EXT}") - else() - message(STATUS "${exe_file}${EXE_EXT} not found in ${OTB_INSTALL_DIR}/bin. (skipping)") - endif() - endforeach() - - if(PKG_GENERATE_XDK) - #Qt stuff - list(APPEND PKG_PEFILES "lrelease${EXE_EXT}") - list(APPEND PKG_PEFILES "moc${EXE_EXT}") - list(APPEND PKG_PEFILES "qmake${EXE_EXT}") - list(APPEND PKG_PEFILES "rcc${EXE_EXT}") - list(APPEND PKG_PEFILES "uic${EXE_EXT}") - list(APPEND PKG_PEFILES "proj${EXE_EXT}") - list(APPEND PKG_PEFILES "cs2cs${EXE_EXT}") - - #shark is optional - if(EXISTS "${DEPENDENCIES_INSTALL_DIR}/bin/sharkVersion${EXE_EXT}") - list(APPEND PKG_PEFILES "sharkVersion${EXE_EXT}") - endif() - - #RK: there is a bug in itk cmake files in install tree - #we workaround with below code - #start hack - file(GLOB itk_all_lib_files - "${DEPENDENCIES_INSTALL_DIR}/${DEST_LIB_DIR}/${LIB_PREFIX}itk*${LIB_EXT}*" - "${DEPENDENCIES_INSTALL_DIR}/${DEST_LIB_DIR}/${LIB_PREFIX}ITK*${LIB_EXT}*" - ) - - foreach(itk_lib_file ${itk_all_lib_files}) - func_is_file_a_symbolic_link("${itk_lib_file}" a_symlink itk_lib_file_target) - if(NOT a_symlink) - list(APPEND PKG_PEFILES "${itk_lib_file}") - endif() - endforeach() - #end hack - - file(GLOB otb_test_exe_list - "${DEPENDENCIES_INSTALL_DIR}/bin/gdal*${EXE_EXT}" - "${OTB_BINARY_DIR}/bin/*Test*${EXE_EXT}" - ) - foreach(otb_test_exe ${otb_test_exe_list}) - get_filename_component(otb_test_exe_name ${otb_test_exe} NAME) - list(APPEND PKG_PEFILES ${otb_test_exe_name}) - endforeach() - endif() - - # special case for msvc: ucrtbase.dll must be explicitly vetted. - # for proj.dll, see Mantis-1424 - if(MSVC AND NOT PKG_GENERATE_XDK) - list(APPEND PKG_PEFILES "ucrtbase.dll") - list(APPEND PKG_PEFILES "proj.dll") - endif() - - file(GLOB OTB_APPS_LIST "${OTB_APPLICATIONS_DIR}/otbapp_*${LIB_EXT}") # /lib/otb - list(APPEND PKG_PEFILES ${OTB_APPS_LIST}) - - if(NOT PKG_GENERATE_XDK) - if(EXISTS "${OTB_INSTALL_DIR}/lib/otb/python/_otbApplication${PYMODULE_EXT}") - install( - DIRECTORY - ${OTB_INSTALL_DIR}/lib/otb/python - DESTINATION ${PKG_STAGE_DIR}/lib - ) - else() - if(OTB_WRAP_PYTHON) - message(FATAL_ERROR "OTB_WRAP_PYTHON is set , but cannot find _otbApplication${PYMODULE_EXT}") - endif() - endif() - endif()# if(NOT PKG_GENERATE_XDK) - - - func_install_support_files() - - unset(matched_vars CACHE) - get_vars_ending_with("_USED|_RESOLVED" matched_vars) - foreach (var_to_unset IN LISTS matched_vars) - if(PKG_DEBUG) - message("unset ${var_to_unset} from cache") - endif() - unset(${var_to_unset} CACHE) - endforeach() - - foreach(infile ${PKG_PEFILES}) - get_filename_component(bn ${infile} NAME) - func_process_deps(${bn}) - endforeach() - -endfunction() #func_prepare_package - -function(func_process_deps input_file) - - set(input_file_full_path) - search_library(${input_file} PKG_SEARCHDIRS input_file_full_path) - - if(NOT input_file_full_path) - if(LINUX) - setif_value_in_list(is_gtk_lib "${input_file}" ALLOWED_SYSTEM_DLLS) - if(is_gtk_lib) - search_library(${input_file} PKG_GTK_SEARCHDIRS input_file_full_path) - if( NOT input_file_full_path) - message(FATAL_ERROR "${input_file} not found. searched in ${PKG_GTK_SEARCHDIRS}") - endif() - endif() - if( NOT input_file_full_path) - message(FATAL_ERROR "${input_file} not found. searched in ${PKG_SEARCHDIRS}") - endif() - endif(LINUX) - - endif() #if(NOT input_file_full_path) - - if(NOT PKG_DEBUG) - message("Processing ${input_file_full_path}") - endif() - - set(is_executable FALSE) - is_file_executable2(input_file_full_path is_executable) - - if(NOT is_executable) - #copy back to input_file_full_path - pkg_install_rule(${input_file_full_path}) - message("not is_executable ${input_file_full_path}") - return() - endif() #NOT is_executable - - if(UNIX) - # Deal with symlinks. - # For any valid symlinks, (see 'not_valid' below) - # we append ln -s source target commands to a file - # That file is executed during installation. - get_filename_component(bn_we ${input_file_full_path} NAME_WE) - get_filename_component(bn_path ${input_file_full_path} PATH) - - file(GLOB sofiles "${bn_path}/${bn_we}*") - foreach(sofile ${sofiles}) - get_filename_component(basename_of_sofile ${sofile} NAME) - get_filename_component(sofile_ext ${sofile} EXT) - set(not_valid FALSE) - if( "${sofile_ext}" MATCHES ".la" - OR "${sofile_ext}" MATCHES ".prl" - OR "${sofile_ext}" MATCHES ".a" - OR IS_DIRECTORY "${sofile}" ) - set(not_valid TRUE) - endif() - - if(not_valid) - continue() - endif() - - func_is_file_a_symbolic_link("${sofile}" is_symlink linked_to_file) - - if(is_symlink) - add_to_symlink_list("${linked_to_file}" "${basename_of_sofile}") - endif() # is_symlink - - endforeach() - - endif(UNIX) - - set(raw_items) - - execute_process( - COMMAND ${LOADER_PROGRAM} ${LOADER_PROGRAM_ARGS} "${input_file_full_path}" - RESULT_VARIABLE loader_rv - OUTPUT_VARIABLE loader_ov - ERROR_VARIABLE loader_ev - ) - - if(loader_rv) - message(FATAL_ERROR "loader_ev=${loader_ev}\n PACKAGE-OTB: result_variable is '${loader_rv}'") - endif() - - string(REPLACE ";" "\\;" candidates "${loader_ov}") - string(REPLACE "\n" "${eol_char};" candidates "${candidates}") - - get_filename_component(bn_name ${input_file_full_path} NAME) - set(${bn_name}_USED TRUE CACHE INTERNAL "") - - if(PKG_DEBUG) - message("Processing ${input_file} started. Set ${bn_name}_USED=${${bn_name}_USED}") - endif() - - foreach(candidate ${candidates}) - if(NOT candidate) - continue() - endif() - - if(NOT "${candidate}" MATCHES "${loader_program_regex}") - continue() - endif() - - string(REGEX REPLACE "${loader_program_regex}" "\\1" raw_item "${candidate}") - - if(NOT raw_item) - continue() - endif() - - string(STRIP ${raw_item} raw_item) - set(is_system FALSE) - setif_value_in_list(is_system "${raw_item}" SYSTEM_DLLS) - - if(APPLE AND NOT is_system) - if("${raw_item}" MATCHES "@rpath") - string(REGEX REPLACE "@rpath." "" raw_item "${raw_item}") - else() - message(FATAL_ERROR "'${raw_item}' does not have @rpath") - endif() - endif() - - if(PKG_DEBUG AND ${raw_item}_RESOLVED) - message("${raw_item} is already resolved [${raw_item}_RESOLVED=${${raw_item}_RESOLVED}]") - endif() - - if(is_system OR ${raw_item}_RESOLVED OR ${raw_item}_USED) - continue() - endif() - - list(APPEND raw_items ${raw_item}) - - endforeach() - - if(PKG_DEBUG) - string(REPLACE ";" "\n" raw_items_pretty_print "${raw_items}") - # message(FATAL_ERROR "raw_items=${raw_items_pretty_print}") - endif(PKG_DEBUG) - - if(raw_items) - list(REVERSE raw_items) - foreach(item ${raw_items}) - search_library(${item} PKG_SEARCHDIRS item_full_path) - set(is_a_symlink FALSE) - set(item_target_file) - func_is_file_a_symbolic_link("${item_full_path}" is_a_symlink item_target_file) - if(is_a_symlink) - set(${item}_RESOLVED TRUE CACHE INTERNAL "") - set(item ${item_target_file}) - endif() - if(PKG_DEBUG) - message("${bn_name} depends on '${item}'. So we now process '${item}'") # [ ${item}_USED=${${item}_USED} ${item}_RESOLVED=${${item}_RESOLVED}]") - endif() - func_process_deps(${item}) - endforeach() - endif() - - set(${bn_name}_RESOLVED TRUE CACHE INTERNAL "") - if(PKG_DEBUG) - message("All dependencies of ${bn_name} are processed. Install file and set ${bn_name}_RESOLVED=${${bn_name}_RESOLVED}") - endif() - - #Install the file with pkg_install_rule. This function has specific rules to decide wheather install file or not - pkg_install_rule(${input_file_full_path}) - -endfunction() #function(func_process_deps infile) - -function(pkg_install_rule src_file) - - get_filename_component(src_file_EXT ${src_file} EXT) - get_filename_component(src_file_NAME ${src_file} NAME) - - set(file_type PROGRAMS) - if(NOT src_file_EXT) - set(output_dir "bin") - elseif("${src_file_EXT}" MATCHES "(.[Dd][Ll][Ll]|.exe)") - set(output_dir "bin") - elseif("${src_file_EXT}" MATCHES "(.lib|.so|.dylib)") - set(output_dir "lib") - set(file_type FILES) - else() - message(FATAL_ERROR "unreachable code") - endif() - - set(SKIP_INSTALL FALSE) - - setif_value_in_list(is_gtk_lib "${src_file_NAME}" GTK_LIB_LIST_1) - if(is_gtk_lib) - if(PKG_GENERATE_XDK) - set(SKIP_INSTALL TRUE) - else() - set(output_dir "lib/gtk") - endif() #if(PKG_GENERATE_XDK) - endif() #if(is_gtk_lib) - - #special case - if("${src_file_NAME}" MATCHES "^otbapp_") - set(output_dir "lib/otb/applications") - set(file_type PROGRAMS) - endif() - - if(PKG_GENERATE_XDK) - if ("${src_file_NAME}" - MATCHES - "([Oo][Tt][Bb])|([Mm]onteverdi)|mapla|iceViewer" - ) - set(SKIP_INSTALL TRUE) - - message("SKIP_INSTALL for ${src_file_NAME}") - endif() - - endif() - - if(NOT SKIP_INSTALL) - install(${file_type} - "${src_file}" - DESTINATION - "${PKG_STAGE_DIR}/${output_dir}") - endif() - -endfunction() - diff --git a/SuperBuild/Packaging/PackageMacros.cmake b/SuperBuild/Packaging/PackageMacros.cmake deleted file mode 100644 index 237228235ad4b2040f02d28e8e7476c9bfd27887..0000000000000000000000000000000000000000 --- a/SuperBuild/Packaging/PackageMacros.cmake +++ /dev/null @@ -1,379 +0,0 @@ -# -# Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) -# -# This file is part of Orfeo Toolbox -# -# https://www.orfeo-toolbox.org/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# - -function(find_python_soname result) - set(${result} PARENT_SCOPE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} - -c - "import sys; from distutils import sysconfig; print (sysconfig.get_config_var('INSTSONAME'));" - RESULT_VARIABLE python_INSTALLED_SONAME_rv - OUTPUT_VARIABLE python_INSTALLED_SONAME_ov - ) - - if(NOT python_INSTALLED_SONAME_rv EQUAL 0) - message( FATAL_ERROR - "python_INSTALLED_SONAME_rv=${python_INSTALLED_SONAME_rv}: Cannot find python library") - endif() - set(${result} "${python_INSTALLED_SONAME_ov}" PARENT_SCOPE) -endfunction() - - -function(func_install_without_message src_dir dst_dir_suffix) - set (extra_func_args ${ARGN}) - list(LENGTH extra_func_args num_extra_args) - if (${num_extra_args} GREATER 0) - list(GET extra_func_args 0 optional_msg) - endif() - - if( "${dst_dir_suffix}" STREQUAL "") - set(dst_dir "${PKG_STAGE_DIR}") - else() - set(dst_dir "${PKG_STAGE_DIR}/${dst_dir_suffix}") - endif() - - get_filename_component(src_dir_name ${src_dir} NAME) - set(install_msg "message(STATUS \"Installing: ${CMAKE_INSTALL_PREFIX}/${dst_dir}/${src_dir_name} ${optional_msg}\")") - install(CODE "${install_msg}" ) - install( - DIRECTORY ${src_dir} - DESTINATION ${dst_dir} - MESSAGE_NEVER ) -endfunction() #func_install_without_message - - -macro(macro_empty_package_staging_directory) - message(STATUS "Empty package staging directory: ${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}") - execute_process( - COMMAND ${CMAKE_COMMAND} - -E remove_directory - "${CMAKE_INSTALL_PREFIX}/${PKG_STAGE_DIR}" - ) -endmacro() #macro_empty_package_staging_directory - - -function(search_library input_file pkg_searchdirs result) - set(${result} "" PARENT_SCOPE) - foreach(pkg_searchdir ${${pkg_searchdirs}}) - - if(EXISTS ${pkg_searchdir}/${input_file} ) - if(PKG_DEBUG) - message("Found '${pkg_searchdir}/${input_file}' (return)") - endif() - set(${result} "${pkg_searchdir}/${input_file}" PARENT_SCOPE) - return() - endif() - - #check for file with lowercase - string(TOLOWER "${input_file}" input_file_lower ) - if(EXISTS ${pkg_searchdir}/${input_file_lower}) - set(${result} "${pkg_searchdir}/${input_file_lower}" PARENT_SCOPE) - return() - endif() - endforeach() - -endfunction() - -macro(add_to_symlink_list src_file_name link_file_name) - #TODO: avoid code duplication here and later in install_rule - - set(SKIP_INSTALL FALSE) - - get_filename_component(src_file_name_NAME ${src_file_name} NAME) - - if(PKG_GENERATE_XDK) - if ("${src_file_name_NAME}" - MATCHES - "libOTB|libotb|otbApp|otbapp_|otbTest|libMonteverdi|monteverdi|mapla|iceViewer" - ) - set(SKIP_INSTALL TRUE) - endif() - endif(PKG_GENERATE_XDK) - - setif_value_in_list(is_gtk_lib "${src_file_name_NAME}" GTK_LIB_LIST_1) - if(is_gtk_lib AND PKG_GENERATE_XDK) - set(SKIP_INSTALL TRUE) - endif() - - - # NOTE: $OUT_DIR is set actually in pkgsetup.in. So don't try - # any pre-mature optimization on that variable names - if(NOT SKIP_INSTALL) - - set(lib_dir "lib") - if(is_gtk_lib) - set(lib_dir "lib/gtk") - endif() - file(APPEND - ${CMAKE_BINARY_DIR}/make_symlinks_temp - "ln -sf \"$OUT_DIR/${lib_dir}/${src_file_name}\" \"$OUT_DIR/${lib_dir}/${link_file_name}\" \n" - ) - endif() -endmacro() - -function(is_file_executable2 file_var result_var) - # - # A file is not executable until proven otherwise: - # - set(${result_var} 0 PARENT_SCOPE) - - get_filename_component(file_full "${${file_var}}" ABSOLUTE) - string(TOLOWER "${file_full}" file_full_lower) - # If file name ends in .exe on Windows, *assume* executable: - # - if(WIN32 AND NOT UNIX) - if("${file_full_lower}" MATCHES "(\\.exe|\\.dll)$") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - # A clause could be added here that uses output or return value of dumpbin - # to determine ${result_var}. In 99%+? practical cases, the exe name - # match will be sufficient... - # - endif() #WIN32 AND NOT UNIX - - func_is_file_a_symbolic_link("${file_full}" is_a_symlink file_full_target) - if(is_a_symlink) - message("Resolving '${file_full}' to '${file_full_target}") - get_filename_component(file_full_path "${file_full}" PATH) - set(file_full "${file_full_path}/${file_full_target}") - if( EXISTS "${file_full}") - set(${file_var} "${file_full}" PARENT_SCOPE) - else() - message(FATAL_ERROR "${file_full} does not exists. Cannot continue") - endif() - - string(TOLOWER "${file_full}" file_full_lower) - endif() - - # Use the information returned from the Unix shell command "file" to - # determine if ${file_full} should be considered an executable file... - # - # If the file command's output contains "executable" and does *not* contain - # "text" then it is likely an executable suitable for prerequisite analysis - # via the get_prerequisites macro. - # - #if we are not on a unix or unix-like platform, then we don't have any business here - if(NOT UNIX) - return() - endif() - - if(NOT FILE_COMMAND) - message(FATAL_ERROR "warning: No 'file' command, cannot continue...") - endif() - - if(NOT EXISTS "${file_full}") - message(FATAL_ERROR "err. '${file_full}' does not exists or is not absolute path") - set(${file_var} "" PARENT_SCOPE) - endif() - - execute_process(COMMAND "${FILE_COMMAND}" "${file_full}" - RESULT_VARIABLE file_rv - OUTPUT_VARIABLE file_ov - ERROR_VARIABLE file_ev - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT file_rv STREQUAL "0") - message(FATAL_ERROR "${FILE_COMMAND} failed: ${file_rv}\n${file_ev}") - endif() - - # Replace the name of the file in the output with a placeholder token - # (the string " _file_full_ ") so that just in case the path name of - # the file contains the word "text" or "executable" we are not fooled - # into thinking "the wrong thing" because the file name matches the - # other 'file' command output we are looking for... - # - string(REPLACE "${file_full}" " _file_full_ " file_ov "${file_ov}") - string(TOLOWER "${file_ov}" file_ov) - - # message(STATUS "file_ov='${file_ov}'") - # below executable check works for both mac osx and linux - # message("file_full=${file_ov}") - if("${file_ov}" MATCHES "executable") - #message(STATUS "executable!") - if("${file_ov}" MATCHES "text") - set(${result_var} 0 PARENT_SCOPE) - #message(FATAL_ERROR "but text, so *not* a binary executable!") - else() - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - endif() - - # detect position independent executables on Linux, - # where "file" gives "dynamically linked (uses shared libraries)" - if("${file_ov}" MATCHES "dynamically linked.*\(uses shared libs\)") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - # detect position independent executables on Linux, - # where "file" gives "shared object ... (uses shared libraries)" - if("${file_ov}" MATCHES "shared object.*\(uses shared libs\)") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - # detect shared libraries on Linux, - # where "file" gives "ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped" - if("${file_ov}" MATCHES "elf.*shared object.*version") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - # "file" version 5.22 does not print "(used shared libraries)" - # but uses "interpreter" - if("${file_ov}" MATCHES "shared object.*interpreter") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - if(APPLE) - # detect shared libraries on Mac OSX - # where "file" gives "Mach-O 64-bit x86_64 dynamically linked shared library" - if("${file_ov}" MATCHES "mach-o.*dynamically linked shared library") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - #below check is redundant. detect executables on Mac OSX - # where "file" gives "Mach-O 64-bit x86_64 executable" - if("${file_ov}" MATCHES "mach-o.*executable") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - # detect shared libraries on Mac OSX - # where "file" gives "Mach-O 64-bit x86_64 bundle" - if("${file_ov}" MATCHES "mach-o.*bundle") - set(${result_var} 1 PARENT_SCOPE) - return() - endif() - - endif(APPLE) - -endfunction() - - -# The below function is modified from GetPrerequisities.cmake -# which is distributed with CMake. -function(func_is_file_a_symbolic_link file result_var1 result_var2) - # - # A file is not executable until proven otherwise: - # - set(${result_var1} 0 PARENT_SCOPE) - set(${result_var2} "" PARENT_SCOPE) - - get_filename_component(file_full "${file}" ABSOLUTE) - string(TOLOWER "${file_full}" file_full_lower) - - # If file name ends in .exe on Windows, *assume* executable: - # - if(WIN32 AND NOT UNIX) - if("${file_full_lower}" MATCHES "\\.lnk$") - set(${result_var1} 1 PARENT_SCOPE) - #Assuming the file is linked to a file with same name without .lnk extension - get_filename_component(name_we_lnk "${file_full_lower}" NAME_WE) - set(${result_var2} "${name_we_lnk}" PARENT_SCOPE) - return() - endif() - - # A clause could be added here that uses output or return value of dumpbin - # to determine ${result_var}. In 99%+? practical cases, the exe name - # match will be sufficient... - # - endif() - - #if we are not on a unix or unix-like platform, then we don't have any business here - if(NOT UNIX) - return() - endif() - - # Use the information returned from the Unix shell command "file" to - # determine if ${file_full} should be considered an executable file... - # - # If the file command's output contains "executable" and does *not* contain - # "text" then it is likely an executable suitable for prerequisite analysis - # via the get_prerequisites macro. - # - if(NOT FILE_COMMAND) - message(FATAL_ERROR "warning: No 'file' command, cannot continue...") - endif() - - execute_process(COMMAND "${FILE_COMMAND}" "${file_full}" - RESULT_VARIABLE file_rv - OUTPUT_VARIABLE file_ov - ERROR_VARIABLE file_ev - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT file_rv STREQUAL "0") - message(FATAL_ERROR "${FILE_COMMAND} failed: ${file_rv}\n${file_ev}") - endif() - - # Replace the name of the file in the output with a placeholder token - # (the string " _file_full_ ") so that just in case the path name of - # the file contains the word "text" or "executable" we are not fooled - # into thinking "the wrong thing" because the file name matches the - # other 'file' command output we are looking for... - # - string(REPLACE "${file_full}" " _file_full_ " file_ov "${file_ov}") - string(TOLOWER "${file_ov}" file_ov_lower) - - # message(FATAL_ERROR "file_ov='${file_ov}'") - if("${file_ov_lower}" MATCHES "symbolic link") - set(${result_var1} 1 PARENT_SCOPE) - #Now find where the symlink is linked to. - #Do a regex replace - string(REGEX REPLACE "_file_full_*.*symbolic.link.to." "" symlinked_to ${file_ov}) - - #older version of file command output has [`} character(remove it). - string(REPLACE "`" "" symlinked_to ${symlinked_to} ) - - #older version of file command output has {'} character(remove it). - string(REPLACE "'" "" symlinked_to "${symlinked_to}") - - #strip final output - string(STRIP ${symlinked_to} symlinked_to) - set(${result_var2} "${symlinked_to}" PARENT_SCOPE) - - #message(FATAL_ERROR "${file_full} is symlinked_to ${symlinked_to}") - return() - endif() - -endfunction() - -macro(setif_value_in_list matched value list) - set(${matched}) - string(TOLOWER ${value} value_) - foreach (pattern ${${list}}) - string(TOLOWER ${pattern} pattern_) - if("${value_}" MATCHES "${pattern_}") - set(${matched} TRUE) - endif() - endforeach() - #message("'${value}' not found in ${list}") -endmacro() - -function (get_vars_ending_with suffix result) - get_cmake_property(all_cmake_vars VARIABLES) - string (REGEX MATCHALL "(^|;)[A-Za-z0-9_\\.\\-]*(${suffix})" _matchedVars "${all_cmake_vars}") - set(${result} ${_matchedVars} PARENT_SCOPE) -endfunction() diff --git a/SuperBuild/patches/ITK/itk-2-itktestlib-all.diff b/SuperBuild/patches/ITK/itk-2-itktestlib-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..dc0b0cbdbb7e18c55a0490150cf92d938cb3ab59 --- /dev/null +++ b/SuperBuild/patches/ITK/itk-2-itktestlib-all.diff @@ -0,0 +1,35 @@ +diff -burN InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/CMakeLists.txt InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/CMakeLists.txt +--- InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/CMakeLists.txt 2017-08-22 11:53:55.960938649 +0200 ++++ InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/CMakeLists.txt 2017-08-22 11:56:07.289820954 +0200 +@@ -18,10 +18,14 @@ + # Retrive the variable type to CACHE. + set(BUILD_EXAMPLES ${BUILD_EXAMPLES} CACHE BOOL "Build the examples from the ITK Software Guide." FORCE) + +-foreach(lib itkvcl itkv3p_netlib itktestlib itkvnl itkvnl_algo itknetlib) ++foreach(lib itkvcl itkv3p_netlib itkvnl itkvnl_algo itknetlib) + itk_module_target(${lib} NO_INSTALL) + endforeach() + ++if(BUILD_TESTING) ++ itk_module_target(itktestlib NO_INSTALL) ++endif() ++ + foreach(exe + netlib_integral_test + netlib_lbfgs_example +diff -burN InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt +--- InsightToolkit-4.12.0.orig/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt 2017-08-22 11:53:55.960938649 +0200 ++++ InsightToolkit-4.12.0/Modules/ThirdParty/VNL/src/vxl/core/CMakeLists.txt 2017-08-22 11:56:56.410150930 +0200 +@@ -131,8 +131,10 @@ + set(CORE_VIDEO_FOUND OFF CACHE INTERNAL "VXL core video libraries built") + endif () + +-# common test executable +-add_subdirectory(testlib) ++# common test executable if testing enabled ++if(BUILD_TESTING) ++ add_subdirectory(testlib) ++endif() + + # Tests that check and output the vxl configuration + # NOTE: some external projects remove the tests directory (aka ITK) diff --git a/SuperBuild/patches/QT4/configure_qt4.bat.in b/SuperBuild/patches/QT4/configure_qt4.bat.in index 0439a883f043d14e36b2714fe150268641e7738b..8ce395fc784d0c9da6743636f3f9e35713bc41d7 100755 --- a/SuperBuild/patches/QT4/configure_qt4.bat.in +++ b/SuperBuild/patches/QT4/configure_qt4.bat.in @@ -4,7 +4,7 @@ set SB_SAVE_LIB=%LIB% set INCLUDE=%INCLUDE%;@QT4_INCLUDE_PREFIX_NATIVE@;@QT4_INCLUDE_PREFIX_NATIVE@\freetype2 set LIB=%LIB%;@QT4_LIB_PREFIX_NATIVE@ -@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@\freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-qt3support -no-xmlpatterns -no-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ +@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@\freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-accessibility -no-qt3support -no-xmlpatterns -no-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ set INCLUDE=%SB_SAVE_INCLUDE% set LIB=%SB_SAVE_LIB% diff --git a/SuperBuild/patches/QT4/configure_qt4.sh.in b/SuperBuild/patches/QT4/configure_qt4.sh.in index 1ed3ef3f981f0bb5343f9d2202b5d5cd5150bc70..ee254d3f306fa713ec12809ae7c3616485d31497 100755 --- a/SuperBuild/patches/QT4/configure_qt4.sh.in +++ b/SuperBuild/patches/QT4/configure_qt4.sh.in @@ -1 +1 @@ -@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@/freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-qt3support -no-xmlpatterns -no-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib @QT4_SB_CONFIG@ +@QT4_CONFIGURE_SCRIPT@ -prefix @QT4_INSTALL_PREFIX_NATIVE@ -L @QT4_LIB_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@ -I @QT4_INCLUDE_PREFIX_NATIVE@/freetype2 -opensource -confirm-license -release -shared -nomake demos -nomake examples -nomake tools -no-phonon-backend -no-phonon -no-script -no-scripttools -no-multimedia -no-audio-backend -no-webkit -no-declarative -no-accessibility -no-qt3support -no-xmlpatterns -no-sql-sqlite -no-openssl -no-libtiff -no-libmng -system-libpng -system-libjpeg -system-zlib -no-dbus @QT4_SB_CONFIG@ diff --git a/SuperBuild/patches/QT4/qjpeghandler.pri b/SuperBuild/patches/QT4/qjpeghandler.pri deleted file mode 100644 index 8b11ad8df81ab5ca5be7fd8ec847be4ccfebcc0c..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/QT4/qjpeghandler.pri +++ /dev/null @@ -1,10 +0,0 @@ -# common to plugin and built-in forms -INCLUDEPATH *= $$PWD -HEADERS += $$PWD/qjpeghandler_p.h -SOURCES += $$PWD/qjpeghandler.cpp -contains(QT_CONFIG, system-jpeg) { - if(unix|win32-g++*): LIBS += -ljpeg - else:win32: LIBS += jpeg.lib -} else { - include($$PWD/../../3rdparty/libjpeg.pri) -} diff --git a/SuperBuild/patches/QT4/qt4-1-minbuild-all.diff b/SuperBuild/patches/QT4/qt4-1-minbuild-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..ae4bdcfd5066945d1738234ee62900b04d02d1c4 --- /dev/null +++ b/SuperBuild/patches/QT4/qt4-1-minbuild-all.diff @@ -0,0 +1,147 @@ +diff -burN qt-everywhere-opensource-src-4.8.7.orig/config.tests/unix/freetype/freetype.pri qt-everywhere-opensource-src-4.8.7/config.tests/unix/freetype/freetype.pri +--- qt-everywhere-opensource-src-4.8.7.orig/config.tests/unix/freetype/freetype.pri 2017-08-18 10:54:50.327911982 +0200 ++++ qt-everywhere-opensource-src-4.8.7/config.tests/unix/freetype/freetype.pri 2017-08-23 15:20:17.132268013 +0200 +@@ -1,5 +1,5 @@ + !cross_compile { +- TRY_INCLUDEPATHS = /include /usr/include $$QMAKE_INCDIR $$QMAKE_INCDIR_X11 $$INCLUDEPATH ++ TRY_INCLUDEPATHS = $$INCLUDEPATH $$QMAKE_INCDIR $$QMAKE_INCDIR_X11 + # LSB doesn't allow using headers from /include or /usr/include + linux-lsb-g++:TRY_INCLUDEPATHS = $$QMAKE_INCDIR $$QMAKE_INCDIR_X11 $$INCLUDEPATH + for(p, TRY_INCLUDEPATHS) { +diff -burN qt-everywhere-opensource-src-4.8.7.orig/projects.pro qt-everywhere-opensource-src-4.8.7/projects.pro +--- qt-everywhere-opensource-src-4.8.7.orig/projects.pro 2017-08-18 10:54:46.519887277 +0200 ++++ qt-everywhere-opensource-src-4.8.7/projects.pro 2017-08-23 15:20:03.224174152 +0200 +@@ -11,7 +11,7 @@ + symbian|integrity { + QT_BUILD_PARTS = libs tools examples demos + } else { +- QT_BUILD_PARTS = libs tools examples demos docs translations ++ QT_BUILD_PARTS = libs tools examples demos translations + } + } else { #make sure the order makes sense + contains(QT_BUILD_PARTS, translations) { +diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/gui/image/qjpeghandler.pri qt-everywhere-opensource-src-4.8.7/src/gui/image/qjpeghandler.pri +--- qt-everywhere-opensource-src-4.8.7.orig/src/gui/image/qjpeghandler.pri 2017-08-18 10:54:45.407880063 +0200 ++++ qt-everywhere-opensource-src-4.8.7/src/gui/image/qjpeghandler.pri 2017-08-23 15:20:03.292174610 +0200 +@@ -4,7 +4,7 @@ + SOURCES += $$PWD/qjpeghandler.cpp + contains(QT_CONFIG, system-jpeg) { + if(unix|win32-g++*): LIBS += -ljpeg +- else:win32: LIBS += libjpeg.lib ++ else:win32: LIBS += jpeg.lib + } else { + include($$PWD/../../3rdparty/libjpeg.pri) + } +diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/plugins/graphicssystems/graphicssystems.pro qt-everywhere-opensource-src-4.8.7/src/plugins/graphicssystems/graphicssystems.pro +--- qt-everywhere-opensource-src-4.8.7.orig/src/plugins/graphicssystems/graphicssystems.pro 2017-08-18 10:54:45.583881205 +0200 ++++ qt-everywhere-opensource-src-4.8.7/src/plugins/graphicssystems/graphicssystems.pro 2017-08-23 15:20:03.292174610 +0200 +@@ -1,5 +1,4 @@ + TEMPLATE = subdirs +-SUBDIRS += trace + !wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl + contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { + SUBDIRS += openvg +diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/plugins/imageformats/imageformats.pro qt-everywhere-opensource-src-4.8.7/src/plugins/imageformats/imageformats.pro +--- qt-everywhere-opensource-src-4.8.7.orig/src/plugins/imageformats/imageformats.pro 2017-08-18 10:54:45.583881205 +0200 ++++ qt-everywhere-opensource-src-4.8.7/src/plugins/imageformats/imageformats.pro 2017-08-23 15:20:03.292174610 +0200 +@@ -3,7 +3,7 @@ + !contains(QT_CONFIG, no-jpeg):!contains(QT_CONFIG, jpeg):SUBDIRS += jpeg + !contains(QT_CONFIG, no-gif):!contains(QT_CONFIG, gif):SUBDIRS += gif + !contains(QT_CONFIG, no-mng):!contains(QT_CONFIG, mng):SUBDIRS += mng +-contains(QT_CONFIG, svg):SUBDIRS += svg ++# contains(QT_CONFIG, svg):SUBDIRS += svg + !contains(QT_CONFIG, no-tiff):!contains(QT_CONFIG, tiff):SUBDIRS += tiff + !contains(QT_CONFIG, no-ico):SUBDIRS += ico + !contains(QT_CONFIG, no-tga):SUBDIRS += tga +diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/plugins/plugins.pro qt-everywhere-opensource-src-4.8.7/src/plugins/plugins.pro +--- qt-everywhere-opensource-src-4.8.7.orig/src/plugins/plugins.pro 2017-08-18 10:54:45.599881309 +0200 ++++ qt-everywhere-opensource-src-4.8.7/src/plugins/plugins.pro 2017-08-23 15:20:03.292174610 +0200 +@@ -1,16 +1,16 @@ + TEMPLATE = subdirs + +-SUBDIRS *= sqldrivers script bearer +-unix:!symbian { +- contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv)|contains(QT_CONFIG,sun-libiconv):SUBDIRS *= codecs +-} else { +- SUBDIRS *= codecs +-} +-!contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats iconengines ++# SUBDIRS *= sqldrivers ++# unix:!symbian { ++# contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv)|contains(QT_CONFIG,sun-libiconv):SUBDIRS *= codecs ++# } else { ++# SUBDIRS *= codecs ++# } ++!contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats + !embedded:!qpa:!contains(QT_CONFIG, no-gui):SUBDIRS *= graphicssystems + embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers +-!win32:!embedded:!mac:!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS *= inputmethods +-!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible ++# !win32:!embedded:!mac:!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS *= inputmethods ++# !symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible + contains(QT_CONFIG, phonon): SUBDIRS *= phonon + qpa:SUBDIRS += platforms + contains(QT_CONFIG, declarative): SUBDIRS *= qmltooling +diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/src.pro qt-everywhere-opensource-src-4.8.7/src/src.pro +--- qt-everywhere-opensource-src-4.8.7.orig/src/src.pro 2017-08-18 10:54:46.487887069 +0200 ++++ qt-everywhere-opensource-src-4.8.7/src/src.pro 2017-08-23 15:20:03.292174610 +0200 +@@ -4,7 +4,7 @@ + unset(SRC_SUBDIRS) + win32:SRC_SUBDIRS += src_winmain + symbian:SRC_SUBDIRS += src_s60main +-SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib ++SRC_SUBDIRS += src_corelib + nacl: SRC_SUBDIRS -= src_network src_testlib + !symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus + !contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui +@@ -18,7 +18,7 @@ + contains(QT_CONFIG, xmlpatterns): SRC_SUBDIRS += src_xmlpatterns + contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon + contains(QT_CONFIG, multimedia): SRC_SUBDIRS += src_multimedia +-contains(QT_CONFIG, svg): SRC_SUBDIRS += src_svg ++# contains(QT_CONFIG, svg): SRC_SUBDIRS += src_svg + contains(QT_CONFIG, script): SRC_SUBDIRS += src_script + contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_declarative + contains(QT_CONFIG, webkit) { +@@ -52,8 +52,8 @@ + src_sql.target = sub-sql + src_network.subdir = $$QT_SOURCE_TREE/src/network + src_network.target = sub-network +-src_svg.subdir = $$QT_SOURCE_TREE/src/svg +-src_svg.target = sub-svg ++# src_svg.subdir = $$QT_SOURCE_TREE/src/svg ++# src_svg.target = sub-svg + src_script.subdir = $$QT_SOURCE_TREE/src/script + src_script.target = sub-script + src_scripttools.subdir = $$QT_SOURCE_TREE/src/scripttools +@@ -89,7 +89,7 @@ + src_xml.depends = src_corelib + src_xmlpatterns.depends = src_corelib src_network + src_dbus.depends = src_corelib src_xml +- src_svg.depends = src_corelib src_gui ++ # src_svg.depends = src_corelib src_gui + src_script.depends = src_corelib + src_scripttools.depends = src_script src_gui src_network + src_network.depends = src_corelib +@@ -105,7 +105,7 @@ + contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl + src_activeqt.depends = src_tools_idc src_gui + src_declarative.depends = src_gui src_script src_network +- src_plugins.depends = src_gui src_sql src_svg ++ src_plugins.depends = src_gui + contains(QT_CONFIG, multimedia):src_plugins.depends += src_multimedia + contains(QT_CONFIG, declarative):src_plugins.depends += src_declarative + src_s60installs.depends = $$TOOLS_SUBDIRS $$SRC_SUBDIRS +@@ -130,9 +130,9 @@ + src_declarative.depends += src_xmlpatterns + src_webkit.depends += src_xmlpatterns + } +- contains(QT_CONFIG, svg) { +- src_declarative.depends += src_svg +- } ++ # contains(QT_CONFIG, svg) { ++ # src_declarative.depends += src_svg ++ # } + } + + diff --git a/SuperBuild/patches/QT4/qt4-1-skip-qtnetwork-module-all.diff b/SuperBuild/patches/QT4/qt4-1-skip-qtnetwork-module-all.diff deleted file mode 100755 index 215f87cecafdb32d103dfa8cd7f9b5bd3de03734..0000000000000000000000000000000000000000 --- a/SuperBuild/patches/QT4/qt4-1-skip-qtnetwork-module-all.diff +++ /dev/null @@ -1,32 +0,0 @@ -diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/plugins/graphicssystems/graphicssystems.pro qt-everywhere-opensource-src-4.8.7/src/plugins/graphicssystems/graphicssystems.pro ---- qt-everywhere-opensource-src-4.8.7.orig/src/plugins/graphicssystems/graphicssystems.pro 2016-07-06 10:15:46.000000000 +0200 -+++ qt-everywhere-opensource-src-4.8.7/src/plugins/graphicssystems/graphicssystems.pro 2016-07-06 14:09:07.000000000 +0200 -@@ -1,5 +1,4 @@ - TEMPLATE = subdirs --SUBDIRS += trace - !wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl - contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) { - SUBDIRS += openvg -diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/plugins/plugins.pro qt-everywhere-opensource-src-4.8.7/src/plugins/plugins.pro ---- qt-everywhere-opensource-src-4.8.7.orig/src/plugins/plugins.pro 2016-07-06 10:15:46.000000000 +0200 -+++ qt-everywhere-opensource-src-4.8.7/src/plugins/plugins.pro 2016-07-06 12:58:14.000000000 +0200 -@@ -1,6 +1,6 @@ - TEMPLATE = subdirs - --SUBDIRS *= sqldrivers script bearer -+SUBDIRS *= sqldrivers - unix:!symbian { - contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv)|contains(QT_CONFIG,sun-libiconv):SUBDIRS *= codecs - } else { -diff -burN qt-everywhere-opensource-src-4.8.7.orig/src/src.pro qt-everywhere-opensource-src-4.8.7/src/src.pro ---- qt-everywhere-opensource-src-4.8.7.orig/src/src.pro 2016-07-06 10:15:47.000000000 +0200 -+++ qt-everywhere-opensource-src-4.8.7/src/src.pro 2016-07-06 10:18:44.000000000 +0200 -@@ -4,7 +4,7 @@ - unset(SRC_SUBDIRS) - win32:SRC_SUBDIRS += src_winmain - symbian:SRC_SUBDIRS += src_s60main --SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib -+SRC_SUBDIRS += src_corelib src_xml src_sql - nacl: SRC_SUBDIRS -= src_network src_testlib - !symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus - !contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui diff --git a/SuperBuild/patches/SHARK/shark-2-find-boost-all.diff b/SuperBuild/patches/SHARK/shark-2-find-boost-all.diff new file mode 100644 index 0000000000000000000000000000000000000000..a97c1ac4afd1f56118fdba14cf7b993755bb5c00 --- /dev/null +++ b/SuperBuild/patches/SHARK/shark-2-find-boost-all.diff @@ -0,0 +1,16 @@ +diff -burN Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0.orig/CMakeLists.txt Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0/CMakeLists.txt +--- Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0.orig/CMakeLists.txt 2017-08-22 11:31:50.472052695 +0200 ++++ Shark-349f29bd71c370e0f88f7fc9aa66fa5c4768fcb0/CMakeLists.txt 2017-08-22 11:32:36.448358789 +0200 +@@ -141,10 +141,8 @@ + + find_package( + Boost 1.48.0 REQUIRED COMPONENTS +- system date_time filesystem +- program_options serialization thread +- unit_test_framework +-) ++ serialization ++ ) + + if(NOT Boost_FOUND) + message(FATAL_ERROR "Please make sure Boost 1.48.0 is installed on your system")