feat(build): install/export rules, umbrella header, verified consumer
This commit is contained in:
1 parent
377cca8e9b
commit
0972903d27
11 files changed
+333
-7
No files matched your search
+53
-1
@@ -28,8 +28,14 @@ add_library(plot_core
|
||||
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 "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_include_directories(plot_core PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
target_compile_features(plot_core PUBLIC cxx_std_20)
|
||||
target_link_libraries(plot_core PRIVATE ${CMAKE_DL_LIBS})
|
||||
plot_apply_warnings(plot_core)
|
||||
@@ -79,3 +85,49 @@ if(PLOT_BUILD_TESTS)
|
||||
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
|
||||
# $<INSTALL_INTERFACE:include> 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()
|
||||
Reference in new issue
Block a user