cmake_minimum_required(VERSION 3.24)
project(EpicTunerLifecycleExample LANGUAGES C CXX)
find_package(EpicTunerSDK 1.0 REQUIRED CONFIG)
add_library(lifecycle MODULE lifecycle.cpp)
target_link_libraries(lifecycle PRIVATE EpicTuner::SDKCpp)
set_target_properties(lifecycle PROPERTIES PREFIX "" CXX_VISIBILITY_PRESET hidden)
add_library(lifecycle-c MODULE lifecycle.c)
target_link_libraries(lifecycle-c PRIVATE EpicTuner::SDK)
set_target_properties(lifecycle-c PROPERTIES PREFIX "" C_STANDARD 11)
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" processor)
if(processor MATCHES "^(arm64|aarch64)$")
    set(ET_ARCH arm64)
elseif(processor MATCHES "^(amd64|x86_64)$")
    set(ET_ARCH x64)
else()
    message(FATAL_ERROR "Unsupported SDK target architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
if(WIN32)
    set(ET_OS windows)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(ET_OS linux)
else()
    message(FATAL_ERROR "This preview targets Windows and Linux; macOS is planned")
endif()
if(WIN32 AND NOT ET_ARCH STREQUAL "x64")
    message(FATAL_ERROR "Windows ARM64 is not an initial SDK target")
endif()
set(ET_PLATFORM "${ET_OS}-${ET_ARCH}")
configure_file(plugin.json.in plugin.json @ONLY)
configure_file(plugin-c.json.in plugin-c.json @ONLY)
find_package(Threads REQUIRED)
add_library(background MODULE background.cpp)
target_link_libraries(background PRIVATE EpicTuner::SDKCpp Threads::Threads)
set_target_properties(background PROPERTIES PREFIX "" CXX_VISIBILITY_PRESET hidden)
configure_file(plugin-background.json.in plugin-background.json @ONLY)
