# The example programs. Each one is guarded by the adapter it needs, so
# -DPLOT_BUILD_EXAMPLES=ON without -DPLOT_BUILD_GLFW=ON is a no-op rather than a
# configure error.
find_package(Threads REQUIRED)  # the GLFW demo's producer thread

if(TARGET plot::glfw)
  add_executable(plot_glfw_demo glfw_demo.cpp)
  target_link_libraries(plot_glfw_demo PRIVATE plot::glfw Threads::Threads)
  plot_apply_warnings(plot_glfw_demo)
endif()

if(TARGET plot::imgui)
  # The demo owns the window, the ImGui context and the frame loop itself, so it
  # links the toolkit and its backends directly; the adapter is only the widget.
  plot_find_glfw(plot_imgui_demo_glfw_dep)
  add_executable(plot_imgui_demo imgui_demo.cpp)
  target_link_libraries(plot_imgui_demo PRIVATE
    plot::imgui
    imgui
    ${plot_imgui_demo_glfw_dep}
    Threads::Threads)
  plot_apply_warnings(plot_imgui_demo)
endif()

if(TARGET plot::qt6)
  # The demo owns the QApplication, the QMainWindow and the toolbar; the adapter is
  # only the widget, which the window adopts as its central widget. No macro
  # processing is needed here: the demo declares no Qt class of its own.
  add_executable(plot_qt_demo qt_demo.cpp)
  target_link_libraries(plot_qt_demo PRIVATE plot::qt6 Threads::Threads)
  plot_apply_warnings(plot_qt_demo)
endif()
