OpenMS / contrib

Automated CMake build scripts for the OpenMS contrib libraries
Other
0 stars 21 forks source link

Include the hdf5-config.cmake if generated #101

Open jpfeuffer opened 4 years ago

jpfeuffer commented 4 years ago

Currently, we get weird CMake errors that actually do not seem to affect the compilation of OpenMS.

-- Unable to determine HDF5 C flags from HDF5 wrapper.
-- Unable to determine HDF5 C version from HDF5 wrapper.
-- Unable to determine HDF5 CXX flags from HDF5 wrapper.
-- Unable to determine HDF5 CXX version from HDF5 wrapper.

or

-- HDF5 C compiler wrapper is unable to compile a minimal HDF5 program.
/Users/runner/work/OpenMS/OpenMS/contribbld/h5c++
dir is /Users/runner/work/OpenMS/OpenMS/contribbld
Package hdf5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `hdf5.pc'
to the PKG_CONFIG_PATH environment variable
Package 'hdf5', required by 'hdf5_cpp-1.10.5', not found
/Users/runner/work/OpenMS/OpenMS/bld/src/openms/CMakeFiles/hdf5/cmake_hdf5_test.cxx:1:10: fatal error: 'H5Cpp.h' file not found
#include <H5Cpp.h>
         ^~~~~~~~~
1 error generated.
-- HDF5 CXX compiler wrapper is unable to compile a minimal HDF5 program.
-- Found HDF5: /Users/runner/work/OpenMS/OpenMS/contribbld/lib/libhdf5_cpp.a;/Users/runner/work/OpenMS/OpenMS/contribbld/lib/libhdf5.a (found version "1.10.5") found components: C CXX HL 

This is because the FindHDF5.cmake module is used, which tries to infer compile options from the hdf5 compiler wrappers (hdf5c++, etc.). Those wrappers are not correctly built in our contrib, e.g. on macOS it has stuff like a hardcoded compiler path in it:

#! /bin/sh
##
# Copyright by The HDF Group....

prg=$0
if [ ! -e "$prg" ]; then
  case $prg in
    (*/*) exit 1;;
    (*) prg=$(command -v -- "$prg") || exit;;
  esac
fi
dir=$(
  cd -P -- "$(dirname -- "$prg")/.." && pwd -P
) || exit
prg=$dir/$(basename -- "$prg") || exit

printf '%s\n' "$prg"
printf 'dir is %s\n' "$dir"

export PKG_CONFIG_PATH=$dir/lib/pkgconfig

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ `pkg-config --define-variable=prefix=$dir --cflag --libs hdf5_cpp-1.10.5` $@

and probably the try_compile commands of the Find module do not specify the sysroot always correctly.

Therefore I think it is better to rely on an hdf5-config.cmake if present and therefore use find_package(HDF5 ... NO_MODULE) in OpenMS.

timosachsenberg commented 1 year ago

outdated?

jpfeuffer commented 1 year ago

No