-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add reference to external dlls in cmakelist #95
Comments
i'm using foxy |
Im not that fluent with cmake either, but here are some pointers based on my understanding. Building and referencing libraries in ROS workspaces with CMAKE
The variables are set in the correspoinding find_package(rcldotnet_common REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(rcldotnet REQUIRED)
# generated from ament_cmake_export_assemblies/cmake/template/ament_cmake_export_assemblies.cmake.in
set(_exported_assemblies_dll "${rcldotnet_common_DIR}/../../../lib/rcldotnet_common/dotnet/rcldotnet_common.dll")
# append absolute assemblies to rcldotnet_common_ASSEMBLIES_DLL
# warn about not existing paths
if(NOT "${_exported_assemblies_dll} " STREQUAL " ")
find_package(ament_cmake_core QUIET REQUIRED)
foreach(_exported_assembly_dll ${_exported_assemblies_dll})
if(NOT EXISTS "${_exported_assembly_dll}")
message(WARNING "Package 'rcldotnet_common' exports the DLL assembly '${_exported_assembly_dll}' which doesn't exist")
endif()
normalize_path(_exported_assembly_dll "${_exported_assembly_dll}")
list(APPEND rcldotnet_common_ASSEMBLIES_DLL "${_exported_assembly_dll}")
endforeach()
endif()
set(_exported_assemblies_nuget "")
# append absolute assemblies to rcldotnet_common_ASSEMBLIES_NUGET
# warn about not existing paths
if(NOT "${_exported_assemblies_nuget} " STREQUAL " ")
find_package(ament_cmake_core QUIET REQUIRED)
foreach(_exported_assembly_nuget ${_exported_assemblies_nuget})
if(NOT EXISTS "${_exported_assembly_nuget}")
message(WARNING "Package 'rcldotnet_common' exports the NuGet assembly '${_exported_assembly_nuget}' which doesn't exist")
endif()
normalize_path(_exported_assembly_nuget "${_exported_assembly_nuget}")
list(APPEND rcldotnet_common_ASSEMBLIES_NUGET "${_exported_assembly_nuget}")
endforeach()
endif() This is for consuming dotnet libraries built using Consume dotnet libraries that are built outside of ROS workspacesYou most likely want to include some library of yours that was built outside of a ROS2 workspace. For this you can either include the absolute path in the The better variant would be to include your external dotnet libraries as NuGet packages in the The test for rcldotnet do it like this: https://github.com/ros2-dotnet/ros2_dotnet/blob/master/rcldotnet/CMakeLists.txt#L100-L109 Here would be the cange for the talker example: add_dotnet_executable(rcldotnet_talker
RCLDotnetTalker.cs
INCLUDE_DLLS
${_assemblies_dep_dlls}
INCLUDE_REFERENCES
"Newtonsoft.Json=13.0.3-beta1"
) The NuGet packages don't need to be public, you can use our own private package feed or configure a folder where dotnet restore searches for them. Build inside ROS workspace but using a
|
Thanks for the response and explanation @hoffmann-stefan . I tried the following(absolute reference for a quick try): 'starting >>> sensor_msgs_py CMake Error at /home/ros/ros2_dotnet_ws/install/dotnet_cmake_module/share/dotnet_cmake_module/cmake/Modules/dotnet/UseCSharpProjectBuilder.cmake:41 (list): make: *** [Makefile:250: cmake_check_build_system] Error 1Failed <<< rcldotnet_examples [0.65s, exited with code 2]' |
The dll's need to go into the Something like that: set(_assemblies_dep_dlls
${rcldotnet_common_ASSEMBLIES_DLL}
${rcldotnet_ASSEMBLIES_DLL}
${std_msgs_ASSEMBLIES_DLL}
${rcldotnet_ASSEMBLIES_DLL}
"/home/ros/Projects/hello/Motion.dll"
)
add_dotnet_executable(rcldotnet_talker RCLDotnetTalker.cs INCLUDE_DLLS ${_assemblies_dep_dlls}) Some other tip: |
Hi,
Thanks for providing this project for developers who want to use C# to build ros2 apps. I'm new to cmake and i wanted to add my own library dll to the publisher and listener node. What do i need to add to cmakelists so it finds the dll and its location?
where are these variables set rcldotnet_common_ASSEMBLIES_DLL, i'm assuming these are the locations for cmake to go and find the dlls !?
set(_assemblies_dep_dlls
${rcldotnet_common_ASSEMBLIES_DLL}
${rcldotnet_ASSEMBLIES_DLL}
${std_msgs_ASSEMBLIES_DLL}
${rcldotnet_ASSEMBLIES_DLL}
)
Thanks for your help,
Michael
The text was updated successfully, but these errors were encountered: