Closed traversaro closed 3 years ago
Background: I hit this problem because I was debugging a failure in building the conda binary package for bipedal-locomotion-framework in https://github.com/traversaro/robotology-superbuild/runs/1998698606?check_suite_focus=true , as I was getting the error:
2021-02-28T16:52:51.3120575Z CMake Error at CMakeLists.txt:63 (include):
2021-02-28T16:52:51.3121761Z include could not find load file:
2021-02-28T16:52:51.3122316Z
2021-02-28T16:52:51.3123021Z AddInstallRPATHSupport
2021-02-28T16:52:51.3123613Z
2021-02-28T16:52:51.3124106Z
2021-02-28T16:52:51.3124855Z CMake Error at CMakeLists.txt:64 (add_install_rpath_support):
2021-02-28T16:52:51.3125772Z Unknown CMake command "add_install_rpath_support".
The actual root cause was that installing the matio-cpp conda package was not installing also the libmatio conda package (this should be solved by https://github.com/conda-forge/libmatio-feedstock/pull/34), but the fact that if matio was not found the CMAKE_MODULE_PATH
was corrupted was actually caused by the issue that this PR should solve.
macOS/Homebrew failures are unrelated, see https://github.com/traversaro/github-actions-brew-update-upgrade-check/actions/runs/608289319 . macOS/conda by the way works fine instead.
Before this PR, the
matioCppConfig.cmake
file contained this lines:Unfortunately these lines do not work correctly if
MATIO
is not present in the system butmatioCpp
is present. In that case, thematioCppConfig.cmake
gets executed till to thefind_dependency(MATIO QUIET)
call, and then the rest of the script is not executed as,find_dependency
callsreturn()
if the package is not found (see https://github.com/Kitware/CMake/blob/v3.19.6/Modules/CMakeFindDependencyMacro.cmake#L59). The net effect is that ifMATIO
is not found, theCMAKE_MODULE_PATH
gets corrupted by any call tofind_package(matioCpp)
, even if it was justfind_package(matioCpp QUIET)
.This PR proposes to fix this problem by using
find_package
there instead offind_dependency
. The main downside is that the error if MATIO is not found will be less clear, but this is in any case better then silently corruping theCMAKE_MODULE_PATH
value.