Skip to content

Commit

Permalink
[misc] Remove legacy compilation mode since no longer necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Duburcq committed Apr 18, 2021
1 parent cdae2c0 commit 23e8b11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 82 deletions.
28 changes: 0 additions & 28 deletions build_tools/cmake/base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,7 @@ if(Boost_NO_SYSTEM_PATHS AND (NOT DEFINED BOOST_ROOT))
set(BOOST_ROOT "/opt/install/pc/")
endif()

# Determine if the old legacy old for Ubuntu 18 must be used.
# It will not use "find_package" but instead plain old "link_directories"
# and "include_directories" directives.
# Thus it requires the dependencies to be installed from robotpkg apt repository.
# TODO: Remove legacy mode after dropping support of Ubuntu 18 and moving to
# Eigen >= 3.3.7, Boost >= 1.71, and Pinocchio >=2.4.0.
find_package(Boost QUIET)
string(REPLACE "_" "." BOOST_VERSION "${Boost_LIB_VERSION}")
if(BOOST_VERSION VERSION_LESS "1.71.0")
set(LEGACY_MODE ON)
endif()
if(LEGACY_MODE)
if(WIN32)
message(FATAL_ERROR "Boost >= 1.71.0 required.")
else()
message(WARNING "Boost version < 1.71.0 detected. Falling back to Ubuntu 18 legacy mode. "
"Make sure depedencies have been installed via `apt-get`, and building "
"against Pinocchio >= 2.5.2, and Hpp-Fcl >= 1.5.4.")
endif()
endif()

# Add Fallback search paths for headers and libraries
if(LEGACY_MODE)
link_directories("/opt/openrobots/lib/")
link_directories("/opt/install/pc/lib/")
include_directories(SYSTEM "/opt/openrobots/include/")
include_directories(SYSTEM "/opt/install/pc/include/")
include_directories(SYSTEM "/opt/install/pc/include/eigen3/")
endif()
list(APPEND CMAKE_PREFIX_PATH "/opt/openrobots/")

# Due to license considerations, we will only use the MPL2 parts of Eigen.
Expand Down
60 changes: 19 additions & 41 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,21 @@ project(${LIBRARY_NAME}_core VERSION ${BUILD_VERSION})

# Find dependencies
find_package(Boost REQUIRED COMPONENTS system filesystem serialization date_time thread)

if(NOT LEGACY_MODE)
find_package(urdfdom REQUIRED NO_MODULE NO_CMAKE_SYSTEM_PATH) # It is impossible to specify the version because it is not exported in cmake config files...
find_package(PkgConfig QUIET) # Using pkgconfig is the only way to get the library version...
if (PkgConfig_FOUND)
pkg_check_modules(_URDFDOM QUIET "urdfdom")
if ((_URDFDOM_FOUND) AND (NOT _URDFDOM_PREFIX STREQUAL "/usr"))
set(urdfdom_VERSION "${_URDFDOM_VERSION}")
endif()
endif()
if(urdfdom_VERSION)
message(STATUS "Found urdfdom: version ${urdfdom_VERSION}")
else()
message(STATUS "Found urdfdom")
endif()

find_package(pinocchio 2.5.2 NO_MODULE NO_CMAKE_SYSTEM_PATH) # Pinocchio v2.5.2 introduces 'isNormalized' method
if(pinocchio_FOUND)
message(STATUS "Found pinocchio: version ${pinocchio_VERSION}")
else()
find_package(hpp-fcl 1.5.4 REQUIRED NO_MODULE NO_CMAKE_SYSTEM_PATH) # hpp-fcl >= 1.5.4 adds support of collision of primitives with halfspace
find_package(urdfdom REQUIRED NO_MODULE NO_CMAKE_SYSTEM_PATH) # It is impossible to specify the version because it is not exported in cmake config files...
find_package(PkgConfig QUIET) # Using pkgconfig is the only way to get the library version...
if (PkgConfig_FOUND)
pkg_check_modules(_URDFDOM QUIET "urdfdom")
if ((_URDFDOM_FOUND) AND (NOT _URDFDOM_PREFIX STREQUAL "/usr"))
set(urdfdom_VERSION "${_URDFDOM_VERSION}")
endif()
endif()

if(urdfdom_VERSION)
message(STATUS "Found urdfdom: version ${urdfdom_VERSION}")
else()
message(STATUS "Found urdfdom")
endif()
find_package(pinocchio 2.5.2 REQUIRED NO_MODULE NO_CMAKE_SYSTEM_PATH) # Pinocchio v2.5.2 introduces 'isNormalized' method
find_package(hpp-fcl 1.5.4 REQUIRED NO_MODULE NO_CMAKE_SYSTEM_PATH) # hpp-fcl >= 1.5.4 adds support of collision of primitives with halfspace
find_package(Eigen3 3.3.0 REQUIRED NO_MODULE) # It adds the target Eigen3::Eigen

