cmake_minimum_required(VERSION 3.24)
project(system_monitor LANGUAGES CXX)
# Plugin-owned sampling library: system-monitor loads it through vtour.native
# (library.lua). No vtour, Lua or ImGui dependency.
find_package(Threads REQUIRED)
if(NOT TARGET nlohmann_json::nlohmann_json)
  find_package(nlohmann_json 3 REQUIRED)
endif()
function(system_monitor_configure target)
  target_compile_features(${target} PUBLIC cxx_std_17)
  target_include_directories(${target} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
  target_link_libraries(${target} PRIVATE nlohmann_json::nlohmann_json Threads::Threads ${CMAKE_DL_LIBS})
  if(APPLE)
    target_link_libraries(${target} PRIVATE "-framework IOKit" "-framework CoreFoundation")
  endif()
endfunction()
add_library(vtour_system_monitor SHARED monitor.cpp)
system_monitor_configure(vtour_system_monitor)
set_target_properties(vtour_system_monitor PROPERTIES PREFIX "" OUTPUT_NAME "system-monitor"
  CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES)
# Tests call the same C ABI statically.
add_library(vtour_system_monitor_static STATIC monitor.cpp)
system_monitor_configure(vtour_system_monitor_static)
target_compile_definitions(vtour_system_monitor_static PUBLIC SYSMON_STATIC)
