# SPDX-FileCopyrightText: 2016 Copyright contributors to the cppTango project
#
# SPDX-License-Identifier: LGPL-3.0-or-later

set(SOURCES Attr.cpp
            SpectrumAttr.cpp
            ImageAttr.cpp
            Attribute_properties.cpp
            Attribute.cpp
            AttrValue.cpp
            attribute_utils.cpp
            AttrManip.cpp
            AutoTangoMonitor.cpp
            basiccommand.cpp
            client_addr.cpp
            BlackBoxElt.cpp
            BlackBox.cpp
            AttrProperty.cpp
            MultiClassAttribute.cpp
            Command.cpp
            TemplCommand.cpp
            CoutAppender.cpp
            MultiClassPipe.cpp
            NoSyncModelTangoMonitor.cpp
            PipeProperty.cpp
            DeviceImpl_event.cpp
            DeviceImpl_poll.cpp
            DeviceImpl.cpp
            Device_2Impl.cpp
            Device_3Impl.cpp
            Device_4Impl.cpp
            Device_5Impl.cpp
            Device_6Impl.cpp
            DeviceClass.cpp
            DeviceImpl_logger.cpp
            $<$<BOOL:${TANGO_USE_TELEMETRY}>:${CMAKE_CURRENT_SOURCE_DIR}/DeviceImpl_telemetry.cpp>
            DevIntr.cpp
            DevIntrThread.cpp
            DServer.cpp
            DServerClass.cpp
            DServer_lock.cpp
            DServer_poll.cpp
            DServer_event.cpp
            dservercmds.cpp
            DServerSignal.cpp
            $<$<BOOL:${TANGO_USE_TELEMETRY}>:${CMAKE_CURRENT_SOURCE_DIR}/DServer_telemetry.cpp>
            EncodedAttribute.cpp
            EventSupplier.cpp
            Except.cpp
            FwdAttr.cpp
            FwdAttribute.cpp
            KillThread.cpp
            logcmds.cpp
            Logging.cpp
            LoggerStream.cpp
            MultiAttribute.cpp
            NotifdEventSupplier.cpp
            Pipe.cpp
            pollcmds.cpp
            PollObj.cpp
            PollRing.cpp
            PollThread.cpp
            RootAttRegistry.cpp
            seq_vec.cpp
            SubDevDiag.cpp
            TangoAppender.cpp
            TangoRollingFileAppender.cpp
            $<$<BOOL:${TANGO_USE_TELEMETRY}>:${CMAKE_CURRENT_SOURCE_DIR}/telemetrycmds.cpp>
            templ_inst.cpp
            Util.cpp
            Util_polling.cpp
            Util_shut.cpp
            WAttribute.cpp
            WPipe.cpp
            ZmqEventSupplier.cpp)

if(WIN32)
    set(SOURCES_WIN
        CoutBuf.cpp
        NTEventLogger.cpp
        NTService.cpp
        w32win.cpp)

    list(APPEND SOURCES ${SOURCES_WIN})
endif()

add_library(server_objects OBJECT ${SOURCES})
add_dependencies(server_objects idl_objects common_objects)
set_cflags_and_include(server_objects)

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  set_source_files_properties(
    DeviceClass.cpp
    PROPERTIES
    COMPILE_FLAGS -Wno-stringop-overflow)
endif()

if(WIN32)
    target_compile_definitions(server_objects PRIVATE "${windows_defs}")
else()
    target_compile_options(server_objects PRIVATE -fPIC)
    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
        # Do not define _TANGO_LIB when compiling Tango debug library on Linux
        # in order to keep the same behaviour as in the past:
        # A Linux Tango Device Server using the debug tango lib will display
        # twice "Ready to accept requests" at startup
    else()
        target_compile_definitions(server_objects PRIVATE _TANGO_LIB)
    endif()
endif()

if(NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
  target_precompile_headers(server_objects REUSE_FROM common_objects)
endif()
