project(ossimplugins)
MESSAGE("**********************Setting up ossimplugins********************")

IF(NOT APPLE)
  cmake_minimum_required(VERSION 2.6)
ELSE(NOT APPLE)
  cmake_minimum_required(VERSION 2.8)
ENDIF(NOT APPLE)

include(OssimVersion)
include(OssimCommonVariables)
include(OssimUtilities)

############################### OVERRIDE THE DEFAULTS TO APPEND THE PLUGIN INFORMATION###################


OPTION(OSSIM_INSTALL_PLUGINS_WITH_VERSION "Set to ON to build OSSIM's plugins to install with a version prefix like ossim-<version>/plugins.  Use OFF to not add a version and make it ossim/plugins." OFF)
OPTION(BUILD_OSSIM_PLUGIN "Set to ON to build OSSIM's core plugins that depend only on ossim.  Use OFF to skip this plugin." ON)
OPTION(BUILD_OSSIMCONTRIB_PLUGIN "Set to ON to build OSSIM's contrib plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMCSM_PLUGIN "Set to ON to build OSSIM's csm  plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMGDAL_PLUGIN "Set to ON to build OSSIM's gdal plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMGEOPDF_PLUGIN "Set to ON to build OSSIM's geopdf plugin.  Use OFF to skip this plugin." OFF)

# Old hdf plugin:
OPTION(BUILD_OSSIMHDF_PLUGIN "Set to ON to build OSSIM's hdf plugin.  Use OFF to skip this plugin." OFF)

