Skip to content

Commit cd03e22

Browse files
facontidavideDavide Faconti
andauthored
hide private fmt dependency (#94)
Co-authored-by: Davide Faconti <dfaconti@aurynrobotics.com>
1 parent f86d6ad commit cd03e22

5 files changed

Lines changed: 31 additions & 8 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,21 @@ if(PJ_BUILD_TESTS)
6767
find_package(GTest REQUIRED)
6868
endif()
6969

70+
find_package(fmt REQUIRED)
71+
72+
if(TARGET fmt::fmt-header-only)
73+
set(PJ_FMT_TARGET fmt::fmt-header-only)
74+
elseif(TARGET fmt::fmt)
75+
set(PJ_FMT_TARGET fmt::fmt)
76+
else()
77+
message(FATAL_ERROR "fmt is required, but no fmt::fmt or fmt::fmt-header-only target was found.")
78+
endif()
79+
80+
add_library(pj_internal_fmt INTERFACE)
81+
target_compile_definitions(pj_internal_fmt INTERFACE FMT_HEADER_ONLY=1)
82+
target_link_libraries(pj_internal_fmt INTERFACE ${PJ_FMT_TARGET})
83+
7084
if(PJ_BUILD_DATASTORE)
71-
find_package(fmt REQUIRED)
7285
find_package(tsl-robin-map REQUIRED)
7386
if(PJ_BUILD_TESTS)
7487
find_package(benchmark CONFIG REQUIRED)

cmake/plotjuggler_coreConfig.cmake.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ foreach(_comp ${plotjuggler_core_FIND_COMPONENTS})
1717
set(plotjuggler_core_base_FOUND TRUE)
1818

1919
elseif(_comp STREQUAL "datastore")
20-
find_dependency(fmt)
2120
find_dependency(tsl-robin-map)
2221
find_dependency(nanoarrow)
2322
set(plotjuggler_core_datastore_FOUND TRUE)

conanfile.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class PlotjugglerCoreConan(ConanFile):
5757
"arrow/*:with_snappy": True,
5858
# pj_datastore's Arrow IPC import path needs nanoarrow_ipc + flatcc.
5959
"nanoarrow/*:with_ipc": True,
60+
# fmt is an implementation detail. Compile it header-only so the
61+
# static archives do not export a downstream fmt link dependency.
62+
"fmt/*:header_only": True,
6063
# Boost is pulled in transitively by arrow. without_cobalt avoids a
6164
# known upstream packaging error in recent boost recipes; without_test
6265
# trims unneeded modules.
@@ -84,9 +87,19 @@ def requirements(self):
8487
# nlohmann_json appears in public headers (widget_data, plugin_catalog).
8588
self.requires("nlohmann_json/3.12.0", transitive_headers=True)
8689

90+
# fmt is private and header-only at build time; do not propagate it
91+
# into consumers of this static-library package.
92+
self.requires(
93+
"fmt/12.1.0",
94+
headers=True,
95+
libs=False,
96+
visible=False,
97+
transitive_headers=False,
98+
transitive_libs=False,
99+
)
100+
87101
if self.options.with_datastore:
88-
# fmt + tsl-robin-map are private; nanoarrow is in public headers.
89-
self.requires("fmt/12.1.0")
102+
# tsl-robin-map is header-only; nanoarrow is in public headers.
90103
self.requires("tsl-robin-map/1.4.0", transitive_headers=True)
91104
self.requires("nanoarrow/0.7.0", transitive_headers=True)
92105

@@ -161,7 +174,6 @@ def package_info(self):
161174
ds.includedirs = ["include"]
162175
ds.requires = [
163176
"base",
164-
"fmt::fmt",
165177
"tsl-robin-map::tsl-robin-map",
166178
"nanoarrow::nanoarrow",
167179
]

pj_datastore/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target_link_libraries(pj_datastore
4242
pj_base
4343
PRIVATE
4444
tsl::robin_map
45-
fmt::fmt
45+
$<BUILD_INTERFACE:pj_internal_fmt>
4646
${PJ_NANOARROW_TARGET}
4747
${PJ_NANOARROW_IPC_TARGET}
4848
)

pj_plugins/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
find_package(fmt REQUIRED)
21
find_package(nlohmann_json REQUIRED)
32

43
add_library(pj_plugin_loader_detail STATIC
@@ -57,7 +56,7 @@ target_link_libraries(pj_plugin_catalog
5756
PRIVATE
5857
pj_plugin_loader_detail
5958
pj_dialog_protocol
60-
fmt::fmt
59+
$<BUILD_INTERFACE:pj_internal_fmt>
6160
${CMAKE_DL_LIBS}
6261
nlohmann_json::nlohmann_json
6362
)

0 commit comments

Comments
 (0)