Skip to content

Commit

Permalink
Release/0.6 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhu-flexiv authored Aug 17, 2022
1 parent 0b9d3fe commit bb948ec
Show file tree
Hide file tree
Showing 98 changed files with 2,389 additions and 2,211 deletions.
80 changes: 48 additions & 32 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CMake

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
workflow_dispatch:

env:
Expand All @@ -20,23 +20,32 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cd ${{github.workspace}}
rm -rf build
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build and install library
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to an external directory.
run: |
cd ${{github.workspace}}
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
make install
- name: Build examples
# Find and link to the flexiv_rdk INTERFACE library, then build all examples.
run: |
cd ${{github.workspace}}/example
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
make -j$(nproc)
- name: Build tests
# Find and link to the flexiv_rdk INTERFACE library, then build all tests.
run: |
cd ${{github.workspace}}/test
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
make -j$(nproc)
- name: Build
# Build examples and tests
run: |
cd ${{github.workspace}}/build
make -j$(nproc)
build-ubuntu18:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
Expand All @@ -45,21 +54,28 @@ jobs:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cd ${{github.workspace}}
rm -rf build
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build and install library
# Configure CMake, then build and install the flexiv_rdk INTERFACE library to an external directory.
run: |
cd ${{github.workspace}}
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
make install
- name: Build
# Build examples and tests
run: |
cd ${{github.workspace}}/build
make -j$(nproc)
- name: Build examples
# Find and link to the flexiv_rdk INTERFACE library, then build all examples.
run: |
cd ${{github.workspace}}/example
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
make -j$(nproc)
- name: Build tests
# Find and link to the flexiv_rdk INTERFACE library, then build all tests.
run: |
cd ${{github.workspace}}/test
rm -rf build && mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/rdk_install
make -j$(nproc)
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.vscode
.vs
.DS_Store
config.h
build/
html/
html/
__pycache__
172 changes: 70 additions & 102 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,117 +1,85 @@
# use cmake 3 which supports targets
cmake_minimum_required(VERSION 3.1.3)
cmake_minimum_required(VERSION 3.4)

# ===================================
# PROJECT SETUP
# ===================================
project(FlexivRdkExampleAndTest)
# ===================================================================
# PROJECT CONFIG
# ===================================================================
project(flexiv_rdk VERSION 0.6.0)

if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE )
endif()
# C++14 required
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(BUILD_FOR_ARM64 "Link to RDK library for arm64 processor, otherwise link to x64" OFF)
# Configure build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "CMake build type" FORCE)
endif()

set(CMAKE_VERBOSE_MAKEFILE ON)
# Configure processor platform
set(BUILD_PLATFORM "x86_64" CACHE STRING "Processor platform")
set_property(CACHE BUILD_PLATFORM PROPERTY STRINGS "x86_64" "arm64")

# Set static library
message("Building for system: ${CMAKE_SYSTEM_NAME}")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${BUILD_PLATFORM} STREQUAL "x86_64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libFlexivRdk.x86_64-linux-gnu.a")
elseif(${BUILD_PLATFORM} STREQUAL "arm64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libFlexivRdk.aarch64-linux-gnu.a")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${BUILD_PLATFORM} STREQUAL "x86_64")
message(FATAL_ERROR "Mac with x86_64 processor is currently not supported.")
elseif(${BUILD_PLATFORM} STREQUAL "arm64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libFlexivRdk.arm64-darwin.a")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(${BUILD_PLATFORM} STREQUAL "x86_64")
set(RDK_STATIC_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/lib/FlexivRdk.x86_64-windows.lib")
elseif(${BUILD_PLATFORM} STREQUAL "arm64")
message(FATAL_ERROR "Windows with arm64 processor is currently not supported.")
endif()
endif()

# ===================================================================
# PROJECT DEPENDENCIES
# ===================================================================
# pthread
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

# ===================================
# CONFIGURE ALL EXAMPLES
# ===================================
# examples bin output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/example)

# list of examples
set(EXAMPLE_LIST
auto_recovery
cartesian_impedance_control
clear_fault
display_robot_states
floating_with_soft_limits
gripper_control
joint_impedance_control
joint_position_control
plan_execution
primitive_execution
robot_dynamics
series_operation
visualization
)

foreach(example ${EXAMPLE_LIST})
# create executable from source
add_executable(${example} example/${example}.cpp)

# link dependencies
target_include_directories(${example}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen3
)
# ===================================================================
# PROJECT LIBRARIES
# ===================================================================
# Create an INTERFACE library with no source file to compile
add_library(${PROJECT_NAME} INTERFACE)

# Link basic libraries
target_link_libraries(${example}
Threads::Threads
anl
)
# Create an alias of the library using flexiv namespace,
# to imitate the install target which uses flexiv namespace.
add_library(flexiv::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

# Link arm64 or x64 version of libFlexivRdk
if (${BUILD_FOR_ARM64})
target_link_libraries(${example}
${CMAKE_CURRENT_SOURCE_DIR}/lib/linux/cpp/arm64/libFlexivRdk.a)
else()
target_link_libraries(${example}
${CMAKE_CURRENT_SOURCE_DIR}/lib/linux/cpp/x64/libFlexivRdk.a)
endif()

endforeach()


# ===================================
# CONFIGURE ALL TESTS
# ===================================
# tests bin output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test)

# list of tests
set(TEST_LIST
test_dynamics_engine
test_dynamics_with_tool
test_endurance
test_log
test_loop_latency
test_scheduler
test_timeliness_monitor
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

foreach(test ${TEST_LIST})
# create executable from source
add_executable(${test} test/${test}.cpp)
target_link_libraries(${PROJECT_NAME} INTERFACE
${RDK_STATIC_LIBRARY}
Threads::Threads
)

# link dependencies
target_include_directories(${test}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen3
)
# Use moderate compiler warning option
if(MSVC)
target_compile_options(${PROJECT_NAME} INTERFACE /W1)
else()
target_compile_options(${PROJECT_NAME} INTERFACE -Wall -Wextra)
endif()

# Link basic libraries
target_link_libraries(${test}
Threads::Threads
anl
)
# Install the INTERFACE library
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FlexivInstallLibrary.cmake)
FlexivInstallLibrary()

# Link arm64 or x64 version of libFlexivRdk
if (${BUILD_FOR_ARM64})
target_link_libraries(${test}
${CMAKE_CURRENT_SOURCE_DIR}/lib/linux/cpp/arm64/libFlexivRdk.a)
else()
target_link_libraries(${test}
${CMAKE_CURRENT_SOURCE_DIR}/lib/linux/cpp/x64/libFlexivRdk.a)
endif()

endforeach()
# Also install Eigen headers
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen3/Eigen
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
Loading

0 comments on commit bb948ec

Please sign in to comment.