### Install SDK Files Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Installs the SDK's header files from the 'include/' directory to the system's include path. It also installs the built library targets (archive, library, runtime) and includes to their respective destinations (lib/, bin/). ```cmake install( DIRECTORY include/ DESTINATION include/ ) install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin INCLUDES DESTINATION include ) ``` -------------------------------- ### Install Executable and Program with CMake Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk_examples/CMakeLists.txt This CMake snippet handles the installation of build artifacts. It installs the 'read_write_node' executable to a specific library path and also installs the 'src/read_write_node.py' Python script to the same destination directory. ```cmake # Install install(TARGETS read_write_node DESTINATION lib/${PROJECT_NAME} ) install(PROGRAMS src/read_write_node.py DESTINATION lib/${PROJECT_NAME} ) ``` -------------------------------- ### Install Python Package Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Uses the ament_python_install_package macro to install the Python package for the Dynamixel SDK. It specifies the package name and the directory containing the Python package sources. ```cmake ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR "src/dynamixel_sdk") ``` -------------------------------- ### Configure Testing and Packaging with CMake Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk_examples/CMakeLists.txt This CMake snippet configures the build for testing if 'BUILD_TESTING' is enabled. It finds linting dependencies and includes commented-out options to skip copyright and cpplint checks. Finally, it defines the package metadata using 'ament_package()'. ```cmake # Test if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # uncomment the line when a copyright and license is not present in all source files #set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # uncomment the line when this package is not in a git repo #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() ament_package() ``` -------------------------------- ### Configure C++ Build with CMake Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk_examples/CMakeLists.txt This snippet demonstrates basic CMake configuration for a C++ project. It sets the minimum required version, project name, C++ standard to C++17, and adds compiler warnings for GCC and Clang. It then finds essential dependencies like ament_cmake, dynamixel_sdk, and ROS 2 libraries. ```cmake cmake_minimum_required(VERSION 3.5) project(dynamixel_sdk_examples) # Default to C++17 if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # Find dependencies find_package(ament_cmake REQUIRED) find_package(ament_cmake_python REQUIRED) find_package(dynamixel_sdk REQUIRED) find_package(dynamixel_sdk_custom_interfaces REQUIRED) find_package(rclcpp REQUIRED) find_package(rclpy REQUIRED) include_directories(include) ``` -------------------------------- ### Build and Link C++ Executable with CMake Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk_examples/CMakeLists.txt This CMake snippet defines a C++ executable target named 'read_write_node' from 'src/read_write_node.cpp'. It then links this executable against the 'dynamixel_sdk', custom interfaces, and the 'rclcpp' library, making them available for use. ```cmake # Build add_executable(read_write_node src/read_write_node.cpp) target_link_libraries(read_write_node PUBLIC dynamixel_sdk::dynamixel_dynamixel_sdk ${dynamixel_sdk_custom_interfaces_TARGETS} rclcpp::rclcpp ) ``` -------------------------------- ### Export Ament Package Targets and Information Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Exports the targets and include directories of the Dynamixel SDK for use by other ament packages. This includes exporting the library target, include directories, and library paths, making the SDK usable in a ROS 2 environment. ```cmake ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) ament_export_include_directories(include) ament_export_libraries(${PROJECT_NAME}) ament_package() ``` -------------------------------- ### Build Dynamixel SDK Shared Library (Platform Specific) Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Builds the Dynamixel SDK as a shared library named 'dynamixel_sdk'. It conditionally includes platform-specific port handler source files (macOS, Windows, or Linux) based on the operating system detected by CMake. ```cmake if(APPLE) add_library(dynamixel_sdk SHARED ${DYNAMIXEL_SDK_SOURCES} src/dynamixel_sdk/port_handler_mac.cpp ) elseif(WIN32) add_library(dynamixel_sdk SHARED ${DYNAMIXEL_SDK_SOURCES} src/dynamixel_sdk/port_handler_windows.cpp ) else() add_library(dynamixel_sdk SHARED ${DYNAMIXEL_SDK_SOURCES} src/dynamixel_sdk/port_handler_linux.cpp ) endif() ``` -------------------------------- ### CMake Build Configuration for Dynamixel SDK Custom Interfaces (CMake) Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk_custom_interfaces/CMakeLists.txt Configures the build system for the Dynamixel SDK custom interfaces package. It sets the minimum CMake version, project name, C++ standard to C++17, enables compiler warnings for GCC and Clang, finds required ROS 2 packages, defines message and service files, generates interface code, and exports package dependencies. ```cmake cmake_minimum_required(VERSION 3.5) project(dynamixel_sdk_custom_interfaces) # Default to C++17 if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find dependencies find_package(ament_cmake REQUIRED) find_package(builtin_interfaces REQUIRED) find_package(rosidl_default_generators REQUIRED) set(msg_files "msg/SetPosition.msg" ) set(srv_files "srv/GetPosition.srv" ) rosidl_generate_interfaces(${PROJECT_NAME} ${msg_files} ${srv_files} DEPENDENCIES builtin_interfaces ) ament_export_dependencies(rosidl_default_runtime) ament_package() ``` -------------------------------- ### Find Ament Dependencies Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Finds necessary ament packages and libraries required for the project, including ament itself and ament_cmake_python for Python package support. The REQUIRED keyword ensures the build fails if these packages are not found. ```cmake find_package(ament_cmake REQUIRED) find_package(ament_cmake_python REQUIRED) ``` -------------------------------- ### Configure C++ Standard and Compiler Options Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Sets the C++ standard to C++17 if not already defined. It also adds standard compiler warnings (Wall, Wextra, Wpedantic) and specific flags to suppress unused variable and parameter warnings for GCC and Clang compilers. ```cmake if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable) endif() ``` -------------------------------- ### Set CMake Minimum Version and Project Name Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Sets the minimum required CMake version for the project and defines the project name. This ensures compatibility with the specified CMake version and identifies the project during the build process. ```cmake cmake_minimum_required(VERSION 3.5) project(dynamixel_sdk) ``` -------------------------------- ### Define Dynamixel SDK Source Files Source: https://github.com/robotis-git/dynamixelsdk/blob/main/ros/dynamixel_sdk/CMakeLists.txt Defines a CMake variable `DYNAMIXEL_SDK_SOURCES` containing a list of all C++ source files for the Dynamixel SDK. This variable is used later when creating the library target. ```cmake set(DYNAMIXEL_SDK_SOURCES src/dynamixel_sdk/packet_handler.cpp src/dynamixel_sdk/protocol1_packet_handler.cpp src/dynamixel_sdk/protocol2_packet_handler.cpp src/dynamixel_sdk/group_sync_read.cpp src/dynamixel_sdk/group_sync_write.cpp src/dynamixel_sdk/group_bulk_read.cpp src/dynamixel_sdk/group_bulk_write.cpp src/dynamixel_sdk/group_fast_bulk_read.cpp src/dynamixel_sdk/group_fast_sync_read.cpp src/dynamixel_sdk/group_handler.cpp src/dynamixel_sdk/port_handler.cpp ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.