cmake_minimum_required(VERSION 3.24) project(plot VERSION 0.1.0 LANGUAGES CXX) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(plot_options) add_library(plot_core src/core/status.cpp src/math/transform.cpp src/data/minmax_pyramid.cpp src/data/series.cpp src/data/array_series.cpp src/data/stream_series.cpp src/gl/loader.cpp src/gl/handle.cpp src/render/shaders.cpp src/render/text.cpp src/render/text_atlas.cpp src/render/embedded_mono_font.cpp src/render/primitives.cpp src/render/buffer.cpp src/render/vertex_array.cpp src/render/program.cpp src/render/renderer.cpp src/plot/ticks.cpp src/plot/axis.cpp src/plot/grid.cpp src/plot/measure.cpp src/plot/plot.cpp src/input/controller.cpp ) add_library(plot::core ALIAS plot_core) # What the target is called in an installed tree. Without this the export set is # namespaced by the target's own name (plot::plot_core), while the build tree -- # and every consumer, and this project's own comments -- says plot::core. set_target_properties(plot_core PROPERTIES EXPORT_NAME core) target_include_directories(plot_core PUBLIC $ $) target_compile_features(plot_core PUBLIC cxx_std_20) target_link_libraries(plot_core PRIVATE ${CMAKE_DL_LIBS}) plot_apply_warnings(plot_core) # Adapters own the surface and translate their host's events; examples link the # adapter they demo. Both are opt-in, so the core library and its tests still build # on a bare toolchain. # # They are added before the test suite on purpose: a test that drives an adapter # needs that adapter's targets to exist, and with both switches on the suite can # then exercise them (see tests/CMakeLists.txt). if(PLOT_BUILD_GLFW) add_subdirectory(adapters/glfw) endif() if(PLOT_BUILD_IMGUI) add_subdirectory(adapters/imgui) endif() if(PLOT_BUILD_QT6) add_subdirectory(adapters/qt6) endif() if(PLOT_BUILD_GTK4) add_subdirectory(adapters/gtk4) endif() if(PLOT_BUILD_EXAMPLES) add_subdirectory(examples) endif() if(PLOT_BUILD_TESTS) # Test-only: counts the pyramid's covering-decomposition entries and its bucket # merges so a test can pin the query's O(log n) cost and the append path's # amortised O(1) cost, neither of which any answer reveals. Off in every # non-test build (see include/plot/data/detail/{cover,merge}_count.hpp). # # PLOT_RING_STATS is the same for the persistent-mapped instance ring: the # properties a frame must hold there -- no slot written twice within a frame, # and one fence wait at most, at the start of the frame -- are invisible in the # pixels, so a test reads counters instead (see # include/plot/render/detail/ring_stats.hpp). # # PLOT_COUNT_MEASURE_RECOMPUTES is the same for the measurement cache: whether # `Plot::measurement()` recomputed or returned a cached result is invisible in # the value it returns, so a test that has to tell a live cache from one frozen # on a stale window counts re-evaluations (see # include/plot/plot/detail/measure_count.hpp). target_compile_definitions(plot_core PRIVATE PLOT_PYRAMID_COUNT_COVERS PLOT_PYRAMID_COUNT_MERGES PLOT_RING_STATS PLOT_COUNT_MEASURE_RECOMPUTES) enable_testing() add_subdirectory(tests) endif() # Install and export. The core always goes in; each adapter joins the set only if # its toolkit can be re-found on a consumer's machine, which the adapter decided # when it was added (plot_record_adapter_export() -- the decisions and the reasons # are in the configure log above). plotConfig.cmake then re-finds exactly those # toolkits before including the targets file the adapters are described in, so # find_package(plot) + target_link_libraries(consumer PRIVATE plot::core) works # from an installed prefix with no -I or -L of the consumer's own. if(PLOT_INSTALL) # The adapters that could be promised to a consumer, in the order they were # added, and the find_dependency() calls that re-create their toolkits there. get_property(PLOT_ADAPTER_EXPORT_TARGETS GLOBAL PROPERTY PLOT_ADAPTER_EXPORT_TARGETS) # Substituted into plotConfig.cmake below (@PLOT_ADAPTER_DEPENDENCIES@). get_property(PLOT_ADAPTER_DEPENDENCIES GLOBAL PROPERTY PLOT_ADAPTER_DEPENDENCIES) include(CMakePackageConfigHelpers) # No INCLUDES DESTINATION here: every target already declares # $ in its own target_include_directories(), and # asking for it twice puts the same directory in the export twice. install(TARGETS plot_core ${PLOT_ADAPTER_EXPORT_TARGETS} EXPORT plotTargets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) install(DIRECTORY include/plot DESTINATION include) install(EXPORT plotTargets NAMESPACE plot:: FILE plotTargets.cmake DESTINATION lib/cmake/plot) configure_package_config_file( cmake/plotConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/plotConfig.cmake" INSTALL_DESTINATION lib/cmake/plot) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/plotConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/plotConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/plotConfigVersion.cmake" DESTINATION lib/cmake/plot) endif()