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
@@ -8,10 +8,36 @@ plot_find_glfw(plot_glfw_dep)
|
||||
|
||||
add_library(plot_glfw STATIC glfw_host.cpp)
|
||||
add_library(plot::glfw ALIAS plot_glfw)
|
||||
# The installed tree names it plot::glfw, like the build tree (see plot_core's).
|
||||
set_target_properties(plot_glfw PROPERTIES EXPORT_NAME glfw)
|
||||
|
||||
# The public include root is `adapters/`, so the header is reached as
|
||||
# <glfw/glfw_host.hpp> -- the toolkit's name first, like every other adapter's.
|
||||
target_include_directories(plot_glfw PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
# The build interface is that root; the install one is the prefix's `include`,
|
||||
# where glfw_host.hpp is installed as <glfw/glfw_host.hpp>, the same spelling.
|
||||
target_include_directories(plot_glfw PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
|
||||
# GLFW stays PRIVATE: the header forward-declares GLFWwindow and includes no GLFW
|
||||
# header, so a consumer of plot::glfw does not inherit the toolkit.
|
||||
target_link_libraries(plot_glfw PUBLIC plot::core PRIVATE ${plot_glfw_dep})
|
||||
plot_apply_warnings(plot_glfw)
|
||||
|
||||
# PLOT_GLFW_DEP is either a target find_package()/pkg-config created or one
|
||||
# FetchContent built. The first two can be promised to a consumer -- the installed
|
||||
# config file re-runs the very same discovery -- but a fetched GLFW cannot: there
|
||||
# is no glfw3Config.cmake on the consumer's machine to find, so exporting this
|
||||
# adapter would hand out a target its link interface cannot satisfy. In that case
|
||||
# the adapter is not installed at all.
|
||||
plot_glfw_dependency_snippet(plot_glfw_dependency)
|
||||
if(PLOT_GLFW_DEP_ORIGIN STREQUAL "FetchContent")
|
||||
plot_record_adapter_export(plot_glfw FALSE
|
||||
"GLFW was fetched with FetchContent, so a consumer's find_package(plot) cannot re-find it" "")
|
||||
else()
|
||||
plot_record_adapter_export(plot_glfw TRUE
|
||||
"GLFW was resolved by ${PLOT_GLFW_DEP_ORIGIN}" "${plot_glfw_dependency}")
|
||||
if(PLOT_INSTALL)
|
||||
install(FILES glfw_host.hpp DESTINATION include/glfw)
|
||||
endif()
|
||||
endif()
|
||||
Reference in new issue
Block a user