ldionne/dyno

Cannot find HanaConfig.cmake

uknys opened this issue · 4 comments

uknys commented

Hello,
I tried to use your library with my project but I have this error with CMake :

  CMake Error at CMakeLists.txt:17 (find_package):
  By not providing "FindHana.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Hana", but
  CMake did not find one.

  Could not find a package configuration file provided by "Hana" with any of
  the following names:

    HanaConfig.cmake
    hana-config.cmake

I installed Boost 1.65.1 with Homebrew on macOS High Sierra, but it doesn't seem to have this file configured while I can add other Boost librairies in my CMake file.

uknys commented

To make it work I used your script in the dependencies folder !

Ahhh. Actually, I think this is a bug with the Boost distribution. When you install Boost, it should install a lib/cmake/Hana/HanaConfig.cmake file with it, but it doesn't. Reopening to keep track of this.

To make it work I used your script in the dependencies folder !

Make sure you're not using both that script AND a global installation of Boost, since that could cause problems.

For people experiencing the same problem and want to use a global installation of Boost, I've used:

find_package(Hana QUIET)
if (Hana_FOUND)
  target_link_libraries(dyno INTERFACE hana)
else()
  find_package(Boost 1.61)
  if (Boost_FOUND)
    target_link_libraries(dyno INTERFACE Boost::boost)
  else()
    message(SEND_ERROR "hana not found: either install stand-alone or use Boost>=1.61")
  endif()
endif()

Do the same for CallableTraits as well (but change the version to 1.64).

Also we need to change cmake/dyno-config.cmake file as well.

include(CMakeFindDependencyMacro)
find_package(Hana QUIET)
if (NOT Hana_FOUND)
  find_package(Boost 1.61 REQUIRED)
endif()

find_package(CallableTraits QUIET)
if (NOT CallableTraits_FOUND)
  find_package(Boost 1.64 REQUIRED)
endif()

# Below is the same
if(NOT TARGET Dyno::dyno)
  include("${CMAKE_CURRENT_LIST_DIR}/dyno-targets.cmake")
endif()

I am not sure whether this should be reported to Boost or packagers of my distribution but this is a workaround. I can send a PR but this feels like dirty hack.