set(GUILIBNAME massgui)

message(\n${BoldGreen}"Now configuring library ${GUILIBNAME}"${ColourReset}\n)

########################################################
# Files
set(${GUILIBNAME}_SRCS
  src/IsotopicDataTableView.cpp
  src/ColorSelector.cpp
  src/IsotopicDataTableViewModel.cpp
  src/IsotopicClusterGeneratorDlg.cpp
  src/IsotopicClusterShaperDlg.cpp
  src/MassPeakShaperConfigDlg.cpp
  src/MassDataClientServerConfigDlg.cpp
  src/MassPeakShaperConfigWidget.cpp
)

set(${GUILIBNAME}_UIS
  src/ui/IsotopicClusterGeneratorDlg.ui
  src/ui/MassPeakShaperConfigDlg.ui
  src/ui/IsotopicClusterShaperDlg.ui
  src/ui/ElementGroupBoxWidget.ui
  src/ui/MassDataClientServerConfigDlg.ui
  src/ui/MassPeakShaperConfigWidget.ui
)

find_package(Qt6 COMPONENTS Widgets Core Gui PrintSupport Svg Xml Sql Concurrent REQUIRED)

qt6_wrap_ui(${GUILIBNAME}_UIS_H ${${GUILIBNAME}_UIS})

qt6_add_resources(${TARGET}_QRC_CPP libmassgui-ressources.qrc)

# Because the header files are in their own directory and not along the source
# files, we need to have them listed explicitely for automoc to work properly
# below.
file(GLOB ${GUILIBNAME}_HEADERS ${CMAKE_CURRENT_LIST_DIR}/includes/lib${GUILIBNAME}/*.hpp)
message(STATUS "Included the header files from ${CMAKE_SOURCE_DIR}/includes/lib${GUILIBNAME}/")
message(STATUS "The header files: ${${GUILIBNAME}_HEADERS}")

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

###############################################################
# Configuration of the binary to be built
###############################################################

# Only now can we add the library, because we have defined the sources.

add_library(${GUILIBNAME} STATIC
  ${${GUILIBNAME}_HEADERS}
  ${${GUILIBNAME}_SRCS}
  ${${GUILIBNAME}_UIS_H}
  ${${TARGET}_QRC_CPP}
  ${PLATFORM_SPECIFIC_SOURCES}
)

include_directories(${CMAKE_CURRENT_LIST_DIR}/includes)
include_directories(${CMAKE_CURRENT_LIST_DIR}/includes/lib${GUILIBNAME})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

target_include_directories(${GUILIBNAME} PUBLIC
  ${CMAKE_CURRENT_LIST_DIR}/includes
  ${CMAKE_CURRENT_LIST_DIR}/includes/lib${GUILIBNAME}
  ${CMAKE_CURRENT_BINARY_DIR})

#message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")

set_target_properties(${GUILIBNAME}
  PROPERTIES OUTPUT_NAME ${GUILIBNAME}
)

add_custom_command(TARGET ${GUILIBNAME}
  POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:${GUILIBNAME}>
  ${CMAKE_CURRENT_LIST_DIR}
)

# Finally actually set the linking dependencies to the library.
target_link_libraries(${GUILIBNAME}
  libmass::nongui
  Qt6::Widgets
  Qt6::Xml
  IsoSpec++::IsoSpec++
)

message("")
message(STATUS "${BoldGreen}Finished configuring of ${GUILIBNAME}.${ColourReset}")
message("")

