Skip to content
Open
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
2 changes: 2 additions & 0 deletions src/ros2cs/ros2cs_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ if(UNIX)
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
elseif(APPLE)
set(CSBUILD_TOOL "Mono")
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
Expand Down
8 changes: 4 additions & 4 deletions src/ros2cs/ros2cs_common/DllLoadUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ private static bool IsMacOSX () {
}

private static Platform CheckPlatform () {
if (IsUnix())
if (IsMacOSX())
{
return Platform.Unix;
return Platform.MacOSX;
}
else if (IsMacOSX())
else if (IsUnix())
{
return Platform.MacOSX;
return Platform.Unix;
}
else if (IsWindowsDesktop())
{
Expand Down
30 changes: 21 additions & 9 deletions src/ros2cs/ros2cs_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ if(UNIX)
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
elseif(APPLE)
set(CSBUILD_TOOL "Mono")
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
Expand Down Expand Up @@ -83,7 +85,11 @@ ament_export_libraries(ros2cs_native)
ament_export_targets(ros2cs_native)
configure_csharp_c_extension_library(ros2cs_native)

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
endif()

set(CS_INTERFACES
interfaces/INode.cs
Expand Down Expand Up @@ -282,7 +288,7 @@ if(STANDALONE_BUILD)

macro(install_standalone_dependencies)
# Filter valid libraries
list(FILTER REQ_STANDALONE_LIBS INCLUDE REGEX ".*(lib|dll|so)(\.[0-9])*$")
list(FILTER REQ_STANDALONE_LIBS INCLUDE REGEX ".*(lib|dll|so|dylib)(\.[0-9])*$")
list(REMOVE_DUPLICATES REQ_STANDALONE_LIBS)

if(WIN32)
Expand All @@ -295,6 +301,12 @@ if(STANDALONE_BUILD)
DESTINATION standalone
)
elseif(UNIX)
# handle both mac and unix libraries
set(LIB_EXT "so")
if (APPLE)
set(LIB_EXT "dylib")
endif()

set(_resolvedFiles "")
foreach(lib_path ${REQ_STANDALONE_LIBS})
# Generate soversion files (.so.<major>). Some libs links to soversion symlinks which are not returned by find_package by default.
Expand All @@ -308,15 +320,15 @@ if(STANDALONE_BUILD)

# Fix soversion files
foreach(_resolvedFile ${_resolvedFiles})
if("${_resolvedFile}" MATCHES "so(\.[0-9]*)+$")
if("${_resolvedFile}" MATCHES "${LIB_EXT}(\.[0-9]*)+$")
# message("Soversion file detected ${_resolvedFile}")

# Get file path without so
string(FIND "${_resolvedFile}" ".so." _findPos)
# Get file path without ${LIB_EXT}
string(FIND "${_resolvedFile}" ".${LIB_EXT}." _findPos)
string(SUBSTRING "${_resolvedFile}" 0 ${_findPos} _cutted)

set(_remainingPath "${_resolvedFile}")
while("${_remainingPath}" MATCHES "so(\.[0-9]*)+$")
while("${_remainingPath}" MATCHES "${LIB_EXT}(\.[0-9]*)+$")
string(FIND "${_remainingPath}" "." _lastDotPos REVERSE)
string(SUBSTRING "${_remainingPath}" 0 ${_lastDotPos} _tempPos)
get_filename_component(_libPathFilename "${_tempPos}" NAME)
Expand All @@ -330,15 +342,15 @@ if(STANDALONE_BUILD)

# rpath for each standalone lib must be updated so all the libs will see each other
install(CODE
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/standalone -name *.so -exec patchelf --set-rpath $ORIGIN:. {} \;)"
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/standalone -name *.${LIB_EXT} -exec patchelf --set-rpath $ORIGIN:. {} \;)"
)
# soversion files as well
install(CODE
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/standalone -name *.so.* -exec patchelf --set-rpath $ORIGIN:. {} \;)"
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/standalone -name *.${LIB_EXT}.* -exec patchelf --set-rpath $ORIGIN:. {} \;)"
)
# as well as custom resources
install(CODE
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/resources -name *.so -exec patchelf --set-rpath $ORIGIN:. {} \;)"
"execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/resources -name *.${LIB_EXT} -exec patchelf --set-rpath $ORIGIN:. {} \;)"
)
endif()
endmacro()
Expand Down
2 changes: 2 additions & 0 deletions src/ros2cs/ros2cs_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ if(UNIX)
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
elseif(APPLE)
set(CSBUILD_TOOL "Mono")
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/ros2cs/ros2cs_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if(BUILD_TESTING)
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
elseif(APPLE)
set(CSBUILD_TOOL "Mono")
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/ros2cs/rosidl_generator_cs/cmake/register_cs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ macro(rosidl_generator_cs_extras BIN GENERATOR_FILES TEMPLATE_DIR)
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
elseif(APPLE)
set(CSBUILD_TOOL "Mono")
else()
set(CSBUILD_TOOL "DotNetCore")
endif()
Expand Down