cmake_minimum_required(VERSION 3.24)
project(keep_awake LANGUAGES CXX)
# Plugin-owned sleep prevention: keep-awake loads it through vtour.native
# (plugin.lua). No vtour, Lua or ImGui dependency.
function(keep_awake_configure target)
  target_compile_features(${target} PUBLIC cxx_std_17)
  target_include_directories(${target} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
  if(WIN32)
    target_compile_definitions(${target} PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
  elseif(APPLE)
    target_link_libraries(${target} PRIVATE "-framework IOKit" "-framework CoreFoundation")
  endif()
endfunction()
add_library(vtour_keep_awake SHARED awake.cpp)
keep_awake_configure(vtour_keep_awake)
set_target_properties(vtour_keep_awake PROPERTIES PREFIX "" OUTPUT_NAME "keep-awake"
  CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES)
# Tests call the same C ABI statically.
add_library(vtour_keep_awake_static STATIC awake.cpp)
keep_awake_configure(vtour_keep_awake_static)
target_compile_definitions(vtour_keep_awake_static PUBLIC AWAKE_STATIC)
