#
# $Id$
# $HeadURL$
# $Author$
#
# Created by Mike Wille, SLSE, 2016-09-19
#

# Make ${Qt6_Gui} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Gui)
  set(Qt6_Gui ${Qt6_Gui})
else()
  set(Qt6_Gui "")
endif()

# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
  set(Qt6_Widgets ${Qt6_Widgets})
else()
  set(Qt6_Widgets "")
endif()


SET(SRCS
  dds_vector_to_pixmap.cpp
  dds_vector_to_pixmap.h
  request_helper.cpp
  request_helper.h
)

NGL_ADD_LIBRARY2(WS SV AAR HLA LtsUtilsGuiDds SHARED ${SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(LtsUtilsGuiDds
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/../
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../
    ${CMAKE_CURRENT_BINARY_DIR}/../
)
if(QT6_GUI_AVAILABLE)
  NGL_TARGET_LINK_LIBRARIES(LtsUtilsGuiDds
    PUBLIC
      LtsUtilsCoreHeaderOnly
      LtsWidgets
      ${Qt6_Gui}
      ${Qt6_Widgets}
      Qt6::Svg
  )
endif()
IF(BUILD_RTI)
  TARGET_LINK_LIBRARIES(LtsUtilsGuiDds PUBLIC ddscore)
ENDIF(BUILD_RTI)
NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds
  PUBLIC
    REQUEST_HELPER_WITH_GUI
)

# The dds_vector_to_pixmap free functions (iconFromSvg / pixmapFromIcon / ...) are
# declared with LTSUTILSCORE_EXPORT, but this TU's include
# <LtsUtils/LtsUtilsCore/ltsutilscore_export.h> resolves to the SOURCE-tree header,
# where the macro expands to Q_DECL_IMPORT (empty on Linux) because
# MAKE_LTSUTILSCORE_LIB is only defined when building LtsUtilsCore itself. Under the
# project-wide -fvisibility=hidden they therefore compile as hidden symbols and, with
# USE_IPO=ON, LTO drops them from the DSO entirely (they are unreferenced inside this
# lib), breaking every consumer that links them (LtsMultiMonitor, LtsSession, ...).
# Legacy exported them because its include <LtsUtilsCore/ltsutilscore_export.h>
# resolved to the GENERATED export header (visibility("default")). Restore that
# default visibility for this target only (same fix shape as the PluginInterfaces
# visibility preset); behavior-neutral.
set_target_properties(LtsUtilsGuiDds PROPERTIES CXX_VISIBILITY_PRESET default)


NGL_ADD_LIBRARY2(AAR HLA  SV LtsUtilsDds SHARED request_helper.cpp request_helper.h)
NGL_TARGET_INCLUDE_DIRECTORIES(LtsUtilsDds
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/../
    ${CMAKE_CURRENT_BINARY_DIR}/../
)
NGL_TARGET_LINK_LIBRARIES(LtsUtilsDds
  PRIVATE
    LtsUtilsCoreHeaderOnly
  PUBLIC
    Qt6::Core
)
IF(BUILD_RTI)
  TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC ddscore)
ENDIF(BUILD_RTI)
