frankaemika / libfranka

C++ library for Franka research robots
https://frankaemika.github.io
Apache License 2.0
244 stars 158 forks source link

[proposed enhancement] CMake: Check for available targets before find_package #132

Closed SchneiderROS closed 2 months ago

SchneiderROS commented 1 year ago

Hi there,

I'm unsing libfranka within my own project. Like libfranka my project uses the Eigen library and therefore Eigen is already a target in my cmake generation step. If I now include libfranka to my project with FetchContent, the libfranka CMakeLists.txt is executed and does a find_package(Eigen3 REQUIRED). The find_package tries to find Eigen in the system directories (global install) and does not incorporate the Eigen target that I already have. The find_package fails and the libfranka installation is aborted. I Don't want to install Eigen system wide and I think I am not the only one that want to have everything local and clean. If libfranka just checks if the target is already available before doing a find_package, this rough behavior could be eliminated.

Therefore I propose to replace the CMakeLists.tex line 29 find_package(Eigen3 REQUIRED) with if (NOT TARGET Eigen3::Eigen3) find_package(Eigen3 REQUIRED) endif()

I tested this modification locally and works well.

AndreasKuhner commented 2 months ago

Hi @SchneiderROS , the reply might come a bit late... :)

I think it is 'clean' to check for the package and should be available to find. Alternatively, you could add your local library paths to the LD_LIBRARY_PATH s.t. also libfranka can find it.

Cheers, Andreas