# Copyright (c) Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.25 FATAL_ERROR)

project(rocprofiler-systems-causal-example LANGUAGES CXX)

# Support standalone builds
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
    include(${CMAKE_CURRENT_LIST_DIR}/../cmake/standalone-helpers.cmake OPTIONAL)
endif()

set(CMAKE_BUILD_TYPE "Release")
find_package(Threads REQUIRED)
if(NOT TARGET rocprofiler-systems::rocprofiler-systems-causal-api-library)
    find_package(rocprofiler-systems REQUIRED COMPONENTS causal-api)
endif()

add_library(causal-interface-library INTERFACE)
target_compile_options(causal-interface-library INTERFACE -g3 -fno-omit-frame-pointer)
target_link_libraries(
    causal-interface-library
    INTERFACE Threads::Threads pthread ${CMAKE_DL_LIBS}
)

rocprofiler_systems_causal_example_executable(
    "causal-both"
    SOURCES causal.cpp impl.cpp
    LINK_LIBRARIES causal-interface-library
    DEFINITIONS USE_RNG=1 USE_CPU=1
)

rocprofiler_systems_causal_example_executable(
    "causal-rng"
    SOURCES causal.cpp impl.cpp
    LINK_LIBRARIES causal-interface-library
    DEFINITIONS USE_RNG=1 USE_CPU=0
)

rocprofiler_systems_causal_example_executable(
    "causal-cpu"
    SOURCES causal.cpp impl.cpp
    LINK_LIBRARIES causal-interface-library
    DEFINITIONS USE_RNG=0 USE_CPU=1
)
