Skip to content

Commit a5f25ce

Browse files
authored
Handle multiple jsoncpp includes (#147)
Signed-off-by: audrow <[email protected]>
1 parent 2d64514 commit a5f25ce

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ros2_ouster/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ find_package(tf2_ros REQUIRED)
2121
find_package(pcl_conversions REQUIRED)
2222
find_package(ouster_msgs REQUIRED)
2323
find_package(PCL REQUIRED COMPONENTS common)
24-
find_package(jsoncpp REQUIRED)
24+
# Workaround for upstream JsonCpp bug:
25+
# https://github.com/open-source-parsers/jsoncpp/issues/1356
26+
# This checks if the JsonCpp::JsonCpp target already exists before
27+
# trying to find the jsoncpp package again. This prevents the
28+
# "cannot create imported target" CMake error when multiple
29+
# dependencies try to find jsoncpp.
30+
if(NOT TARGET JsonCpp::JsonCpp)
31+
find_package(jsoncpp REQUIRED)
32+
endif()
2533

2634
include_directories(
2735
include
@@ -67,7 +75,7 @@ ament_target_dependencies(${library_name}
6775
)
6876

6977
target_link_libraries(${library_name}
70-
jsoncpp_lib
78+
JsonCpp::JsonCpp
7179
tins
7280
${PCL_LIBRARIES}
7381
)

0 commit comments

Comments
 (0)