# Pinocchio-specific stuffs
Expand Down Expand Up @@ -118,9 +109,7 @@ target_include_directories(${PROJECT_NAME}-object SYSTEM PUBLIC

# Include headers from other libraries (in such a way to avoid any warnings compiling them)
target_include_directories(${PROJECT_NAME}-object SYSTEM PUBLIC "${Boost_INCLUDE_DIRS}")
if(NOT LEGACY_MODE)
target_include_directories(${PROJECT_NAME}-object SYSTEM PUBLIC "${urdfdom_INCLUDE_DIRS}")
endif()
target_include_directories(${PROJECT_NAME}-object SYSTEM PUBLIC "${urdfdom_INCLUDE_DIRS}")
get_target_property(Eigen3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME}-object SYSTEM PUBLIC ${Eigen3_INCLUDE_DIRS})

Expand All @@ -147,23 +136,12 @@ foreach(target "${PROJECT_NAME}" "${LIBRARY_NAME}")
target_compile_features(${target} PUBLIC cxx_std_17)

# Linking with other libraries (in such a way to avoid any warnings compiling them)
if(pinocchio_FOUND)
target_link_libraries_system(${target} pinocchio::pinocchio)
elseif(hpp-fcl_FOUND)
target_link_libraries_system(${target} hpp-fcl::hpp-fcl)
elseif(LEGACY_MODE)
# It is necessary to link to Pinocchio shared lib since 2.4.0
target_link_libraries(${target} pinocchio hpp-fcl)
endif()
if(NOT LEGACY_MODE)
if (NOT "${urdfdom_LIBRARIES}" MATCHES ".*tinyxml.*")
list(APPEND urdfdom_LIBRARIES "tinyxml")
endif()
target_link_libraries(${target} "${urdfdom_LIBRARIES}")
else()
# Fallback to raw library name
target_link_libraries(${target} urdfdom_model)
target_link_libraries_system(${target} pinocchio::pinocchio)
target_link_libraries_system(${target} hpp-fcl::hpp-fcl)
if (NOT "${urdfdom_LIBRARIES}" MATCHES ".*tinyxml.*")
list(APPEND urdfdom_LIBRARIES "tinyxml")
endif()
target_link_libraries(${target} "${urdfdom_LIBRARIES}")
target_link_libraries(${target} Eigen3::Eigen)
target_link_libraries(${target} jsoncpp::jsoncpp hdf5::hdf5_cpp hdf5::hdf5 hdf5::zlib) # Beware the order is critical !
target_link_libraries(${target} ${Boost_LIBRARIES})
Expand Down
15 changes: 2 additions & 13 deletions python/jiminy_pywrap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ cmake_minimum_required(VERSION 3.10)
project(${LIBRARY_NAME}_pywrap VERSION ${BUILD_VERSION})

# Find libraries and headers
if(NOT LEGACY_MODE)
find_package(eigenpy 2.0.2 NO_MODULE NO_CMAKE_SYSTEM_PATH) # It adds target include lib eigenpy::eigenpy
if((NOT eigenpy_FOUND) AND (WIN32))
message(FATAL_ERROR "Eigenpy not found, CMake will exit.")
elseif(eigenpy_FOUND)
message(STATUS "Found eigenpy: version ${eigenpy_VERSION}")
endif()
endif()
find_package(eigenpy 2.0.2 REQUIRED NO_MODULE NO_CMAKE_SYSTEM_PATH)

# Add cpp sources (in binary dir, since the sources are pre-processed to substitute docstring)
set(SRC
Expand Down Expand Up @@ -56,11 +49,7 @@ target_include_directories(${PROJECT_NAME}
SYSTEM PRIVATE ${NumPy_INCLUDE_DIRS} ${Python_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME} ${LIBRARY_NAME}_core "${BOOST_PYTHON_LIB}")
if(NOT LEGACY_MODE)
target_link_libraries_system(${PROJECT_NAME} eigenpy::eigenpy)
else()
target_link_libraries(${PROJECT_NAME} eigenpy) # Fallback to raw library name
endif()
target_link_libraries_system(${PROJECT_NAME} eigenpy::eigenpy)

# Install C++ headers
install(DIRECTORY "include/${LIBRARY_NAME}"
Expand Down

0 comments on commit 23e8b11

Please sign in to comment.