diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f95d41ead8..189771fd56 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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 " @@ -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 @@ -59,7 +78,13 @@ 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 @@ -67,5 +92,26 @@ jobs: 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 61a0d5c08c..f829122c0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() @@ -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) @@ -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() diff --git a/cmake b/cmake index 5cb34667bd..ef309d5a23 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 5cb34667bde62b5676e2b869dc6d13d598a4e2e3 +Subproject commit ef309d5a23037324b48749ab8faf30846dc0e7f0 diff --git a/unittest/packaging/CMakeLists.txt b/unittest/packaging/cmake/CMakeLists.txt similarity index 62% rename from unittest/packaging/CMakeLists.txt rename to unittest/packaging/cmake/CMakeLists.txt index c67e262dc8..f9a52e0dfb 100644 --- a/unittest/packaging/CMakeLists.txt +++ b/unittest/packaging/cmake/CMakeLists.txt @@ -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) diff --git a/unittest/packaging/external/CMakeLists.txt b/unittest/packaging/external/CMakeLists.txt new file mode 100644 index 0000000000..f5a92e1304 --- /dev/null +++ b/unittest/packaging/external/CMakeLists.txt @@ -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) diff --git a/unittest/packaging/pkgconfig/CMakeLists.txt b/unittest/packaging/pkgconfig/CMakeLists.txt new file mode 100644 index 0000000000..352d2eca50 --- /dev/null +++ b/unittest/packaging/pkgconfig/CMakeLists.txt @@ -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}")