From 475e99b1074cd620ab99a21f1bc997fe714c551f Mon Sep 17 00:00:00 2001 From: John Wason Date: Fri, 29 Nov 2024 20:07:37 -0500 Subject: [PATCH] Fix library anchors on Windows --- tesseract_python/CMakeLists.txt | 45 +++++++++++++++++-- .../swig/tesseract_collision_python.i | 4 +- .../swig/tesseract_kinematics_python.i | 10 ++--- .../swig/tesseract_task_composer_python.i | 13 +++--- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/tesseract_python/CMakeLists.txt b/tesseract_python/CMakeLists.txt index ab959e3e..d2e50011 100644 --- a/tesseract_python/CMakeLists.txt +++ b/tesseract_python/CMakeLists.txt @@ -130,16 +130,55 @@ include(FindSWIG) find_package(SWIG 4.1.1 REQUIRED) include(UseSWIG) +macro(tesseract_python_find_target lib_name search_target) + # Find install directory of search_target + + get_target_property(search_target_location ${search_target} LOCATION) + if (NOT WIN32) + get_filename_component(search_target_location_dir ${search_target_location} DIRECTORY) + else() + get_filename_component(search_target_location_dir1 ${search_target_location} DIRECTORY) + get_filename_component(search_target_location_dir2 ${search_target_location_dir1} DIRECTORY) + set(search_target_location_dir "${search_target_location_dir2}/lib") + endif() + # Find library lib_name + unset(lib_name_location) + find_library(lib_name_location ${lib_name} HINTS ${search_target_location_dir} NO_CACHE) + if (NOT lib_name_location) + message(FATAL_ERROR "Could not find library ${lib_name}") + endif() + # Create import target + add_library(tesseract::${lib_name} SHARED IMPORTED) + if (WIN32) + set_target_properties(tesseract::${lib_name} PROPERTIES IMPORTED_IMPLIB_RELWITHDEBINFO ${lib_name_location}) + set_target_properties(tesseract::${lib_name} PROPERTIES IMPORTED_IMPLIB ${lib_name_location}) + set_target_properties(tesseract::${lib_name} PROPERTIES IMPORTED_LOCATION ${lib_name_location}) + else() + set_target_properties(tesseract::${lib_name} PROPERTIES IMPORTED_LOCATION ${lib_name_location}) + endif() +endmacro() + +tesseract_python_find_target(tesseract_collision_fcl_factories tesseract::tesseract_collision_core) +tesseract_python_find_target(tesseract_collision_bullet_factories tesseract::tesseract_collision_core) +tesseract_python_find_target(tesseract_kinematics_kdl_factories tesseract::tesseract_kinematics_core) +tesseract_python_find_target(tesseract_kinematics_ur_factory tesseract::tesseract_kinematics_core) +tesseract_python_find_target(tesseract_kinematics_opw_factory tesseract::tesseract_kinematics_core) +#tesseract_python_find_target(tesseract_kinematics_core_factories tesseract::tesseract_kinematics_core) +tesseract_python_find_target(tesseract_task_composer_factories tesseract::tesseract_task_composer) +tesseract_python_find_target(tesseract_task_composer_planning_factories tesseract::tesseract_task_composer) +# tesseract_python_find_target(tesseract_task_composer_planning_nodes tesseract::tesseract_task_composer) +tesseract_python_find_target(tesseract_task_composer_taskflow_factories tesseract::tesseract_task_composer) + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/tesseract_python_module.cmake) tesseract_python_module(tesseract_common_python SWIG_SRCS swig/tesseract_common_python.i PACKAGE tesseract_common LIBS tesseract::tesseract_common ) tesseract_python_module(tesseract_geometry_python SWIG_SRCS swig/tesseract_geometry_python.i PACKAGE tesseract_geometry LIBS tesseract::tesseract_geometry ) -tesseract_python_module(tesseract_collision_python SWIG_SRCS swig/tesseract_collision_python.i PACKAGE tesseract_collision LIBS tesseract::tesseract_collision_core Bullet3::Bullet ) # tesseract::tesseract_collision_bullet_factories tesseract::tesseract_collision_fcl_factories ) +tesseract_python_module(tesseract_collision_python SWIG_SRCS swig/tesseract_collision_python.i PACKAGE tesseract_collision LIBS tesseract::tesseract_collision_core Bullet3::Bullet tesseract::tesseract_collision_bullet_factories tesseract::tesseract_collision_fcl_factories ) tesseract_python_module(tesseract_scene_graph_python SWIG_SRCS swig/tesseract_scene_graph_python.i PACKAGE tesseract_scene_graph LIBS tesseract::tesseract_scene_graph ) tesseract_python_module(tesseract_srdf_python SWIG_SRCS swig/tesseract_srdf_python.i PACKAGE tesseract_srdf LIBS tesseract::tesseract_srdf ) tesseract_python_module(tesseract_urdf_python SWIG_SRCS swig/tesseract_urdf_python.i PACKAGE tesseract_urdf LIBS tesseract::tesseract_urdf ) tesseract_python_module(tesseract_state_solver_python SWIG_SRCS swig/tesseract_state_solver_python.i PACKAGE tesseract_state_solver LIBS tesseract::tesseract_state_solver_core tesseract::tesseract_state_solver_ofkt tesseract::tesseract_state_solver_kdl) -tesseract_python_module(tesseract_kinematics_python SWIG_SRCS swig/tesseract_kinematics_python.i PACKAGE tesseract_kinematics LIBS tesseract::tesseract_kinematics_core )# tesseract::tesseract_kinematics_kdl_factories tesseract::tesseract_kinematics_ur_factory tesseract::tesseract_kinematics_opw_factory tesseract::tesseract_kinematics_core_factories ) +tesseract_python_module(tesseract_kinematics_python SWIG_SRCS swig/tesseract_kinematics_python.i PACKAGE tesseract_kinematics LIBS tesseract::tesseract_kinematics_core tesseract::tesseract_kinematics_kdl_factories tesseract::tesseract_kinematics_ur_factory tesseract::tesseract_kinematics_opw_factory tesseract::tesseract_kinematics_core_factories ) tesseract_python_module(tesseract_environment_python SWIG_SRCS swig/tesseract_environment_python.i PACKAGE tesseract_environment LIBS tesseract::tesseract_environment ) tesseract_python_module(tesseract_visualization_python SWIG_SRCS swig/tesseract_visualization_python.i PACKAGE tesseract_visualization LIBS tesseract::tesseract_visualization) tesseract_python_module(tesseract_command_language_python SWIG_SRCS swig/tesseract_command_language_python.i PACKAGE tesseract_command_language LIBS tesseract::tesseract_command_language) @@ -149,7 +188,7 @@ tesseract_python_module(tesseract_motion_planners_trajopt_python SWIG_SRCS swig/ tesseract_python_module(tesseract_motion_planners_ompl_python SWIG_SRCS swig/tesseract_motion_planners_ompl_python.i PACKAGE tesseract_motion_planners_ompl LIBS tesseract::tesseract_motion_planners_ompl ) tesseract_python_module(tesseract_motion_planners_descartes_python SWIG_SRCS swig/tesseract_motion_planners_descartes_python.i PACKAGE tesseract_motion_planners_descartes LIBS tesseract::tesseract_motion_planners_descartes ) tesseract_python_module(tesseract_time_parameterization_python SWIG_SRCS swig/tesseract_time_parameterization_python.i PACKAGE tesseract_time_parameterization LIBS tesseract::tesseract_time_parameterization_core tesseract::tesseract_time_parameterization_isp tesseract::tesseract_time_parameterization_totg tesseract::tesseract_time_parameterization_ruckig) -tesseract_python_module(tesseract_task_composer_python SWIG_SRCS swig/tesseract_task_composer_python.i PACKAGE tesseract_task_composer LIBS tesseract::tesseract_task_composer tesseract::tesseract_task_composer_nodes tesseract::tesseract_task_composer_taskflow tesseract::tesseract_collision_core ) # tesseract::tesseract_task_composer_factories tesseract::tesseract_task_composer_planning_factories tesseract::tesseract_task_composer_planning tesseract::tesseract_task_composer_taskflow_factories ) +tesseract_python_module(tesseract_task_composer_python SWIG_SRCS swig/tesseract_task_composer_python.i PACKAGE tesseract_task_composer LIBS tesseract::tesseract_task_composer tesseract::tesseract_task_composer_nodes tesseract::tesseract_task_composer_taskflow tesseract::tesseract_collision_core tesseract::tesseract_task_composer_factories tesseract::tesseract_task_composer_planning_factories tesseract::tesseract_task_composer_planning_nodes tesseract::tesseract_task_composer_taskflow_factories ) set(TESSERACT_PYTHON_MODULE_TARGETS _tesseract_common_python diff --git a/tesseract_python/swig/tesseract_collision_python.i b/tesseract_python/swig/tesseract_collision_python.i index 05142cdd..5f468fdd 100644 --- a/tesseract_python/swig/tesseract_collision_python.i +++ b/tesseract_python/swig/tesseract_collision_python.i @@ -102,6 +102,6 @@ class ContactResult; %init %{ // TODO: fix anchors -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_collision::tesseract_collision_bullet::BulletFactoriesAnchor(), "TESSERACT_CONTACT_MANAGERS_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_collision::tesseract_collision_fcl::FCLFactoriesAnchor(), "TESSERACT_CONTACT_MANAGERS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_collision::tesseract_collision_bullet::BulletFactoriesAnchor(), "TESSERACT_CONTACT_MANAGERS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_collision::tesseract_collision_fcl::FCLFactoriesAnchor(), "TESSERACT_CONTACT_MANAGERS_PLUGINS"); %} diff --git a/tesseract_python/swig/tesseract_kinematics_python.i b/tesseract_python/swig/tesseract_kinematics_python.i index 98d5be48..ad0a7e38 100644 --- a/tesseract_python/swig/tesseract_kinematics_python.i +++ b/tesseract_python/swig/tesseract_kinematics_python.i @@ -132,11 +132,11 @@ struct KinGroupIKInput; %init %{ // TODO: fix anchors -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::REPInvKinFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::ROPInvKinFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::KDLFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::OPWFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::URFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::REPInvKinFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::ROPInvKinFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::KDLFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::OPWFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_kinematics::URFactoriesAnchor(), "TESSERACT_KINEMATICS_PLUGINS"); diff --git a/tesseract_python/swig/tesseract_task_composer_python.i b/tesseract_python/swig/tesseract_task_composer_python.i index 1f759984..2f162ad2 100644 --- a/tesseract_python/swig/tesseract_task_composer_python.i +++ b/tesseract_python/swig/tesseract_task_composer_python.i @@ -299,10 +299,9 @@ enum class future_status { %arg(env, profiles, name));*/ // contact_check_profile -// TODO: Fix library linking -// %shared_ptr(tesseract_planning::ContactCheckProfile) -// %include "tesseract_task_composer/planning/profiles/contact_check_profile.h" -// %tesseract_command_language_add_profile_type(ContactCheckProfile); +%shared_ptr(tesseract_planning::ContactCheckProfile) +%include "tesseract_task_composer/planning/profiles/contact_check_profile.h" +%tesseract_command_language_add_profile_type(ContactCheckProfile); // fix_state_bounds_profile %shared_ptr(tesseract_planning::FixStateBoundsProfile) @@ -348,9 +347,9 @@ enum class future_status { %init %{ // TODO: fix anchors -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_planning::TaskComposerPlanningFactoriesAnchor(), "TESSERACT_TASK_COMPOSER_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_planning::TaskComposerTaskflowFactoriesAnchor(), "TESSERACT_TASK_COMPOSER_PLUGINS"); -// tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_planning::TaskComposerTaskFactoryAnchor(), "TESSERACT_TASK_COMPOSER_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_planning::TaskComposerPlanningFactoriesAnchor(), "TESSERACT_TASK_COMPOSER_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_planning::TaskComposerTaskflowFactoriesAnchor(), "TESSERACT_TASK_COMPOSER_PLUGINS"); +tesseract_common::PluginLoader::addSymbolLibraryToSearchLibrariesEnv(tesseract_planning::TaskComposerTaskFactoryAnchor(), "TESSERACT_TASK_COMPOSER_PLUGINS"); %}