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

53 lines
1.9 KiB
CMake

# ==============================================================================
# Find implot3d
# ==============================================================================
# Builds ImPlot3D from the bundled sources in deps/implo3d/.
#
# Targets provided:
# implot3d::implot3d - The ImPlot3D library target
#
# Variables set:
# implot3d_FOUND - TRUE if implot3d is available
# implot3d_LIBRARIES - The implot3d library target (implot3d::implot3d)
# implot3d_INCLUDE_DIR - Include directories for implot3d
#
# Configuration (set before find_package):
# IMPLOT3D_BUILD_DEMO - Include demo sources (default: ON)
# ==============================================================================
if (DEFINED _FINDIMPLOT3D_INCLUDED)
return()
endif()
set(_FINDIMPLOT3D_INCLUDED TRUE)
option(IMPLOT3D_BUILD_DEMO "Include ImPlot3D demo sources" ON)
set(_implot3d_source_dir "${CMAKE_CURRENT_LIST_DIR}/implo3d")
if (NOT EXISTS "${_implot3d_source_dir}/implot3d.cpp")
message(FATAL_ERROR "implot3d sources not found at '${_implot3d_source_dir}'")
endif()
if (NOT TARGET imgui::imgui)
message(FATAL_ERROR "implot3d requires imgui::imgui to be available before find_package(implot3d)")
endif()
add_subdirectory("${_implot3d_source_dir}" "${CMAKE_BINARY_DIR}/_deps/implot3d-build" EXCLUDE_FROM_ALL)
if (NOT TARGET implot3d::implot3d)
message(FATAL_ERROR "implot3d: target implot3d::implot3d was not created")
endif()
set(implot3d_FOUND TRUE)
set(implot3d_LIBRARIES implot3d::implot3d)
get_target_property(_implot3d_inc implot3d INTERFACE_INCLUDE_DIRECTORIES)
set(implot3d_INCLUDE_DIR "${_implot3d_inc}")
if (_implot3d_inc AND TARGET implot3d)
set_target_properties(implot3d PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_implot3d_inc}"
)
endif()
set(IMPLOT3D_LICENSE_FILE "${_implot3d_source_dir}/LICENSE" CACHE FILEPATH "Path to ImPlot3D license file")