[netcdfgroup] Potential bugs in cmake files for msvc builds with explicit paths to hdf5 .lib files

(I wasn't sure which was the appropriate contact for my report, hence I'm
sending it to support@ as well as the mailing list; apologies if this causes
double mails for some people)

 

Hi,

 

I've been building netcdf 4.4.0 today and I ran into a couple of issues that
I think are bugs in the cmake files. I don't know what the more abstract
build system philosophies are so I took only the required steps to get it to
work for me, but since this prevents me from making automated builds I'd
appreciate it if the maintainers of the build system could suggest and
hopefully even implement a proper fix to be included in future releases
(unless I'm just using everything wrong, in which case I'd appreciate it if
somebody would set me straight.)

 

My situation is msvc14 (= Visual Studio 2015), with HDF5 in a non-standard
location (i.e., no .cmake files availables). According to docs/cmake_faq.md
this can be made to work with some cmake defines, but I ran into the
following issues:

 

- Documentation is wrong on the names of the parameters to pass to cmake:
HDF5_HL_LIB should be HDF5_HL_LIBRARY and HDF5_LIB should be HDF5_C_LIBRARY,
if I look around lines 494 of CMakeLists.txt

- There is an issue with backslashes in those paths; if you try to use
backslashes, cmake fails (thinks it's an escape character). In my batch file
I replaced backslashes with forward slashes; it would be more user-friendly
(imo) if the netcdf cmakefile would do a s|\|/|g itself, as I've found
suggested on some websites to other cmake-based library maintainers.

- Then, in the generated .vcproj, the netcdf4 project file doesn't have
C:\source\vendor\include\HDF5\ (which is what I passed to HDF5_INCLUDE_DIR)
added to its include directories. This seems to be because the cmake file
does INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR}) within the 'else' section that
is only ran when not explicitly setting the above-mentioned variables (i.e.,
only set when the find_package approach is used)

- When linking against hdf5 dynamically, H5_BUILT_AS_DYNAMIC_LIB should be
set as a preprocessor flag, otherwise the HDF5 declspec's will be wrong and
the linker will fail to find the right imports in the .lib.

 

Then finally, and this is more a general question, there doesn't seem to be
a way to pass different hdf5 libraries to release and debug builds? I'd like
to pass hdf5d.lib to debug builds, hdf5.lib to release. For now I make do
with running cmake twice but it would be nice if this would work in one go.

 

Thanks

 

Cheers,

 

Roel

 

  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: