0

I write a generic function to support the search of the dependencies.

If I write the following command:

find_package(HDF5 REQUIRED HINTS /opt/cots/)

the cmake (version 3.13.4 on REHL7 ) is able to find correctly the dependencies and everything is working properly. if instead I try to write generic code like that:

set(HDF5_HINT_ROOT "/opt/cots/") # in another file
set(HDF5_HINT_STRING "HINTS ${HDF5_HINT_ROOT}")
find_package(HDF5 REQUIRED ${HDF5_HINT_STRING})

I obtain the following error:

CMake Error at /usr/share/cmake3/Modules/FindHDF5.cmake:136 (message):
HINTS /opt/cots/ is not a valid HDF5 component.

Expansion of the variable with --trace-expand is exactly the same. What I 'm missing?

Thanks in advance

  • 1
    Look closely into the error message: CMake treats string `HINTS /opt/cots/` as a **single argument**. This is because you enclose this string into double quotes when assign `HDF5_HINT_STRING` variable. Remove that double quotes, and behavour will be as expected one. – Tsyvarev Apr 23 '19 at 09:12
  • Thanks a lot!!! I need to better figure out the usage of double quote – Michele Belotti Apr 23 '19 at 11:54
  • 1
    As a general rule in CMake: Put into the double quotes only a string, which represents a **single value**, never use double quotes for a *multi-value* variable. – Tsyvarev Apr 23 '19 at 12:02

0 Answers0