endif()if(NOT OTB_INSTALL_DATA_DIR)set(OTB_INSTALL_DATA_DIR share/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})endif()if(NOT OTB_INSTALL_DOC_DIR)set(OTB_INSTALL_DOC_DIR share/doc/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR})endif()if(NOT OTB_INSTALL_PACKAGE_DIR)set(OTB_INSTALL_PACKAGE_DIR "${OTB_INSTALL_LIBRARY_DIR}/cmake/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")endif()# Override CMake's built-in add_* commands: assign LABELS to tests and targets# automatically. Depends on the CMake variable otb-module being set to the# "current" module when add_* is called.macro(verify_otb_module_is_set)if("" STREQUAL "${otb-module}")message(FATAL_ERROR "CMake variable otb-module is not set")endif()endmacro()#-----------------------------------------------------------------------------# Set a default build type if none was specifiedif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)message(STATUS "Setting build type to 'Release' as none was specified.")set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)# Set the possible values of build type for cmake-guiset_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug""Release""MinSizeRel""RelWithDebInfo")endif()#-----------------------------------------------------------------------------# Enable running cppcheck for each module on its source and test directories.option(OTB_CPPCHECK_TEST "Run cppcheck for static code analysis" OFF)mark_as_advanced(OTB_CPPCHECK_TEST)#-----------------------------------------------------------------------------# Forbid downloading resources from the network during a build. This helps# when building on systems without network connectivity to determine which# resources much be obtained manually and made available to the build.option(OTB_FORBID_DOWNLOADS "Do not download source code or data from the network" OFF)mark_as_advanced(OTB_FORBID_DOWNLOADS)macro(otb_download_attempt_check _name)if(OTB_FORBID_DOWNLOADS)message(SEND_ERROR "Attempted to download ${_name} when OTB_FORBID_DOWNLOADS is ON")endif()endmacro()# TODO : handle shared libs on windowsoption(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON)set(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

#----------------------------------------------------------------------# Make sure remote modules are downloaded before sorting out the module# dependencies.add_subdirectory(Modules/Remote)# Enable modules according to user inputs and the module dependency DAG.include(OTBModuleEnablement)#----------------------------------------------------------------------# Generate OTBConfig.cmake for the build tree.set(OTB_CONFIG_CODE "set(OTB_MODULES_DIR \"${OTB_MODULES_DIR}\")")

if(BUILD_TESTING)add_subdirectory(Utilities/InstallTest)endif()#-----------------------------------------------------------------------------# The subdirectories added below this line should use only the public# interface with find_package(ITK). Set ITK_DIR to use this ITK build.set(OTB_DIR "${OTB_BINARY_DIR}")if(BUILD_EXAMPLES)add_subdirectory(Examples)endif()#----------------------------------------------------------------------# Provide an option for generating documentation.add_subdirectory(Utilities/Doxygen)