Unidata / netcdf-cxx4

Official GitHub repository for netCDF-C++ libraries and utilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cmake macro ERROR Microsoft Visual Studio generator

doedsjarl666 opened this issue · comments

When trying to build netCDF-cxx4 on WIndows using CMake the following error occurs:
CMake Error at CMakeLists.txt:405 (CHECK_LIBRARY_EXISTS):
CHECK_LIBRARY_EXISTS Macro invoked with incorrect arguments for macro named: CHECK_LIBRARY_EXISTS

The problem lies couple of line prior to that:
400: FIND_PACKAGE(HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS C HL NO_MODULES REQUIRED ${NC_HDF5_LINK_TYPE})
This line implies that find_package() runs in the config mode, thus it will not create variable HDF5_C_LIBRARY_hdf5 that is used in line 405.

I fixed it with using FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED ${NC_HDF5_LINK_TYPE})
at line 400 and changing the name of the HDF5_C_LIBRARY_hdf5 variable to HDF5_C_LIBRARIES
which is actually getting created by FindHDF5.cmake module.

I can confirm this issue as well, on CentOS / Linux.

The CMake Module has no variable HDF5_C_LIBRARY_hdf5. The CMake macro is reporting an error for the incorrect number of arguments due to ${HDF5_C_LIBRARY_hdf5} not existing.

The fix is as @doedsjarl666 says, replace HDF5_C_LIBRARY_hdf5 with HDF5_C_LIBRARIES in the CMakeLists.

I will take a look at this; the Windows HDF5 support stanzas in the C library files should be easy enough to port over to the cxx4 interface. CMake support for the HDF5 libraries are a bit inconsistent by platform.

We are working on getting the new C library release out, which will open the door for the C++ and Fortran releases. Thanks for reporting this, let me see what I can do.