From 30d1c424628170407a8769f93d060899b16f0455 Mon Sep 17 00:00:00 2001 From: "Ethan J. Musser" Date: Fri, 12 Jun 2026 16:00:36 -0400 Subject: [PATCH 1/4] Export targets in their respective namespaces --- source/Legacy/CMakeLists.txt | 7 ++++++- source/LibMultiSense/CMakeLists.txt | 7 ++++++- source/Wire/CMakeLists.txt | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/Legacy/CMakeLists.txt b/source/Legacy/CMakeLists.txt index 2b93596b..b2c94705 100644 --- a/source/Legacy/CMakeLists.txt +++ b/source/Legacy/CMakeLists.txt @@ -59,7 +59,11 @@ add_library(MultiSense ${MULTISENSE_HEADERS} ${DETAILS_HEADERS} ${DETAILS_SRC}) -target_link_libraries(MultiSense PUBLIC MultiSenseWire) +# Provide a namespaced alias so that in-tree consumers can link against the same +# target name that the installed package exports. +add_library(MultiSense::MultiSense ALIAS MultiSense) + +target_link_libraries(MultiSense PUBLIC MultiSenseWire::MultiSenseWire) target_include_directories(MultiSense PUBLIC $ PUBLIC $) @@ -110,6 +114,7 @@ install(TARGETS MultiSense ) install(EXPORT MultiSenseTargets + NAMESPACE MultiSense:: DESTINATION lib/cmake/MultiSense) write_basic_package_version_file( diff --git a/source/LibMultiSense/CMakeLists.txt b/source/LibMultiSense/CMakeLists.txt index 0119fb73..b1245c9b 100644 --- a/source/LibMultiSense/CMakeLists.txt +++ b/source/LibMultiSense/CMakeLists.txt @@ -31,7 +31,11 @@ else() endif() -target_link_libraries(MultiSense PRIVATE MultiSenseWire) +# Provide a namespaced alias so that in-tree consumers can link against the same +# target name that the installed package exports. +add_library(MultiSense::MultiSense ALIAS MultiSense) + +target_link_libraries(MultiSense PRIVATE MultiSenseWire::MultiSenseWire) if (FILESYSTEM_LIBRARY) target_link_libraries(MultiSense PUBLIC ${FILESYSTEM_LIBRARY}) endif() @@ -96,6 +100,7 @@ install(TARGETS MultiSense ) install(EXPORT MultiSenseTargets + NAMESPACE MultiSense:: DESTINATION lib/cmake/MultiSense) write_basic_package_version_file( diff --git a/source/Wire/CMakeLists.txt b/source/Wire/CMakeLists.txt index d1b3213c..2b9b2ec1 100644 --- a/source/Wire/CMakeLists.txt +++ b/source/Wire/CMakeLists.txt @@ -124,6 +124,10 @@ else() endif() +# Provide a namespaced alias so that in-tree consumers can link against the same +# target name that the installed package exports. +add_library(MultiSenseWire::MultiSenseWire ALIAS MultiSenseWire) + target_compile_definitions(MultiSenseWire PRIVATE MultiSense_EXPORTS=True) if (MULTISENSE_USE_MONOTONIC_CLOCK) target_compile_definitions(MultiSenseWire PRIVATE USE_MONOTONIC_CLOCK=${MULTISENSE_USE_MONOTONIC_CLOCK}) @@ -165,7 +169,8 @@ install(TARGETS MultiSenseWire ) install(EXPORT MultiSenseWireTargets -DESTINATION lib/cmake/MultiSenseWire) + NAMESPACE MultiSenseWire:: + DESTINATION lib/cmake/MultiSenseWire) install(FILES ${WIRE_HEADERS} DESTINATION include/MultiSense/wire) install(FILES ${UTILITY_HEADERS} DESTINATION include/MultiSense/utility) From 8588163c234f3335b1141d48e36c1f7293ebfe84 Mon Sep 17 00:00:00 2001 From: "Ethan J. Musser" Date: Fri, 12 Jun 2026 16:01:17 -0400 Subject: [PATCH 2/4] Add legacy, unnamespaced targets to package config --- source/Legacy/MultiSenseConfig.cmake.in | 11 +++++++++++ source/LibMultiSense/MultiSenseConfig.cmake.in | 11 +++++++++++ source/Wire/MultiSenseWireConfig.cmake.in | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/source/Legacy/MultiSenseConfig.cmake.in b/source/Legacy/MultiSenseConfig.cmake.in index 051ef9e5..84ebcd0a 100644 --- a/source/Legacy/MultiSenseConfig.cmake.in +++ b/source/Legacy/MultiSenseConfig.cmake.in @@ -19,4 +19,15 @@ endif() include("${CMAKE_CURRENT_LIST_DIR}/MultiSenseTargets.cmake") +# The exported target is namespaced as `MultiSense::MultiSense`. Historically, +# this was simply `MultiSense`. For backwards compatibility, recreate the +# legacy `MultiSense` target as an interface that forwards to the current, +# namespaced target. +# TODO: Remove this legacy support in a future, major release. +if (NOT TARGET MultiSense AND TARGET MultiSense::MultiSense) + add_library(MultiSense INTERFACE IMPORTED) + set_target_properties(MultiSense PROPERTIES + INTERFACE_LINK_LIBRARIES MultiSense::MultiSense) +endif() + check_required_components(MultiSense) diff --git a/source/LibMultiSense/MultiSenseConfig.cmake.in b/source/LibMultiSense/MultiSenseConfig.cmake.in index d845c6f6..ee910a79 100644 --- a/source/LibMultiSense/MultiSenseConfig.cmake.in +++ b/source/LibMultiSense/MultiSenseConfig.cmake.in @@ -29,4 +29,15 @@ endif() include("${CMAKE_CURRENT_LIST_DIR}/MultiSenseTargets.cmake") +# The exported target is namespaced as `MultiSense::MultiSense`. Historically, +# this was simply `MultiSense`. For backwards compatibility, recreate the +# legacy `MultiSense` target as an interface that forwards to the current, +# namespaced target. +# TODO: Remove this legacy support in a future, major release. +if (NOT TARGET MultiSense AND TARGET MultiSense::MultiSense) + add_library(MultiSense INTERFACE IMPORTED) + set_target_properties(MultiSense PROPERTIES + INTERFACE_LINK_LIBRARIES MultiSense::MultiSense) +endif() + check_required_components(MultiSense) diff --git a/source/Wire/MultiSenseWireConfig.cmake.in b/source/Wire/MultiSenseWireConfig.cmake.in index b36a027b..d95f6626 100644 --- a/source/Wire/MultiSenseWireConfig.cmake.in +++ b/source/Wire/MultiSenseWireConfig.cmake.in @@ -2,4 +2,15 @@ include("${CMAKE_CURRENT_LIST_DIR}/MultiSenseWireTargets.cmake") +# The exported target is namespaced as `MultiSenseWire::MultiSenseWire`. +# Historically, this was simply `MultiSenseWire`. For backwards compatibility, +# recreate the legacy `MultiSenseWire` target as an interface that forwards to +# the current, namespaced target. +# TODO: Remove this legacy support in a future, major release. +if (NOT TARGET MultiSenseWire AND TARGET MultiSenseWire::MultiSenseWire) + add_library(MultiSenseWire INTERFACE IMPORTED) + set_target_properties(MultiSenseWire PROPERTIES + INTERFACE_LINK_LIBRARIES MultiSenseWire::MultiSenseWire) +endif() + check_required_components(MultiSenseWire) From 88a489c5e755e877525d48638eaca4ecde44f5a5 Mon Sep 17 00:00:00 2001 From: "Ethan J. Musser" Date: Fri, 12 Jun 2026 16:01:48 -0400 Subject: [PATCH 3/4] Document CI consumption uses both targets --- ci/library-consumption-test/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/library-consumption-test/CMakeLists.txt b/ci/library-consumption-test/CMakeLists.txt index 62f5ae24..a0e4f778 100644 --- a/ci/library-consumption-test/CMakeLists.txt +++ b/ci/library-consumption-test/CMakeLists.txt @@ -47,6 +47,12 @@ if (CONSUME_OPENCV) endif() add_executable(multisense_consumption_test main.cc) + +# Link against the legacy `MultiSense` target rather than the modern, namespaced +# `MultiSense::MultiSense` target. The package configuration will forward the +# legacy target to the namespaced target, thus evaluating both paths in a single +# test. +# TODO: Remove this when the legacy `MultiSense` target is removed. target_link_libraries(multisense_consumption_test PRIVATE MultiSense) if (CONSUME_JSON_SERIALIZATION) From 77b3525fb123d3c978086ac3467dacc51061862d Mon Sep 17 00:00:00 2001 From: "Ethan J. Musser" Date: Fri, 12 Jun 2026 16:02:09 -0400 Subject: [PATCH 4/4] Update library links to use namespaced targets --- python/CMakeLists.txt | 2 +- source/LibMultiSense/test/CMakeLists.txt | 4 ++-- source/Utilities/Legacy/CMakeLists.txt | 2 +- source/Utilities/LibMultiSense/CMakeLists.txt | 2 +- source/Wire/test/CMakeLists.txt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index bcadfb2b..b3efb415 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,7 +8,7 @@ pybind11_add_module(_libmultisense MODULE bindings.cc) target_link_libraries( _libmultisense PRIVATE - MultiSense + MultiSense::MultiSense ${FILESYSTEM_LIBRARY}) if (BUILD_JSON_SERIALIZATION) diff --git a/source/LibMultiSense/test/CMakeLists.txt b/source/LibMultiSense/test/CMakeLists.txt index 78a59fb7..c793c559 100644 --- a/source/LibMultiSense/test/CMakeLists.txt +++ b/source/LibMultiSense/test/CMakeLists.txt @@ -14,8 +14,8 @@ set(TEST_NAMES foreach(TEST_NAME ${TEST_NAMES}) add_executable(${TEST_NAME} ${TEST_NAME}.cc) - target_link_libraries(${TEST_NAME} PRIVATE MultiSense - MultiSenseWire + target_link_libraries(${TEST_NAME} PRIVATE MultiSense::MultiSense + MultiSenseWire::MultiSenseWire GTest::GTest GTest::Main) add_test(${TEST_NAME} ${TEST_NAME}) diff --git a/source/Utilities/Legacy/CMakeLists.txt b/source/Utilities/Legacy/CMakeLists.txt index 8ff29b02..01b5f1b8 100644 --- a/source/Utilities/Legacy/CMakeLists.txt +++ b/source/Utilities/Legacy/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories(shared) find_package(Threads REQUIRED) list(APPEND MULTISENSE_UTILITY_LIBS - MultiSense + MultiSense::MultiSense Threads::Threads ) diff --git a/source/Utilities/LibMultiSense/CMakeLists.txt b/source/Utilities/LibMultiSense/CMakeLists.txt index 7a8e52c4..046997e7 100644 --- a/source/Utilities/LibMultiSense/CMakeLists.txt +++ b/source/Utilities/LibMultiSense/CMakeLists.txt @@ -1,7 +1,7 @@ find_package(Threads REQUIRED) list(APPEND MULTISENSE_UTILITY_LIBS - MultiSense + MultiSense::MultiSense Threads::Threads ${FILESYSTEM_LIBRARY} ) diff --git a/source/Wire/test/CMakeLists.txt b/source/Wire/test/CMakeLists.txt index 3f2ca8ff..4d962dfa 100644 --- a/source/Wire/test/CMakeLists.txt +++ b/source/Wire/test/CMakeLists.txt @@ -5,7 +5,7 @@ set(TEST_NAMES foreach(TEST_NAME ${TEST_NAMES}) add_executable(${TEST_NAME} ${TEST_NAME}.cc) - target_link_libraries(${TEST_NAME} PRIVATE MultiSenseWire + target_link_libraries(${TEST_NAME} PRIVATE MultiSenseWire::MultiSenseWire GTest::GTest GTest::Main) add_test(${TEST_NAME} ${TEST_NAME})