Franka ローカルでexamplesをビルド・CMakeLists.txt的


手順

オリジナルのlibfranka/examples/CMakeLists.txtを元に自分で理解できる記述に変更

$ git clone https://git-codecommit.us-east-2.amazonaws.com/v1/repos/franka_test1
$ cd franka_test1
$ cat CMakeLists.txt 
cmake_minimum_required(VERSION 3.4)

project(libfranka-examples CXX)

include_directories(/opt/ros/melodic/include/libfranka)
include_directories(/usr/include/eigen3)

#set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Franka REQUIRED)
#find_package(Eigen3 REQUIRED)
find_package(Poco REQUIRED COMPONENTS Foundation)

#set(THREADS_PREFER_PTHREAD_FLAG ON)
#find_package(Threads REQUIRED)

add_library(examples_common STATIC
  examples_common.cpp
)

target_link_libraries(examples_common PUBLIC Franka::Franka)

set(EXAMPLES
  cartesian_impedance_control
  communication_test
  echo_robot_state
  force_control
  generate_cartesian_pose_motion
  generate_cartesian_velocity_motion
  generate_consecutive_motions
  generate_elbow_motion
  generate_joint_position_motion
  generate_joint_velocity_motion
  grasp_object
  joint_impedance_control
  joint_point_to_point_motion
  motion_with_control
  print_joint_poses
  vacuum_object
)

foreach(example ${EXAMPLES})
  add_executable(${example} ${example}.cpp)
  target_link_libraries(${example} examples_common Franka::Franka)
endforeach()

target_link_libraries(joint_impedance_control Threads::Threads)
target_link_libraries(motion_with_control Poco::Foundation)
$ mkdir build
$ cd build
$ cmake ..
-- The CXX compiler identification is GNU 7.5.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/frankanote/franka_test1/build
$ make
Scanning dependencies of target examples_common
[  2%] Building CXX object CMakeFiles/examples_common.dir/examples_common.cpp.o
[  5%] Linking CXX static library libexamples_common.a
[  5%] Built target examples_common
Scanning dependencies of target vacuum_object
[  8%] Building CXX object CMakeFiles/vacuum_object.dir/vacuum_object.cpp.o
[ 11%] Linking CXX executable vacuum_object
[ 11%] Built target vacuum_object
Scanning dependencies of target force_control
[ 14%] Building CXX object CMakeFiles/force_control.dir/force_control.cpp.o
[ 17%] Linking CXX executable force_control
[ 17%] Built target force_control
Scanning dependencies of target print_joint_poses
[ 20%] Building CXX object CMakeFiles/print_joint_poses.dir/print_joint_poses.cpp.o
[ 23%] Linking CXX executable print_joint_poses
[ 23%] Built target print_joint_poses
Scanning dependencies of target echo_robot_state
[ 26%] Building CXX object CMakeFiles/echo_robot_state.dir/echo_robot_state.cpp.o
[ 29%] Linking CXX executable echo_robot_state
[ 29%] Built target echo_robot_state
Scanning dependencies of target communication_test
[ 32%] Building CXX object CMakeFiles/communication_test.dir/communication_test.cpp.o
[ 35%] Linking CXX executable communication_test
[ 35%] Built target communication_test
Scanning dependencies of target generate_cartesian_pose_motion
[ 38%] Building CXX object CMakeFiles/generate_cartesian_pose_motion.dir/generate_cartesian_pose_motion.cpp.o
[ 41%] Linking CXX executable generate_cartesian_pose_motion
[ 41%] Built target generate_cartesian_pose_motion
Scanning dependencies of target generate_consecutive_motions
[ 44%] Building CXX object CMakeFiles/generate_consecutive_motions.dir/generate_consecutive_motions.cpp.o
[ 47%] Linking CXX executable generate_consecutive_motions
[ 47%] Built target generate_consecutive_motions
Scanning dependencies of target joint_impedance_control
[ 50%] Building CXX object CMakeFiles/joint_impedance_control.dir/joint_impedance_control.cpp.o
[ 52%] Linking CXX executable joint_impedance_control
[ 52%] Built target joint_impedance_control
Scanning dependencies of target generate_cartesian_velocity_motion
[ 55%] Building CXX object CMakeFiles/generate_cartesian_velocity_motion.dir/generate_cartesian_velocity_motion.cpp.o
[ 58%] Linking CXX executable generate_cartesian_velocity_motion
[ 58%] Built target generate_cartesian_velocity_motion
Scanning dependencies of target generate_joint_position_motion
[ 61%] Building CXX object CMakeFiles/generate_joint_position_motion.dir/generate_joint_position_motion.cpp.o
[ 64%] Linking CXX executable generate_joint_position_motion
[ 64%] Built target generate_joint_position_motion
Scanning dependencies of target generate_elbow_motion
[ 67%] Building CXX object CMakeFiles/generate_elbow_motion.dir/generate_elbow_motion.cpp.o
[ 70%] Linking CXX executable generate_elbow_motion
[ 70%] Built target generate_elbow_motion
Scanning dependencies of target grasp_object
[ 73%] Building CXX object CMakeFiles/grasp_object.dir/grasp_object.cpp.o
[ 76%] Linking CXX executable grasp_object
[ 76%] Built target grasp_object
Scanning dependencies of target generate_joint_velocity_motion
[ 79%] Building CXX object CMakeFiles/generate_joint_velocity_motion.dir/generate_joint_velocity_motion.cpp.o
[ 82%] Linking CXX executable generate_joint_velocity_motion
[ 82%] Built target generate_joint_velocity_motion
Scanning dependencies of target cartesian_impedance_control
[ 85%] Building CXX object CMakeFiles/cartesian_impedance_control.dir/cartesian_impedance_control.cpp.o
[ 88%] Linking CXX executable cartesian_impedance_control
[ 88%] Built target cartesian_impedance_control
Scanning dependencies of target joint_point_to_point_motion
[ 91%] Building CXX object CMakeFiles/joint_point_to_point_motion.dir/joint_point_to_point_motion.cpp.o
[ 94%] Linking CXX executable joint_point_to_point_motion
[ 94%] Built target joint_point_to_point_motion
Scanning dependencies of target motion_with_control
[ 97%] Building CXX object CMakeFiles/motion_with_control.dir/motion_with_control.cpp.o
[100%] Linking CXX executable motion_with_control
[100%] Built target motion_with_control

参照