Skip to content

Commit

Permalink
Test packaging (#1365)
Browse files Browse the repository at this point in the history
* packaging: update test

* packaging: test pkgconfig

* ci: fix path

* ci: fix test

* cmake: fix path

* cmake: fix typo

* cmake: export variables

* test/packaging: add test for FetchContent

* cmake: sync submodule

* ci: run external cmake example

* ci: fix

* ci: fix GIT_TAG

* ci: fix branch name

* ci: fix branch name extraction

* ci: fix git url
  • Loading branch information
jcarpent authored Jan 6, 2021
1 parent 8f040db commit 178f146
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 17 deletions.
54 changes: 50 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,27 @@ jobs:
os: [ubuntu-20.04,ubuntu-18.04]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive

# extract branch name
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV

# extract branch name on pull request
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV

# print branch name
- name: Debug
run: echo ${{ env.BRANCH_NAME }}

- name: Register robotpkg
run: |
sudo sh -c "echo \"deb [arch=amd64] http://robotpkg.openrobots.org/packages/debian/pub $(lsb_release -cs) robotpkg\" >> /etc/apt/sources.list "
Expand Down Expand Up @@ -45,7 +65,6 @@ jobs:
- name: Run cmake
run: |
git submodule update --init
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/openrobots/lib/pkgconfig
export PATH=$PATH:/opt/openrobots/bin
export PYTHON3_DOT_VERSION=$(python3 -c "import sys; print(str(sys.version_info.major)+'.'+str(sys.version_info.minor))")
export PYTHONPATH=${PYTHONPATH}:/opt/openrobots/lib/python$PYTHON3_DOT_VERSION/site-packages
Expand All @@ -59,13 +78,40 @@ jobs:
export CTEST_OUTPUT_ON_FAILURE=1
make test
sudo make install
cd ../unittest/packaging
- name: Test packaging
run: |
export PATH=$PATH:/opt/openrobots/bin
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/openrobots/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/openrobots/lib:/usr/local/lib:/usr/lib:/usr/lib/x86_64-linux-gnu
cd ./unittest/packaging/cmake
mkdir build
cd build
export CMAKE_PREFIX_PATH=/usr/local
cmake ..
make
./run_rnea
./load_urdf
cd ../../../build
cd ../../pkgconfig
mkdir build
cd build
cmake ..
make
./run_rnea
cd ../../external
export PINOCCHIO_GIT_REPOSITORY="file://"$GITHUB_WORKSPACE
#export PINOCCHIO_GIT_REPOSITORY=$(git remote get-url origin)
export PINOCCHIO_GIT_TAG="test-external-"$(git rev-parse --short HEAD)
git tag $PINOCCHIO_GIT_TAG
mkdir build
cd build
cmake ..
make
./run_rnea
./load_urdf
- name: Uninstall project
run: |
cd build
sudo make uninstall
20 changes: 13 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)

# Check if the submodule cmake have been initialized
IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake")
IF(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/cmake/base.cmake")
MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n")
ENDIF()

SET(DOXYGEN_USE_MATHJAX YES)
SET(DOXYGEN_USE_TEMPLATE_CSS YES)

INCLUDE(cmake/base.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/cmake/base.cmake)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})

INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
INCLUDE(cmake/ide.cmake)
INCLUDE(cmake/apple.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/cmake/boost.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/cmake/python.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/cmake/ide.cmake)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/cmake/apple.cmake)

# If needed, set CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION()
Expand All @@ -45,7 +45,7 @@ ENDIF(WIN32)
# --- OPTIONS ----------------------------------------
OPTION(BUILD_BENCHMARK "Build the benchmarks" OFF)
OPTION(BUILD_UTILS "Build the utils" OFF)
OPTION(BUILD_PYTHON_INTERFACE "Build the Python binding" ON)
OPTION(BUILD_PYTHON_INTERFACE "Build the Python bindings" ON)
OPTION(BUILD_WITH_COMMIT_VERSION "Build libraries by setting specific commit version" OFF)

IF(DEFINED BUILD_UNIT_TESTS)
Expand Down Expand Up @@ -262,21 +262,27 @@ ADD_SUBDIRECTORY(benchmark)

