Resolved 2 Issue preventing CMake netcdf-cxx4 build on MacOS.
Trying to build latest HDF5, NetCDF-c, and then NetCDF-cxx4 from source on macOS Mojave using cmake version 3.17.2, hdf5 1.13.0 at 88a39adaa, and netcdf-c 4.8.0 at c2ea69df.
With NetCDF-cxx4, first issue:
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DHDF5_DIR=/usr/local/HDF_Group/HDF5/1.13.0/share/cmake/hdf5/ ..
[...]
-- Found HDF5: hdf5-shared (found version "1.13.0") found components: C HL
CMake Error at CMakeLists.txt:415 (CHECK_LIBRARY_EXISTS):
CHECK_LIBRARY_EXISTS Macro invoked with incorrect arguments for macro
named: CHECK_LIBRARY_EXISTS
-- Plugin support requires libhdf5 with H5Free support. Your libhdf5 install does not provide H5Free. Please install a newer version of libhdf5 if you require plugin compression support.
[...]
-- Configuring incomplete, errors occurred!
Attributed to blank variable HDF5_C_LIBRARY_hdf5 in CMakeLists.txt. The FIND_PACKAGE(HDF5... call [1] sets HDF5_C_LIBRARIES. Looks like this snippet might have been copied from the NetCDF-c cmake, but the part that actually sets HDF5_C_LIBRARY_hdf5 from HDF5_C_LIBRARIES was omitted? Solution, modify HDF5_C_LIBRARY_hdf5 -> HDF5_C_LIBRARIES.
Build gets a little further, but gets stuck with error:
[...]
CMake Error in cxx4/CMakeLists.txt:
Target "netcdf-cxx4" INTERFACE_INCLUDE_DIRECTORIES property contains path:
"/full/path/to/netcdf-cxx4/cxx4/"
which is prefixed in the source directory.
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
Finally tracked this down to the line above in cxx4/CMakeLists.txt referring to empty variable HDF5_C_INCLUDE_DIRS. Again FindHDF5 [1] sets HDF5_INCLUDE_DIRS, so changing HDF5_C_INCLUDE_DIRS -> HDF5_INCLUDE_DIRS seems to fix. Interestingly, compilation and tests pass even removing that line. Is that line necessary?
Resolved 2 Issue preventing CMake netcdf-cxx4 build on MacOS.
Trying to build latest HDF5, NetCDF-c, and then NetCDF-cxx4 from source on macOS Mojave using cmake version 3.17.2, hdf5 1.13.0 at 88a39adaa, and netcdf-c 4.8.0 at c2ea69df.
With NetCDF-cxx4, first issue:
Attributed to blank variable
HDF5_C_LIBRARY_hdf5
in CMakeLists.txt. TheFIND_PACKAGE(HDF5...
call [1] setsHDF5_C_LIBRARIES
. Looks like this snippet might have been copied from the NetCDF-c cmake, but the part that actually setsHDF5_C_LIBRARY_hdf5
fromHDF5_C_LIBRARIES
was omitted? Solution, modifyHDF5_C_LIBRARY_hdf5
->HDF5_C_LIBRARIES
.Build gets a little further, but gets stuck with error:
Using [2] [3]:
Finally tracked this down to the line above in cxx4/CMakeLists.txt referring to empty variable
HDF5_C_INCLUDE_DIRS
. Again FindHDF5 [1] setsHDF5_INCLUDE_DIRS
, so changingHDF5_C_INCLUDE_DIRS
->HDF5_INCLUDE_DIRS
seems to fix. Interestingly, compilation and tests pass even removing that line. Is that line necessary?Thanks!
[1] https://cmake.org/cmake/help/v3.0/module/FindHDF5.html [2] https://cmake.org/cmake/help/latest/module/CMakePrintHelpers.html [3] https://cmake.org/cmake/help/latest/command/variable_watch.html