Files
cppcourse/deps/Findimplot.cmake
T
2026-10-04 22:48:25 +02:00

53 lines
1.8 KiB
CMake

# ==============================================================================
# Find implot
# ==============================================================================
# Builds ImPlot from the bundled sources in deps/implot/.
#
# Targets provided:
# implot::implot - The ImPlot library target
#
# Variables set:
# implot_FOUND - TRUE if implot is available
# implot_LIBRARIES - The implot library target (implot::implot)
# implot_INCLUDE_DIR - Include directories for implot
#
# Configuration (set before find_package):
# IMPLOT_BUILD_DEMO - Include demo sources (default: ON)
# ==============================================================================
if (DEFINED _FINDIMPLOT_INCLUDED)
return()
endif()
set(_FINDIMPLOT_INCLUDED TRUE)
option(IMPLOT_BUILD_DEMO "Include ImPlot demo sources" ON)
set(_implot_source_dir "${CMAKE_CURRENT_LIST_DIR}/implot")
if (NOT EXISTS "${_implot_source_dir}/implot.cpp")
message(FATAL_ERROR "implot sources not found at '${_implot_source_dir}'")
endif()
if (NOT TARGET imgui::imgui)
message(FATAL_ERROR "implot requires imgui::imgui to be available before find_package(implot)")
endif()
add_subdirectory("${_implot_source_dir}" "${CMAKE_BINARY_DIR}/_deps/implot-build" EXCLUDE_FROM_ALL)
if (NOT TARGET implot::implot)
message(FATAL_ERROR "implot: target implot::implot was not created")
endif()
set(implot_FOUND TRUE)
set(implot_LIBRARIES implot::implot)
get_target_property(_implot_inc implot INTERFACE_INCLUDE_DIRECTORIES)
set(implot_INCLUDE_DIR "${_implot_inc}")
if (_implot_inc AND TARGET implot)
set_target_properties(implot PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_implot_inc}"
)
endif()
set(IMPLOT_LICENSE_FILE "${_implot_source_dir}/LICENSE" CACHE FILEPATH "Path to ImPlot license file")