##*************************************************************************##
##  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.                                                 ##
##*************************************************************************##


cmake_minimum_required(VERSION 3.16)
project(CubeWriterExamples LANGUAGES C)
find_package(CubeW REQUIRED)
find_package(MPI)

#####################################################################################
# build frontend examples after cubew has been installed
#####################################################################################

set( EXAMPLES
    cubew_example_complex.c
    cubew_example_derived.c
    cubew_example_gpu_metrics.c
    cubew_example_simple.c
    cubew_system_tree_memory_footprint_optimized.c
    cubew_system_tree_memory_footprint_standard.c
)
if(MPI_C_FOUND)
list( APPEND EXAMPLES
    backend/cubew_example_complex.mpi.c
)
endif()

foreach( EXAMPLE_C ${EXAMPLES} )
    get_filename_component( EXAMPLE ${EXAMPLE_C} NAME_WE )

    add_executable(${EXAMPLE} ${EXAMPLE_C})
    target_link_libraries( ${EXAMPLE} PRIVATE cubew  -lm )
endforeach()
