Skip to content

Commit

Permalink
cmake: refactor exported CMake configuration
Browse files Browse the repository at this point in the history
- Avoid relative paths (../../..) in exported CMake variables
- Find dependencies in downstream packages and do not export build-time include
  directories
- Use find_package(Eigen3) CMake config shipped with newer Eigen versions and
  install custom FindEigen3.cmake to find older versions
- Rename CMake templates to match the installed filenames
  • Loading branch information
meyerj committed Jun 6, 2020
1 parent a540506 commit 228754b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions orocos_kdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ ENDIF ( NOT CMAKE_BUILD_TYPE )

SET( KDL_CFLAGS "")

find_package(Eigen 3 QUIET)
if(NOT Eigen_FOUND)
find_package(Eigen3 QUIET)
if(NOT EIGEN3_FOUND)
include(${PROJ_SOURCE_DIR}/cmake/FindEigen3.cmake)
set(Eigen_INCLUDE_DIR "${EIGEN3_INCLUDE_DIR}")
endif()
include_directories(${Eigen_INCLUDE_DIR})
SET(KDL_CFLAGS "${KDL_CFLAGS} -I${Eigen_INCLUDE_DIR}")
include_directories(${EIGEN3_INCLUDE_DIR})
SET(KDL_CFLAGS "${KDL_CFLAGS} -I${EIGEN3_INCLUDE_DIR}")

# Check the platform STL containers capabilities
include(cmake/CheckSTLContainers.cmake)
Expand Down Expand Up @@ -110,11 +109,12 @@ export(TARGETS orocos-kdl
export(PACKAGE orocos_kdl)

# Generate CMake package configuration
CONFIGURE_FILE(KDLConfig.cmake.in
CONFIGURE_FILE(orocos_kdl-config.cmake.in
${PROJECT_BINARY_DIR}/orocos_kdl-config.cmake @ONLY)
CONFIGURE_FILE(KDLConfigVersion.cmake.in
CONFIGURE_FILE(orocos_kdl-config-version.cmake.in
${PROJECT_BINARY_DIR}/orocos_kdl-config-version.cmake @ONLY)

INSTALL(FILES cmake/FindEigen3.cmake DESTINATION share/orocos_kdl/cmake)
INSTALL(FILES ${PROJECT_BINARY_DIR}/orocos_kdl-config.cmake DESTINATION share/orocos_kdl/cmake)
INSTALL(FILES ${PROJECT_BINARY_DIR}/orocos_kdl-config-version.cmake DESTINATION share/orocos_kdl/cmake)
INSTALL(EXPORT OrocosKDLTargets DESTINATION share/orocos_kdl/cmake)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
# orocos_kdl_LIBRARIES - libraries to link against for Orocos KDL
# orocos_kdl_PKGCONFIG_DIR - directory containing the .pc pkgconfig files

# Find dependencies
find_package(Boost REQUIRED)
find_package(Eigen3 QUIET)
if(NOT EIGEN3_FOUND)
include(${CMAKE_CURRENT_LIST_DIR}/FindEigen3.cmake)
endif()

# Compute paths
set(orocos_kdl_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../../include;@Boost_INCLUDE_DIRS@;@Eigen_INCLUDE_DIR@")
get_filename_component(orocos_kdl_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)

if(NOT TARGET orocos-kdl)
include("${CMAKE_CURRENT_LIST_DIR}/OrocosKDLTargets.cmake")
endif()

set(orocos_kdl_INCLUDE_DIRS "${orocos_kdl_PREFIX}/include;${Boost_INCLUDE_DIRS};${EIGEN3_INCLUDE_DIR}")
set(orocos_kdl_LIBRARIES orocos-kdl)

# where the .pc pkgconfig files are installed
set(orocos_kdl_PKGCONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../lib/pkgconfig")
set(orocos_kdl_PKGCONFIG_DIR "${orocos_kdl_PREFIX}/lib/pkgconfig")

0 comments on commit 228754b

Please sign in to comment.