# Description: Build configuration for the GeoDMA Common Module
#
#  Author: Raian Vargas Maretto <raian@dpi.inpe.br>
#          Thales Sehn Korting <tkorting@dpi.inpe.br>
#          Emiliano Ferreira Castejon <castejon@dpi.inpe.br>
#

# Includes
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${terralib_INCLUDE_DIRS})
#include_directories(${terralib_DIR})

#Set include directories location
#include_directories(${GEODMA_SRC_DIR}/geodmalib/common)
include_directories(${GEODMA_SRC_DIR})

if(WIN32)
  add_definitions(-DGDMACOMMONDLL)
endif()

# Source and Header files
file(GLOB GEODMA_COMMON_SRCS ${GEODMA_SRC_DIR}/geodmalib/common/*.cpp)
file(GLOB GEODMA_COMMON_HDRS ${GEODMA_SRC_DIR}/geodmalib/common/*.hpp)

# Creating source groups for IDEs
source_group("Source Files"  FILES ${GEODMA_COMMON_SRCS})
source_group("Header Files"  FILES ${GEODMA_COMMON_HDRS})

set(GEODMA_COMMON_LIB_DEPENDENCIES ${Boost_SYSTEM_LIBRARY}
                                   ${Boost_CHRONO_LIBRARY}
                                   terralib_mod_common
                                   terralib_mod_dataaccess
)

add_library(geodma_mod_common SHARED ${GEODMA_COMMON_SRCS} ${GEODMA_COMMON_HDRS})

target_link_libraries(geodma_mod_common ${GEODMA_COMMON_LIB_DEPENDENCIES})

# set_property(TARGET geodma_mod_common PROPERTY DEBUG_POSTFIX _d)

if(GEODMA_SOURCE_VERIFY_ENABLED)
    add_style_check_target(geodma_mod_common "${GEODMA_COMMON_SRCS};${GEODMA_COMMON_HDRS}")
endif()

set_target_properties(geodma_mod_common
                      PROPERTIES VERSION ${GEODMA_VERSION_MAJOR}.${GEODMA_VERSION_MINOR}
                                 SOVERSION ${GEODMA_VERSION_MAJOR}.${GEODMA_VERSION_MINOR})
                                 #INSTALL_NAME_DIR "@executable_path/../lib")

if(NOT GEODMA_TRACK_3RDPARTY_DEPENDENCIES_ENABLED)

  install(TARGETS geodma_mod_common
          EXPORT geodma-targets
          RUNTIME DESTINATION ${GEODMA_DESTINATION_RUNTIME} COMPONENT runtime
          LIBRARY DESTINATION ${GEODMA_DESTINATION_LIBRARY} COMPONENT runtime
          ARCHIVE DESTINATION ${GEODMA_DESTINATION_ARCHIVE} COMPONENT runtime)
endif()

install(FILES ${GEODMA_COMMON_HDRS}
        DESTINATION ${GEODMA_DESTINATION_HEADERS}/geodma/common
        COMPONENT devel)

export(TARGETS geodma_mod_common APPEND FILE ${CMAKE_BINARY_DIR}/geodma-exports.cmake)
