https://blog.csdn.net/weixin_44388819/article/details/118567328
https://www.cnblogs.com/cv-pr/p/5787176.html
在Catkin构建系统中,除了 ${CATKIN_PACKAGE_PREFIX_DESTINATION},还有一些其他常用的安装目标变量,用于指定要将文件和目录安装到哪里。以下是一些常见的安装目标变量:
${CATKIN_GLOBAL_SHARE_DESTINATION}:
通常用于将文件和目录安装到ROS工作空间的全局共享目录。这可用于包之间共享的资源,如参数文件或配置文件。
${CATKIN_PACKAGE_SHARE_DESTINATION}:
用于将文件和目录安装到当前ROS包的共享目录。这通常用于将与包相关的资源安装到包内。
${CATKIN_GLOBAL_LIB_DESTINATION}:
通常用于将库文件(.so 文件)安装到ROS工作空间的全局库目录。
${CATKIN_PACKAGE_LIB_DESTINATION}:
用于将库文件安装到当前ROS包的库目录。
${CATKIN_GLOBAL_BIN_DESTINATION}:
通常用于将可执行文件安装到ROS工作空间的全局可执行文件目录。
${CATKIN_PACKAGE_BIN_DESTINATION}:
用于将可执行文件安装到当前ROS包的可执行文件目录。
这些变量的值由Catkin根据工作空间的结构和安装目标的不同类型自动设置。你可以使用这些变量来控制你的文件和目录安装到工作空间中的哪个位置。
需要注意的是, C A T K I N P A C K A G E P R E F I X D E S T I N A T I O N 和 {CATKIN_PACKAGE_PREFIX_DESTINATION}和 CATKINPACKAGEPREFIXDESTINATION和{CATKIN_GLOBAL_SHARE_DESTINATION}通常用于包内文件和资源,而 C A T K I N P A C K A G E B I N D E S T I N A T I O N 和 {CATKIN_PACKAGE_BIN_DESTINATION}和 CATKINPACKAGEBINDESTINATION和{CATKIN_GLOBAL_BIN_DESTINATION}通常用于可执行文件。根据你的需求,你可以选择适当的变量来安装文件和目录。
将如下install复制到每个package的CMakelist文件中,catkin_make 后catkin_make install后即可获取封装后的文件
#############
## Install ##
#############
# #添加文件到指定目录lib
# install(PROGRAMS
# dev_install/nvidia_env.txt
# dev_install/qt5_env.txt
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
# #添加文件夹到指定目录lib
# install(DIRECTORY dev_install/json_lib
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables and/or libraries for installation
#执行程序文件编译成库
install(TARGETS ros_qt_app
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
## Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h *.hpp"
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY resources
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
install(DIRECTORY dev_install
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
# install(DIRECTORY urdf
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
# install(DIRECTORY mesh
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
# install(DIRECTORY rviz
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
#t添加launch文件到share文件夹
install(FILES
launch/bringup.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)