Skip to content

Commit

Permalink
fixed library issue
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Kucheria <kucheria@usc.edu>
  • Loading branch information
skucheria committed Jul 23, 2019
1 parent 793675d commit b257a8d
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions rclcpp_components/cmake/rclcpp_components_register_node.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
#
# usage: rclcpp_components_register_node(
# <target> PLUGIN <component> EXECUTABLE <node>)
# <target> PLUGIN <component> EXECUTABLE <node>)
#
# Register an rclcpp component with the ament
# resource index and create an executable.
Expand All @@ -26,39 +26,22 @@
# :type EXECUTABLE: string
#
macro(rclcpp_components_register_node target)
cmake_parse_arguments(
ARGS
""
"PLUGIN;EXECUTABLE"
""
${ARGN})
cmake_parse_arguments(ARGS "" "PLUGIN;EXECUTABLE" "" ${ARGN})
set(component ${ARGS_PLUGIN})
set(node ${ARGS_EXECUTABLE})
_rclcpp_components_register_package_hook()
set(_path "lib")
set(_path "lib")
set(library_name "$<TARGET_FILE_NAME:${target}>")
if(WIN32)
set(_path "bin")
set(library_name ${target}.dll)
elseif(APPLE)
set(library_name lib${target}.dylib)
else()
set(library_name lib${target}.so)
endif()
set(_RCLCPP_COMPONENTS__NODES
"${_RCLCPP_COMPONENTS__NODES}${component};${_path}/$<TARGET_FILE_NAME:${target}>\n")
configure_file(${rclcpp_components_NODE_TEMPLATE}
${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp @ONLY)
${PROJECT_BINARY_DIR}/node_main_configured.cpp.in)
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp
INPUT ${PROJECT_BINARY_DIR}/node_main_configured.cpp.in)
add_executable(${node} ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp)
set(lib ${target})
# Needed so symbols aren't dropped if not used
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(lib
"-Wl,--no-as-needed"
${target}
"-Wl,--as-needed")
endif()
target_link_libraries(${node}
${lib})
ament_target_dependencies(${node}
"rclcpp"
"class_loader"
Expand Down

0 comments on commit b257a8d

Please sign in to comment.