##*************************************************************************##
##  CUBE        http://www.scalasca.org/                                   ##
##*************************************************************************##
##  Copyright (c) 2024-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.                                                 ##
##*************************************************************************##


if(EMSCRIPTEN)
    set(PLUGIN_TYPE STATIC)
else()
    set(PLUGIN_TYPE SHARED)
endif()

set( PLUGINS
     AdvancedColorMaps
     CubeDiff
     Barplot
     Heatmap
     launch
     CubeMean
     CubeMerge
     Measurement
     MetricEditor
     MetricIdentify
     POPAdvisor
     Scaling
     ScorePConfig
     SourceCodeEditor
     Statistics
     Sunburst
     SystemStatistics
     SystemTopology
     Tau2Cube
     TreeItemMarker
)

if(WEB_SOCKETS)
    message(STATUS "select subset of cube plugins for WebAssembly")
set( PLUGINS
    AdvancedColorMaps
    #CubeDiff
    #Barplot
    #Heatmap
    #launch
    #CubeMean
    #CubeMerge
    #Measurement
    MetricEditor
    MetricIdentify
    POPAdvisor
    #Scaling
    ScorePConfig
    # SourceCodeEditor -> allow to write/read any files? only enable for unix sockets
    Statistics
    #Sunburst
    SystemStatistics
    SystemTopology
    #Tau2Cube
    TreeItemMarker
)
endif()

# add default description
foreach(PLUGIN ${PLUGINS})
    set(${PLUGIN}_DESC "Enable ${PLUGIN} Plugin ")
endforeach()

# add cmake option to enable/disable each plugin and include subdirectory if option is enabled
foreach(PLUGIN ${PLUGINS})
    string(TOUPPER ${PLUGIN} PLUGIN_UPPER)
    option(CUBEGUI_PLUGIN_${PLUGIN_UPPER} "${${PLUGIN}_DESC}" ON)
    if(CUBEGUI_PLUGIN_${PLUGIN_UPPER})
        add_subdirectory(${PLUGIN})
    endif()
endforeach()

# special case: BarPlot and Heatmap depend on GraphWidget-common
if( CUBEGUI_PLUGIN_BARPLOT OR CUBEGUI_PLUGIN_HEATMAP )
     add_subdirectory(Graphwidget-common)
endif()
