Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ci/library-consumption-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion source/Legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>)
Expand Down Expand Up @@ -110,6 +114,7 @@ install(TARGETS MultiSense
)

install(EXPORT MultiSenseTargets
NAMESPACE MultiSense::
DESTINATION lib/cmake/MultiSense)

write_basic_package_version_file(
Expand Down
11 changes: 11 additions & 0 deletions source/Legacy/MultiSenseConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 6 additions & 1 deletion source/LibMultiSense/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -96,6 +100,7 @@ install(TARGETS MultiSense
)

install(EXPORT MultiSenseTargets
NAMESPACE MultiSense::
DESTINATION lib/cmake/MultiSense)

write_basic_package_version_file(
Expand Down
11 changes: 11 additions & 0 deletions source/LibMultiSense/MultiSenseConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions source/LibMultiSense/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion source/Utilities/Legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include_directories(shared)

find_package(Threads REQUIRED)
list(APPEND MULTISENSE_UTILITY_LIBS
MultiSense
MultiSense::MultiSense
Threads::Threads
)

Expand Down
2 changes: 1 addition & 1 deletion source/Utilities/LibMultiSense/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

find_package(Threads REQUIRED)
list(APPEND MULTISENSE_UTILITY_LIBS
MultiSense
MultiSense::MultiSense
Threads::Threads
${FILESYSTEM_LIBRARY}
)
Expand Down
7 changes: 6 additions & 1 deletion source/Wire/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
11 changes: 11 additions & 0 deletions source/Wire/MultiSenseWireConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion source/Wire/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Loading