如何将 SOEM 作为 git 子模块使用
SOEM 是一个不错的 EtherCAT 库,但我建议不要通过 RosPKG 或类似方式将其作为系统组件安装。相反,请将其作为 git 子模块使用。这样你可以轻松地更新它,并跟踪所使用的版本。
install-soem.sh
git submodule init
git submodule add https://github.com/OpenEtherCATsociety/SOEM.git
cd SOEM && git checkout v2.0.0使用 CMake 时,你可以像这样将其包含到你的项目中:
CMakeLists.txt
file(GLOB_RECURSE SOEM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/soem/*.c"
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/osal/linux/*.c"
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/oshw/linux/*.c"
)
target_include_directories(${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/soem"
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/oshw"
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/oshw/linux"
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/osal/"
"${CMAKE_CURRENT_SOURCE_DIR}/SOEM/osal/linux"
)现在找到你的 add_executable() 命令,并将 ${SOEM_SOURCES} 添加到源文件列表中。
CMakeLists.txt
add_executable(${PROJECT_NAME}
src/main.cpp
src/ds402_controller.cpp
${SOEM_SOURCES}
)If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow