##*************************************************************************##
##  CUBE        http://www.scalasca.org/                                   ##
##*************************************************************************##
##  Copyright (c) 2023-2025                                                ##
##  Forschungszentrum Juelich GmbH, Juelich Supercomputing Centre          ##
##                                                                         ##
##  This software may be modified and distributed under the terms of       ##
##  a BSD-style license.  See the COPYING file in the package base         ##
##  directory for details.                                                 ##
##*************************************************************************##


# === cube_server ====================================
add_executable(cube_server
    ./RequestTask.h
    ./ServerWorker.cpp
    ./ServerWorker.h
    ./ThreadPool.cpp
    ./ThreadPool.h
    ./cube4_server.cpp
)
target_link_libraries(cube_server PRIVATE
    cube-base utils libcube_library_tools
)
install(TARGETS cube_server DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

# === plugins ========================================
if(HAVE_DLOPEN)

target_compile_definitions( cube_server PRIVATE HAVE_DLOPEN ) # dlopen is required to support plugins

# disable file server plugin till cube_server gets an elaborated safety concept
#add_library( fileserver_plugin MODULE
#     ./plugins/FileServerPlugin/FileServerPlugin.h
#     ./plugins/FileServerPlugin/FileServerPlugin.cpp
#)
#target_link_libraries( fileserver_plugin PRIVATE
#    cube-base libcube_library_tools utils
#)
#install(TARGETS fileserver_plugin
#    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/cube-plugins
#)

# POP server plugin
add_library( popserver_plugin MODULE
     ./plugins/POPServerPlugin/POPServerPlugin.h
     ./plugins/POPServerPlugin/POPServerPlugin.cpp
)
target_link_libraries( popserver_plugin PRIVATE
    cube-base libcube_library_tools utils cube_popx_library
)
install(TARGETS popserver_plugin
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/cube-plugins
)

endif()