# New split out hdf4 and hdf5 plugins:
OPTION(BUILD_OSSIMHDF4_PLUGIN "Set to ON to build OSSIM's hdf4 plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMHDF5_PLUGIN "Set to ON to build OSSIM's hdf5 plugin.  Use OFF to skip this plugin." OFF)

OPTION(BUILD_OSSIMKAKADU_PLUGIN "Set to ON to build OSSIM's kakadu plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMKMLSUPEROVERLAY_PLUGIN "Set to ON to build OSSIM's kml super overvlay plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMLAS_PLUGIN "Set to ON to build OSSIM's LAS plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMLIBLAS_PLUGIN "Set to ON to build OSSIM's LIBLAS plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMLIBRAW_PLUGIN "Set to ON to build OSSIM's lib raw plugin that is an interface to draw plugin.  Use OFF to skip this plugin." ON)
OPTION(BUILD_OSSIMMRSID_PLUGIN "Set to ON to build OSSIM's mrsid plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMNDF_PLUGIN "Set to ON to build OSSIM's ndf plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMOPENCV_PLUGIN "Set to ON to build OSSIM's opencv plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMOPENJPEG_PLUGIN "Set to ON to build OSSIM's openjpeg plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMPDAL_PLUGIN "Set to ON to build OSSIM's pdal plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMPNG_PLUGIN "Set to ON to build OSSIM's png plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMREGISTRATION_PLUGIN "Set to ON to build OSSIM's registration plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMSQLITE_PLUGIN "Set to ON to build OSSIM's sqlite plugin.  Use OFF to skip this plugin." OFF)
OPTION(BUILD_OSSIMWEB_PLUGIN "Set to ON to build OSSIM's web plugin.  Use OFF to skip this plugin." OFF)

find_package(OpenThreads)
find_package(ossim)

IF(OSSIM_INSTALL_PLUGINS_WITH_VERSION)
  SET(INSTALL_RUNTIME_DIR   "${INSTALL_LIBRARY_DIR}/ossim-${OSSIM_VERSION}/plugins")
ELSE()
  SET(INSTALL_RUNTIME_DIR   "${INSTALL_LIBRARY_DIR}/ossim/plugins")
ENDIF()

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${OSSIM_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})

SET(BUILD_OSSIM_FRAMEWORKS "OFF")
SET(OSSIM_PLUGIN_LINK_TYPE "SHARED")

if(BUILD_OSSIM_PLUGIN)
   SUBDIRS(ossim)
ENDIF(BUILD_OSSIM_PLUGIN)

IF(BUILD_OSSIMCONTRIB_PLUGIN)
   MESSAGE(WARNING "BUILD_OSSIMCONTRIB_PLUGIN: We have not created a CMakeList.txt for the contrib plugin yet.")
ENDIF(BUILD_OSSIMCONTRIB_PLUGIN)

if(BUILD_OSSIMCSM_PLUGIN)
   SUBDIRS(csm)
ENDiF(BUILD_OSSIMCSM_PLUGIN)

if(BUILD_OSSIMGDAL_PLUGIN)
   SUBDIRS(gdal)
ENDIF(BUILD_OSSIMGDAL_PLUGIN)

if(BUILD_OSSIMGEOPDF_PLUGIN)
   SUBDIRS(geopdf)
ENDIF(BUILD_OSSIMGEOPDF_PLUGIN)

if(BUILD_OSSIMHDF_PLUGIN)
   SUBDIRS(hdf)
ENDIF(BUILD_OSSIMHDF_PLUGIN)

if(BUILD_OSSIMHDF4_PLUGIN)
   SUBDIRS(hdf4)
ENDIF(BUILD_OSSIMHDF4_PLUGIN)

if(BUILD_OSSIMHDF5_PLUGIN)
   SUBDIRS(hdf5)
ENDIF(BUILD_OSSIMHDF5_PLUGIN)

if(BUILD_OSSIMKAKADU_PLUGIN)
   SUBDIRS(kakadu)
ENDIF(BUILD_OSSIMKAKADU_PLUGIN)

if(BUILD_OSSIMKMLSUPEROVERLAY_PLUGIN)
   SUBDIRS(kmlsuperoverlay)
ENDIF(BUILD_OSSIMKMLSUPEROVERLAY_PLUGIN)

IF(BUILD_OSSIMLAS_PLUGIN)
   SUBDIRS(las)
ENDIF(BUILD_OSSIMLAS_PLUGIN)

IF(BUILD_OSSIMLIBLAS_PLUGIN)
   SUBDIRS(liblas)
ENDIF(BUILD_OSSIMLIBLAS_PLUGIN)

IF(BUILD_OSSIMLIBRAW_PLUGIN)
   SUBDIRS(libraw)
ENDIF(BUILD_OSSIMLIBRAW_PLUGIN)

IF(BUILD_OSSIMMRSID_PLUGIN)
   SUBDIRS(mrsid)  
ENDIF(BUILD_OSSIMMRSID_PLUGIN)

IF(BUILD_OSSIMNDF_PLUGIN)
   SUBDIRS(ndf) 
ENDIF(BUILD_OSSIMNDF_PLUGIN)

IF(BUILD_OSSIMOPENCV_PLUGIN)
   SUBDIRS(opencv)
ENDIF(BUILD_OSSIMOPENCV_PLUGIN)

IF(BUILD_OSSIMOPENJPEG_PLUGIN)
   SUBDIRS(openjpeg) 
ENDIF(BUILD_OSSIMOPENJPEG_PLUGIN)

IF(BUILD_OSSIMPDAL_PLUGIN)
   SUBDIRS(pdal)
ENDIF(BUILD_OSSIMPDAL_PLUGIN)

if(BUILD_OSSIMPNG_PLUGIN)
   SUBDIRS(png)
ENDIF(BUILD_OSSIMPNG_PLUGIN)

if(BUILD_OSSIMREGISTRATION_PLUGIN)
   SUBDIRS(registration)
ENDIF(BUILD_OSSIMREGISTRATION_PLUGIN)

if(BUILD_OSSIMSQLITE_PLUGIN)
   SUBDIRS(sqlite)
ENDIF(BUILD_OSSIMSQLITE_PLUGIN)

if(BUILD_OSSIMWEB_PLUGIN)
   SUBDIRS(web)
ENDIF(BUILD_OSSIMWEB_PLUGIN)

IF(OSSIM_BUILD_ADDITIONAL_PLUGIN_DIRECTORIES)
    FOREACH(it IN LISTS OSSIM_BUILD_ADDITIONAL_PLUGIN_DIRECTORIES)
        SUBDIRS(${it})
    ENDFOREACH(it)
ELSE(OSSIM_BUILD_ADDITIONAL_PLUGIN_DIRECTORIES)
    SET(OSSIM_BUILD_ADDITIONAL_PLUGIN_DIRECTORIES "" CACHE PATH "Specify full paths separated by ; to additional plugins you wish to include into the ossim build framework" FORCE)
ENDIF()

MESSAGE( STATUS "BUILD_OSSIM_PLUGIN                 = ${BUILD_OSSIM_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMCONTRIB_PLUGIN          = ${BUILD_OSSIMCONTRIB_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMCSM_PLUGIN              = ${BUILD_OSSIMCSM_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMGDAL_PLUGIN             = ${BUILD_OSSIMGDAL_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMGEOPDF_PLUGIN           = ${BUILD_OSSIMGEOPDF_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMHDF_PLUGIN              = ${BUILD_OSSIMHDF_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMHDF4_PLUGIN             = ${BUILD_OSSIMHDF4_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMHDF5_PLUGIN             = ${BUILD_OSSIMHDF5_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMKAKADU_PLUGIN           = ${BUILD_OSSIMKAKADU_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMKMLSUPEROVERLAY_PLUGIN  = ${BUILD_OSSIMKMLSUPEROVERLAY_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMLAS_PLUGIN              = ${BUILD_OSSIMLAS_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMLIBLAS_PLUGIN           = ${BUILD_OSSIMLIBLAS_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMLIBRAW_PLUGIN           = ${BUILD_OSSIMLIBRAW_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMMRSID_PLUGIN            = ${BUILD_OSSIMMRSID_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMNDF_PLUGIN              = ${BUILD_OSSIMNDF_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMOPENCV_PLUGIN           = ${BUILD_OSSIMOPENCV_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMOPENJPEG_PLUGIN         = ${BUILD_OSSIMOPENJPEG_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMPDAL_PLUGIN             = ${BUILD_OSSIMPDAL_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMPNG_PLUGIN              = ${BUILD_OSSIMPNG_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMREGISTRATION_PLUGIN     = ${BUILD_OSSIMREGISTRATION_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMSQLITE_PLUGIN           = ${BUILD_OSSIMSQLITE_PLUGIN}" )
MESSAGE( STATUS "BUILD_OSSIMWEB_PLUGIN              = ${BUILD_OSSIMWEB_PLUGIN}" )
MESSAGE( STATUS "OPENTHREADS_LIBRARY                = ${OPENTHREADS_LIBRARY}" )
MESSAGE( STATUS "OPENTHREADS_INCLUDE                = ${OPENTHREADS_INCLUDE_DIR}" )
MESSAGE( STATUS "OSSIM_LIBRARY                      = ${OSSIM_LIBRARY}" )
MESSAGE( STATUS "OSSIM_INCLUDE                      = ${OSSIM_INCLUDE_DIR}" )
MESSAGE( STATUS "OSSIM_INSTALL_PLUGINS_WITH_VERSION = ${OSSIM_INSTALL_PLUGINS_WITH_VERSION}" )

OSSIM_ADD_COMMON_MAKE_UNINSTALL()
