#
#  Copyright (C) 2008-2014 National Institute For Space Research (INPE) - Brazil.
#
#  This file is part of the TerraLib - a Framework for building GIS enabled applications.
#
#  TerraLib is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation, either version 3 of the License,
#  or (at your option) any later version.
#
#  TerraLib 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 Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with TerraLib. See COPYING. If not, write to
#  TerraLib Team at <terralib-team@terralib.org>.
#
#
#  Description: CMake script for the TerraLib Python binding.
#
#  Author: Matheus Cavassan Zaglia <mzaglia@dpi.inpe.br>
#

include(${SWIG_USE_FILE})

set (CMAKE_SWIG_FLAGS "-c++")

include_directories (
  "${TERRALIB_ABSOLUTE_ROOT_DIR}/src"
  "${CMAKE_BINARY_DIR}"
  "${Boost_INCLUDE_DIR}"
  "${PYTHON_INCLUDE_DIRS}"
)
set(CMAKE_SWIG_OUTDIR "${CMAKE_BINARY_DIR}/swig/python/terralib")

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_core
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/Core.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_common
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/Common.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_dataaccess
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/DataAccess.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_datatype
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/DataType.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_geometry
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/Geometry.i)

#TERRALIB_ADD_PYTHON_BINDING(terralib_mod_memory
#  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/Memory.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_raster
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/Raster.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_rp
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/RP.i)

TERRALIB_ADD_PYTHON_BINDING(terralib_mod_srs
  ${TERRALIB_ABSOLUTE_ROOT_DIR}/src/terralib/binding/swig/python/SRS.i)

configure_file(${CMAKE_SOURCE_DIR}/terralib_mod_binding_python/__init__.py.in
               ${CMAKE_SWIG_OUTDIR}/__init__.py @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/terralib_mod_binding_python/setup.py.in
               ${CMAKE_SWIG_OUTDIR}/../setup.py @ONLY)

if(UNIX AND NOT APPLE)
file(GLOB TERRALIB_BINDING_LIBRARIES ${CMAKE_SWIG_OUTDIR}/*.so)
endif()
file(GLOB TERRALIB_BINDING_PY_FILES ${CMAKE_SWIG_OUTDIR}/*.py)

install (FILES ${TERRALIB_BINDING_LIBRARIES}
DESTINATION "${TERRALIB_BASE_DESTINATION_DIR}swig/terralib")

install (FILES ${TERRALIB_BINDING_PY_FILES}
DESTINATION "${TERRALIB_BASE_DESTINATION_DIR}swig/terralib")

install (FILES "${CMAKE_SWIG_OUTDIR}/../setup.py"
DESTINATION "${TERRALIB_BASE_DESTINATION_DIR}swig/")

#install(TARGETS _terralib_mod_binding_python
#        RUNTIME DESTINATION ${TERRALIB_DESTINATION_RUNTIME} COMPONENT runtime
#        LIBRARY DESTINATION ${TERRALIB_DESTINATION_RUNTIME} COMPONENT runtime
#        ARCHIVE DESTINATION ${TERRALIB_DESTINATION_RUNTIME} COMPONENT runtime)
