# Description: Build configuration for the GeoDMA Gui Components 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(${Qt5_INCLUDE_DIRS})
include_directories(${GEODMA_SRC_DIR})

if(WIN32)
  add_definitions(-DGDMAGUICMPDLL)
endif()

#if(Qt5_FOUND)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#endif()

file(GLOB GEODMA_GUICMP_SRC_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/*.cpp)
file(GLOB GEODMA_GUICMP_HDR_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/*.hpp)

file(GLOB GEODMA_GUICMPDECTR_SRC_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/decision_trees/*.cpp)
file(GLOB GEODMA_GUICMPDECTR_HDR_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/decision_trees/*.hpp)

file(GLOB GEODMA_GUICMPKM_SRC_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/kmeans/*.cpp)
file(GLOB GEODMA_GUICMPKM_HDR_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/kmeans/*.hpp)

file(GLOB GEODMA_GUICMPSA_SRC_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/semanticanalysis/*.cpp)
file(GLOB GEODMA_GUICMPSA_HDR_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/semanticanalysis/*.hpp)
file(GLOB GEODMA_GUICMPSA_UI_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/semanticanalysis/*.ui)

file(GLOB GEODMA_GUICMP_UI_FILES ${GEODMA_SRC_DIR}/geodmalib/guicomponents/ui/*.ui)

if(GEODMA_MOD_SA_ENABLED)
    list(APPEND GEODMA_GUICMP_UI_FILES ${GEODMA_GUICMPSA_UI_FILES})
endif()

# Creating source groups for IDEs
source_group("Source Files"  FILES ${GEODMA_GUICMP_SRC_FILES})
source_group("Header Files"  FILES ${GEODMA_GUICMP_HDR_FILES})
source_group("Source Files\\decision_trees"  FILES ${GEODMA_GUICMPDECTR_SRC_FILES})
source_group("Header Files\\decision_trees"  FILES ${GEODMA_GUICMPDECTR_HDR_FILES})
source_group("Source Files\\kmeans"  FILES ${GEODMA_GUICMPKM_SRC_FILES})
source_group("Header Files\\kmeans"  FILES ${GEODMA_GUICMPKM_HDR_FILES})

if(GEODMA_MOD_SA_ENABLED)
  source_group("Source Files\\semantic_analysis"  FILES ${GEODMA_GUICMPSA_SRC_FILES})
  source_group("Header Files\\semantic_analysis"  FILES ${GEODMA_GUICMPSA_HDR_FILES})
endif()

source_group("UI Files"  FILES ${GEODMA_GUICMP_UI_FILES})

#if(Qt5_FOUND)
# uic'ing
QT5_WRAP_UI(GEODMA_GUICMP_GEN_HDR_FILES ${GEODMA_GUICMP_UI_FILES})
set(GEODMA_FILES ${GEODMA_GUICMP_SRC_FILES} ${GEODMA_GUICMP_HDR_FILES}
                                            ${GEODMA_GUICMPDECTR_SRC_FILES}
                                            ${GEODMA_GUICMPDECTR_HDR_FILES}
                                            ${GEODMA_GUICMPKM_SRC_FILES}
                                            ${GEODMA_GUICMPKM_HDR_FILES}
                                            ${GEODMA_GUICMP_GEN_HDR_FILES}
)

if(GEODMA_MOD_SA_ENABLED)
    list(APPEND GEODMA_FILES ${GEODMA_GUICMPSA_SRC_FILES})
    list(APPEND GEODMA_FILES ${GEODMA_GUICMPSA_HDR_FILES})
endif()

add_library(geodma_mod_guicomponents SHARED ${GEODMA_FILES})

set(GEODMA_GUICOMPONENTS_DEP_LIBS_LIST)
list(APPEND GEODMA_GUICOMPONENTS_DEP_LIBS_LIST geodma_mod_classification
                                               geodma_mod_common
                                               geodma_mod_datamanager
                                               terralib_mod_qt_apf
                                               terralib_mod_qt_widgets
                                               terralib_mod_classification
                                               ${QT_LIBRARIES} )

if(GEODMA_MOD_SA_ENABLED)
  list(APPEND GEODMA_GUICOMPONENTS_DEP_LIBS_LIST geodma_mod_semanticanalysis )
endif()

target_link_libraries(geodma_mod_guicomponents ${GEODMA_GUICOMPONENTS_DEP_LIBS_LIST} )

qt5_use_modules(geodma_mod_guicomponents Widgets)
#endif()

if(GEODMA_SOURCE_VERIFY_ENABLED)
    add_style_check_target(geodma_mod_guicomponents "${GEODMA_GUICMP_SRC_FILES};${GEODMA_GUICMP_HDR_FILES};${GEODMA_GUICMPDECTR_SRC_FILES};${GEODMA_GUICMPDECTR_HDR_FILES};${GEODMA_GUICMPKM_SRC_FILES};${GEODMA_GUICMPKM_HDR_FILES}")
endif()

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

## @TODO SET HERE INSTALL COMMANDS