# --- PACKAGING ----------------------------------------------------------------
IF(BUILD_WITH_URDF_SUPPORT)
SET(PINOCCHIO_USE_URDFDOM ON PARENT_SCOPE)
SET(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}\nset(PINOCCHIO_USE_URDFDOM \"\")")
ENDIF()
IF(BUILD_WITH_HPP_FCL_SUPPORT)
SET(PINOCCHIO_USE_HPP_FCL ON)
SET(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}\nset(PINOCCHIO_USE_HPP_FCL \"\")")
ENDIF()
IF(BUILD_WITH_CPPAD_SUPPORT)
SET(PINOCCHIO_USE_CPPAD ON)
SET(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}\nset(PINOCCHIO_USE_CPPAD \"\")")
ENDIF()
IF(BUILD_WITH_CPPAD_CODEGEN_SUPPORT)
SET(PINOCCHIO_USE_CPPAD_CODEGEN ON)
SET(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}\nset(PINOCCHIO_USE_CPPAD_CODEGEN \"\")")
ENDIF()
IF(BUILD_WITH_CASADI_SUPPORT)
SET(PINOCCHIO_USE_CASADI ON)
SET(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}\nset(PINOCCHIO_USE_CASADI \"\")")
ENDIF()
IF(BUILD_PYTHON_INTERFACE)
SET(PINOCCHIO_WITH_PYTHON_INTERFACE ON)
SET(PACKAGE_EXTRA_MACROS "${PACKAGE_EXTRA_MACROS}\nset(PINOCCHIO_WITH_PYTHON_INTERFACE \"\")")
ENDIF()

Expand Down
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 1 files
+1 −1 base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ cmake_minimum_required(VERSION 2.6)

project(ExtraLib CXX)
find_package(pinocchio REQUIRED)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)

set(PINOCCHIO_MODEL_DIR "${PROJECT_SOURCE_DIR}/../../models")
set(PINOCCHIO_MODEL_DIR "${PROJECT_SOURCE_DIR}/../../../models")
add_definitions('-DPINOCCHIO_MODEL_DIR=\"${PINOCCHIO_MODEL_DIR}\"')

add_executable(run_rnea run_rnea.cpp)
add_executable(run_rnea ../run_rnea.cpp)
target_link_libraries(run_rnea PUBLIC pinocchio::pinocchio)

if(DEFINED PINOCCHIO_USE_URDFDOM)
add_executable(load_urdf load_urdf.cpp)
add_executable(load_urdf ../load_urdf.cpp)
target_link_libraries(load_urdf PUBLIC pinocchio::pinocchio)
endif(DEFINED PINOCCHIO_USE_URDFDOM)
38 changes: 38 additions & 0 deletions unittest/packaging/external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.11)

project(ExtraLib CXX)

message(STATUS "PINOCCHIO_GIT_REPOSITORY: $ENV{PINOCCHIO_GIT_REPOSITORY}")
message(STATUS "PINOCCHIO_GIT_TAG: $ENV{PINOCCHIO_GIT_TAG}")

include(FetchContent)
FetchContent_Declare(
#FetchContent_Populate(
Pinocchio
GIT_REPOSITORY $ENV{PINOCCHIO_GIT_REPOSITORY}
GIT_TAG $ENV{PINOCCHIO_GIT_TAG}
GIT_SUBMODULES cmake
GIT_SHALLOW ON
)

FetchContent_GetProperties(Pinocchio)
if(NOT pinocchio_POPULATED) # name is lowercased
FetchContent_Populate(Pinocchio)
message(STATUS "pinocchio source dir: ${pinocchio_SOURCE_DIR}")
message(STATUS "pinocchio binary dir: ${pinocchio_BINARY_DIR}")
set(BUILD_PYTHON_INTERFACE OFF CACHE INTERNAL "Build Python bindings")
set(BUILD_TESTING OFF CACHE INTERNAL "Build unit tests")
add_subdirectory(${pinocchio_SOURCE_DIR} ${pinocchio_BINARY_DIR}) # name is lowercased
endif()
# or simply FetchContent_MakeAvailable(Pinocchio)

set(PINOCCHIO_MODEL_DIR "${PROJECT_SOURCE_DIR}/../../../models")
add_definitions('-DPINOCCHIO_MODEL_DIR=\"${PINOCCHIO_MODEL_DIR}\"')

add_executable(run_rnea ../run_rnea.cpp)
target_link_libraries(run_rnea PUBLIC pinocchio)

if(DEFINED PINOCCHIO_USE_URDFDOM)
add_executable(load_urdf ../load_urdf.cpp)
target_link_libraries(load_urdf PUBLIC pinocchio)
endif(DEFINED PINOCCHIO_USE_URDFDOM)
10 changes: 10 additions & 0 deletions unittest/packaging/pkgconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.6)

project(ExtraLib CXX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PINOCCHIO REQUIRED pinocchio)

include_directories(SYSTEM ${PINOCCHIO_INCLUDE_DIRS})
add_executable(run_rnea ../run_rnea.cpp)
target_link_libraries(run_rnea PUBLIC ${PINOCCHIO_LDFLAGS})
message(STATUS "${PINOCCHIO_LDFLAGS}")

0 comments on commit 178f146

Please sign in to comment.