set(GLDOZE_GPU_MONITOR_APP_DIR "${CMAKE_BINARY_DIR}/apps/glpowerforge")

add_library(gldoze_glpowerforge MODULE
  gpu_monitor_plugin.cpp
  powerforge_profile_model.cpp
  ../profiler/gpu_optimizer_model.cpp)
target_link_libraries(gldoze_glpowerforge PRIVATE gldoze_sdk Threads::Threads)
set_target_properties(gldoze_glpowerforge PROPERTIES
  LIBRARY_OUTPUT_DIRECTORY "${GLDOZE_GPU_MONITOR_APP_DIR}"
  PREFIX "lib"
  OUTPUT_NAME "gldoze_glpowerforge"
  CXX_VISIBILITY_PRESET hidden
  VISIBILITY_INLINES_HIDDEN YES
)

file(MAKE_DIRECTORY "${GLDOZE_GPU_MONITOR_APP_DIR}")
configure_file(app.json.in "${GLDOZE_GPU_MONITOR_APP_DIR}/app.json" @ONLY)
configure_file("${GLDOZE_REPO_ROOT}/assets/desktop/icons/gpu-monitor.svg"
  "${GLDOZE_GPU_MONITOR_APP_DIR}/icon.svg" COPYONLY)

install(TARGETS gldoze_glpowerforge
	LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/gldoze/apps/glpowerforge"
  COMPONENT GLDozeDesktop)
install(FILES
  "${GLDOZE_GPU_MONITOR_APP_DIR}/app.json"
  "${GLDOZE_GPU_MONITOR_APP_DIR}/icon.svg"
	DESTINATION "${CMAKE_INSTALL_LIBDIR}/gldoze/apps/glpowerforge"
	COMPONENT GLDozeDesktop)

add_executable(powerforge_profile_model_test
  powerforge_profile_model_test.cpp powerforge_profile_model.cpp)
target_link_libraries(powerforge_profile_model_test PRIVATE gldoze_project_options)
add_test(NAME powerforge_profile_model COMMAND powerforge_profile_model_test)

add_executable(glpowerforge_plugin_test glpowerforge_plugin_test.cpp)
target_link_libraries(glpowerforge_plugin_test PRIVATE gldoze_sdk ${CMAKE_DL_LIBS})
add_dependencies(glpowerforge_plugin_test gldoze_glpowerforge)
add_test(NAME glpowerforge_plugin COMMAND glpowerforge_plugin_test
  $<TARGET_FILE:gldoze_glpowerforge>)
