File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,11 @@ function(viamcppsdk_add_boost_test SOURCE_FILE_NAME)
1717 COMMAND ${TEST_EXECUTABLE_NAME} --catch_system_error=yes )
1818 endforeach ()
1919endfunction ()
20+
21+ function (viamcppsdk_link_viam_api TARGET_LIBRARY)
22+ if (BUILD_SHARED_LIBS )
23+ target_link_libraries (${TARGET_LIBRARY} ${ARGV1} viam-cpp-sdk::viamapi)
24+ else ()
25+ target_link_libraries (${TARGET_LIBRARY} ${ARGV1} "$<LINK_LIBRARY:WHOLE_ARCHIVE,viam-cpp-sdk::viamapi>" )
26+ endif ()
27+ endfunction ()
Original file line number Diff line number Diff line change @@ -106,9 +106,10 @@ target_include_directories(complex_module_sources
106106)
107107target_link_libraries (complex_module_sources
108108 viam-cpp-sdk::viamsdk
109- viam-cpp-sdk::viamapi
110109)
111110
111+ viamcppsdk_link_viam_api(complex_module_sources)
112+
112113add_executable (complex_module)
113114target_sources (complex_module
114115 PRIVATE
Original file line number Diff line number Diff line change @@ -233,11 +233,7 @@ target_link_directories(viamsdk
233233 "$<INSTALL_INTERFACE:${VIAMCPPSDK_PROTOBUF_LIBRARY_DIRS} >"
234234)
235235
236- if (BUILD_SHARED_LIBS )
237- target_link_libraries (viamsdk PRIVATE viam-cpp-sdk::viamapi)
238- else ()
239- target_link_libraries (viamsdk PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,viam-cpp-sdk::viamapi>" )
240- endif ()
236+ viamcppsdk_link_viam_api(viamsdk PRIVATE )
241237
242238target_link_libraries (viamsdk
243239 PUBLIC ${VIAMCPPSDK_GRPCXX_LIBRARIES}
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ target_link_libraries(viamsdk_test
4949 PUBLIC viam-cpp-sdk::viamapi
5050)
5151
52+ viamcppsdk_link_viam_api(viamsdk_test PUBLIC )
53+
5254viamcppsdk_add_boost_test(test_arm.cpp)
5355viamcppsdk_add_boost_test(test_base.cpp)
5456viamcppsdk_add_boost_test(test_board.cpp)
You can’t perform that action at this time.
0 commit comments