Skip to content

Commit fbb4241

Browse files
facontidavideDavide Faconticlaude
authored
Release 0.2.1: fix Conan cmake_build_modules + namespaced subdir aliases (#91)
* feat(cmake): add namespaced plotjuggler_core:: ALIAS targets Build-tree ALIASes mirror the install-tree EXPORT_NAMEs (base, datastore, plugin_sdk, plugin_host) so consumers can write the same target_link_libraries call against plotjuggler_core::* regardless of whether they pick up plotjuggler_core via add_subdirectory() or via find_package(plotjuggler_core CONFIG REQUIRED). Without these aliases, subdirectory-mode consumers had to use the non-namespaced pj_base / pj_plugin_sdk / pj_plugin_host names while find_package consumers got plotjuggler_core::base / ::plugin_sdk / ::plugin_host. Two ways to express the same link forced every consumer to write a compatibility shim. ALIAS targets are the canonical CMake idiom for this exact build-tree / install-tree parity case (see CMake's importing-exporting guide). Pure addition; no existing target name is removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(conan): aggregate cmake_build_modules at package level Conan 2's CMakeDeps generator only aggregates cmake_build_modules declared at the package level (self.cpp_info), not at component level. The previous declaration on the sdk component was silently dropped: plotjuggler_core_BUILD_MODULES_PATHS_RELEASE ended up empty in the generated <pkg>-release-<arch>-data.cmake, PjPluginManifest.cmake was never include()d after find_package() returned, and consumers that called pj_emit_plugin_manifest() saw "Unknown CMake command". Move the property to self.cpp_info. Documented behavior, per the Conan CMakeDeps reference: "This property cannot be set in the components, only in the root self.cpp_info." Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump version to 0.2.1 Updates conanfile.py recipe version and CMakeLists.txt PJ_PACKAGE_VERSION in lockstep so the Conan-published version and the installed CMake package version stay coherent. The Release workflow validates conanfile.py vs the tag before publishing to cloudsmith and creating the GitHub release. 0.2.1 contents (additive, no breaking changes vs 0.2.0): - fix(conan): cmake_build_modules now properly aggregated at package level — PjPluginManifest.cmake auto-include()s after find_package() so pj_emit_plugin_manifest() works without consumer-side workarounds. - feat(cmake): build-tree plotjuggler_core::* ALIAS targets (base, datastore, plugin_sdk, plugin_host) for subdirectory- mode / find_package consumer parity. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Davide Faconti <dfaconti@aurynrobotics.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent db4dcf1 commit fbb4241

5 files changed

Lines changed: 20 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ endif()
183183
if(PJ_INSTALL_SDK)
184184
include(CMakePackageConfigHelpers)
185185

186-
set(PJ_PACKAGE_VERSION "0.2.0")
186+
set(PJ_PACKAGE_VERSION "0.2.1")
187187
set(PJ_PACKAGE_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/plotjuggler_core)
188188

189189
install(EXPORT plotjuggler_coreTargets

conanfile.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class PlotjugglerCoreConan(ConanFile):
2929
name = "plotjuggler_core"
30-
version = "0.2.0"
30+
version = "0.2.1"
3131
license = "MIT"
3232
url = "https://github.com/PlotJuggler/plotjuggler_core"
3333
description = "C++20 foundation libraries for PlotJuggler: storage engine, plugin SDK, plugin host loaders."
@@ -131,6 +131,16 @@ def package_info(self):
131131
# No top-level umbrella target: the four components have
132132
# mutually-exclusive audiences. Consumers must request a component.
133133

134+
# Conan 2's CMakeDeps only aggregates cmake_build_modules declared at
135+
# the package level (self.cpp_info), not at component level — declaring
136+
# it on the `sdk` component below silently produced an empty
137+
# plotjuggler_core_BUILD_MODULES_PATHS_RELEASE in the generated data
138+
# file. Ship the PjPluginManifest helper from the package root so
139+
# CMakeDeps actually include()s it after find_package() returns.
140+
self.cpp_info.set_property("cmake_build_modules", [
141+
os.path.join("lib", "cmake", "plotjuggler_core", "PjPluginManifest.cmake"),
142+
])
143+
134144
# --- base ---
135145
base = self.cpp_info.components["base"]
136146
base.set_property("cmake_target_name", "plotjuggler_core::base")
@@ -156,11 +166,6 @@ def package_info(self):
156166
sdk.libs = [] # INTERFACE only
157167
sdk.includedirs = ["include"]
158168
sdk.requires = ["base", "nlohmann_json::nlohmann_json"]
159-
# Ship the cmake helper alongside the component. cmake_build_modules
160-
# makes Conan auto-include() it after find_package() succeeds.
161-
sdk.set_property("cmake_build_modules", [
162-
os.path.join("lib", "cmake", "plotjuggler_core", "PjPluginManifest.cmake"),
163-
])
164169

165170
# --- plugin_host (umbrella linking every host-side loader) ---
166171
if self.options.with_host:

pj_base/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ set_target_properties(pj_base PROPERTIES
2828
POSITION_INDEPENDENT_CODE ON
2929
EXPORT_NAME base
3030
)
31+
# Build-tree alias so subdirectory-mode consumers can use the same namespaced
32+
# target name that the install/export tree exposes (and that the Conan package
33+
# emits). Keeps add_subdirectory() and find_package(plotjuggler_core) consumers
34+
# writing identical link declarations.
35+
add_library(plotjuggler_core::base ALIAS pj_base)
3136
if(PJ_ASSERT_THROWS)
3237
target_compile_definitions(pj_base PUBLIC PJ_ASSERT_THROWS)
3338
endif()

pj_datastore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ set_target_properties(pj_datastore PROPERTIES
3333
POSITION_INDEPENDENT_CODE ON
3434
EXPORT_NAME datastore
3535
)
36+
add_library(plotjuggler_core::datastore ALIAS pj_datastore)
3637
if(PJ_ASSERT_THROWS)
3738
target_compile_definitions(pj_datastore PUBLIC PJ_ASSERT_THROWS)
3839
endif()

pj_plugins/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ target_include_directories(pj_plugin_sdk INTERFACE
3232
)
3333
target_link_libraries(pj_plugin_sdk INTERFACE pj_base pj_dialog_sdk)
3434
set_target_properties(pj_plugin_sdk PROPERTIES EXPORT_NAME plugin_sdk)
35+
add_library(plotjuggler_core::plugin_sdk ALIAS pj_plugin_sdk)
3536

3637
# ---------------------------------------------------------------------------
3738
# pj_plugin_catalog — host-side embedded-manifest discovery
@@ -257,6 +258,7 @@ target_link_libraries(pj_plugin_host INTERFACE
257258
pj_plugin_catalog
258259
)
259260
set_target_properties(pj_plugin_host PROPERTIES EXPORT_NAME plugin_host)
261+
add_library(plotjuggler_core::plugin_host ALIAS pj_plugin_host)
260262

261263
if(PJ_BUILD_TESTS)
262264

0 commit comments

Comments
 (0)