Skip to content

Commit

Permalink
Find Choreonoid with CMake
Browse files Browse the repository at this point in the history
This is more reliable as Choreonoid version are getting updated
  • Loading branch information
gergondet committed Sep 6, 2023
1 parent 56f1fed commit dc57984
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

# choreonoid
find_package(PkgConfig)
pkg_check_modules(CNOID REQUIRED choreonoid IMPORTED_TARGET)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir choreonoid
OUTPUT_VARIABLE CNOID_PLUGIN_SUBDIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=sharedir choreonoid
OUTPUT_VARIABLE CNOID_SHARE_SUBDIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
find_package(choreonoid REQUIRED)
set(CNOID_PLUGIN_SUBDIR "${CHOREONOID_PLUGIN_DIR}")
set(CNOID_SHARE_SUBDIR "${CHOREONOID_SHARE_DIR}")

if(DEFINED CATKIN_DEVEL_PREFIX)
catkin_package(
Expand All @@ -54,6 +49,7 @@ if(DEFINED CATKIN_DEVEL_PREFIX)
target_include_directories(ROSDependencies INTERFACE ${catkin_INCLUDE_DIRS})
target_link_libraries(ROSDependencies INTERFACE ${catkin_LIBRARIES})
else()
find_package(PkgConfig)
add_library(ROSDependencies INTERFACE)
function(add_ros_dependency NAME)
pkg_check_modules(${NAME} REQUIRED ${NAME} IMPORTED_TARGET)
Expand Down
4 changes: 1 addition & 3 deletions plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
link_directories(${CNOID_LIBRARY_DIRS})

add_library(CnoidRosUtilsPlugin
SHARED
Plugin.cpp
ClockPublisherItem.cpp
PosePublisherItem.cpp
)
target_link_libraries(CnoidRosUtilsPlugin PUBLIC ROSDependencies PkgConfig::CNOID CnoidBodyPlugin)
target_link_libraries(CnoidRosUtilsPlugin PUBLIC ROSDependencies Choreonoid::CnoidBodyPlugin)

if(DEFINED CATKIN_DEVEL_PREFIX)
set(CNOID_PLUGIN_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/plugin/lib)
Expand Down

0 comments on commit dc57984

Please sign in to comment.