[netcdfgroup] cmake changes

Another thing that needs fixing in the Cmake script

Hdf5 is a bit of a mess regarding the use use of header files
Instead of simply having one “hdf5.h”, there are many and they are scattered all over the place

When using cmake and *NOT* doing an install, there are 3 header files that netCDF needs

From hdf5

In this example %root% is some path

“hdf5.h”
needs
-DHDF5_INCLUDE_DIR=%root%/hdf5/src

Also needed is “H5pubconf.h”
That is generated by cmake
Here in the “build” subfolder because that was the location of the cmake build
-DHAVE_HDF5_H=%root%/hdf5/build

And finally the high level header files

Located in
-DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src

So this new symbol “HDF5_HL_INCLUDE_DIR”
Needs to be added , like this

INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})

Another symbol would be needed for the location of
“H5pubconf.h”

But the script has a “HAVE_HDF5_H” that can be used like this

cmake .. -G "NMake Makefiles" ^
           -DCMAKE_BUILD_TYPE=Debug ^
           -DBUILD_SHARED_LIBS=OFF ^
           -DHDF5_HL_LIBRARY=%root%/hdf5/build/bin/libhdf5_hl_D.lib ^
           -DHDF5_C_LIBRARY=%root%/hdf5/build/bin/libhdf5_D.lib ^
           -DHDF5_INCLUDE_DIR=%root%/hdf5/src ^
           -DZLIB_LIBRARY:FILE=%root%/zlib/build/zlibstaticd.lib ^
           -DZLIB_INCLUDE_DIR:PATH=%root%/zlib ^
           -DHAVE_HDF5_H=%root%/hdf5/build ^
           -DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src ^
           -DCURL_LIBRARY=%root%/curl/build/lib/libcurl-d_imp.lib ^
           -DCURL_INCLUDE_DIR=%root%/curl/include

···

----------------------
Pedro Vicente
http://www.space-research.org/

From: Pedro Vicente
Sent: Thursday, December 28, 2017 1:51 PM
To: netcdfgroup@unidata.ucar.edu
Subject: Re: [netcdfgroup] cmake option NC_USE_STATIC_CRT

this can be fixed if in CMakeLists.txt, you move the definition of

MACRO(specify_static_crt_flag)

before its call at

IF(MSVC)
OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)

could anyone push this fix to the repo?

I am relying on a script that assumes the github versions of the libraries build

thanks

----------------------
Pedro Vicente
http://www.space-research.org/

----- Original Message -----
From: Pedro Vicente
To: netcdfgroup@unidata.ucar.edu
Sent: Thursday, December 28, 2017 1:22 PM
Subject: [netcdfgroup] cmake option NC_USE_STATIC_CRT

I am trying to build a script that clones and builds a series of libraries , including netcdf

On Windows, in a command prompt, I did

git clone GitHub - Unidata/netcdf-c: Official GitHub repository for netCDF-C libraries and utilities.
cd netcdf-c
mkdir build
cd build
cmake .. -DNC_USE_STATIC_CRT=ON

and I get this error
CMake Error at CMakeLists.txt:334 (specify_static_crt_flag):
Unknown CMake command "specify_static_crt_flag".
this is the code called
IF(MSVC)
OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)
IF(NC_USE_STATIC_CRT)
SET(USE_STATIC_CRT ON)
specify_static_crt_flag()
ENDIF()
ENDIF()
"specify_static_crt_flag" is a macro included in CMakeLists.txt
MACRO(specify_static_crt_flag)
so, I'm not sure why this gives that error
thanks
----------------------
Pedro Vicente
http://www.space-research.org/

_______________________________________________
NOTE: All exchanges posted to Unidata maintained email lists are
recorded in the Unidata inquiry tracking system and made publicly
available through the web. Users who post to any of the lists we
maintain are reminded to remove any personal information that they
do not want to be made public.

netcdfgroup mailing list
netcdfgroup@unidata.ucar.edu
For list information or to unsubscribe, visit: Unidata | Support

To test the bug, do on a windows shell

git clone GitHub - nco/nco: netCDF Operators
cd nco/cmake
clone.bat
dep.bat

dep.bat
builds the current netcdf repo using cmake (actually the 4.50 tag) and its dependencies, like hdf5

the cmake build will fail because it cannot find the hdf5 HL headers

···

From: Pedro Vicente
Sent: Friday, December 29, 2017 2:26 PM
To: netcdfgroup@unidata.ucar.edu
Cc: hdf-forum@lists.hdfgroup.org
Subject: Re: [netcdfgroup] cmake changes

Another thing that needs fixing in the Cmake script

Hdf5 is a bit of a mess regarding the use use of header files
Instead of simply having one “hdf5.h”, there are many and they are scattered all over the place

When using cmake and *NOT* doing an install, there are 3 header files that netCDF needs

From hdf5

In this example %root% is some path

“hdf5.h”
needs
-DHDF5_INCLUDE_DIR=%root%/hdf5/src

Also needed is “H5pubconf.h”
That is generated by cmake
Here in the “build” subfolder because that was the location of the cmake build
-DHAVE_HDF5_H=%root%/hdf5/build

And finally the high level header files

Located in
-DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src

So this new symbol “HDF5_HL_INCLUDE_DIR”
Needs to be added , like this

INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})

Another symbol would be needed for the location of
“H5pubconf.h”

But the script has a “HAVE_HDF5_H” that can be used like this

cmake .. -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Debug ^
-DBUILD_SHARED_LIBS=OFF ^
-DHDF5_HL_LIBRARY=%root%/hdf5/build/bin/libhdf5_hl_D.lib ^
-DHDF5_C_LIBRARY=%root%/hdf5/build/bin/libhdf5_D.lib ^
-DHDF5_INCLUDE_DIR=%root%/hdf5/src ^
-DZLIB_LIBRARY:FILE=%root%/zlib/build/zlibstaticd.lib ^
-DZLIB_INCLUDE_DIR:PATH=%root%/zlib ^
-DHAVE_HDF5_H=%root%/hdf5/build ^
-DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src ^
-DCURL_LIBRARY=%root%/curl/build/lib/libcurl-d_imp.lib ^
-DCURL_INCLUDE_DIR=%root%/curl/include

----------------------
Pedro Vicente
http://www.space-research.org/

From: Pedro Vicente
Sent: Thursday, December 28, 2017 1:51 PM
To: netcdfgroup@unidata.ucar.edu
Subject: Re: [netcdfgroup] cmake option NC_USE_STATIC_CRT

this can be fixed if in CMakeLists.txt, you move the definition of

MACRO(specify_static_crt_flag)

before its call at

IF(MSVC)
OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)

could anyone push this fix to the repo?

I am relying on a script that assumes the github versions of the libraries build

thanks

----------------------
Pedro Vicente
http://www.space-research.org/

----- Original Message -----
From: Pedro Vicente
To: netcdfgroup@unidata.ucar.edu
Sent: Thursday, December 28, 2017 1:22 PM
Subject: [netcdfgroup] cmake option NC_USE_STATIC_CRT

I am trying to build a script that clones and builds a series of libraries , including netcdf

On Windows, in a command prompt, I did

git clone GitHub - Unidata/netcdf-c: Official GitHub repository for netCDF-C libraries and utilities.
cd netcdf-c
mkdir build
cd build
cmake .. -DNC_USE_STATIC_CRT=ON

and I get this error
CMake Error at CMakeLists.txt:334 (specify_static_crt_flag):
Unknown CMake command "specify_static_crt_flag".
this is the code called
IF(MSVC)
OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)
IF(NC_USE_STATIC_CRT)
SET(USE_STATIC_CRT ON)
specify_static_crt_flag()
ENDIF()
ENDIF()
"specify_static_crt_flag" is a macro included in CMakeLists.txt
MACRO(specify_static_crt_flag)
so, I'm not sure why this gives that error
thanks
----------------------
Pedro Vicente
http://www.space-research.org/

_______________________________________________
NOTE: All exchanges posted to Unidata maintained email lists are
recorded in the Unidata inquiry tracking system and made publicly
available through the web. Users who post to any of the lists we
maintain are reminded to remove any personal information that they
do not want to be made public.

netcdfgroup mailing list
netcdfgroup@unidata.ucar.edu
For list information or to unsubscribe, visit: Unidata | Support

Hi Pedro,

We understand that this issue is a valid concern. However, because the build directory
is a working space, making the proposed change may introduce errors later on.

This is not an issue that we plan to work on. For a simple solution perform the install step.

-Barbara

···

From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of Pedro Vicente
Sent: Friday, December 29, 2017 1:26 PM
To: netcdfgroup@unidata.ucar.edu
Cc: hdf-forum@lists.hdfgroup.org
Subject: Re: [Hdf-forum] [netcdfgroup] cmake changes

Another thing that needs fixing in the Cmake script

Hdf5 is a bit of a mess regarding the use use of header files
Instead of simply having one “hdf5.h”, there are many and they are scattered all over the place

When using cmake and *NOT* doing an install, there are 3 header files that netCDF needs
From hdf5

In this example %root% is some path

“hdf5.h”
needs
-DHDF5_INCLUDE_DIR=%root%/hdf5/src

Also needed is “H5pubconf.h”
That is generated by cmake
Here in the “build” subfolder because that was the location of the cmake build
-DHAVE_HDF5_H=%root%/hdf5/build

And finally the high level header files

Located in
-DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src

So this new symbol “HDF5_HL_INCLUDE_DIR”
Needs to be added , like this

INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})

Another symbol would be needed for the location of
“H5pubconf.h”

But the script has a “HAVE_HDF5_H” that can be used like this

cmake .. -G "NMake Makefiles" ^
           -DCMAKE_BUILD_TYPE=Debug ^
           -DBUILD_SHARED_LIBS=OFF ^
           -DHDF5_HL_LIBRARY=%root%/hdf5/build/bin/libhdf5_hl_D.lib ^
           -DHDF5_C_LIBRARY=%root%/hdf5/build/bin/libhdf5_D.lib ^
           -DHDF5_INCLUDE_DIR=%root%/hdf5/src ^
           -DZLIB_LIBRARY:FILE=%root%/zlib/build/zlibstaticd.lib ^
           -DZLIB_INCLUDE_DIR:PATH=%root%/zlib ^
           -DHAVE_HDF5_H=%root%/hdf5/build ^
           -DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src ^
           -DCURL_LIBRARY=%root%/curl/build/lib/libcurl-d_imp.lib ^
           -DCURL_INCLUDE_DIR=%root%/curl/include

----------------------
Pedro Vicente
http://www.space-research.org/

From: Pedro Vicente<mailto:pedro.vicente@space-research.org>
Sent: Thursday, December 28, 2017 1:51 PM
To: netcdfgroup@unidata.ucar.edu<mailto:netcdfgroup@unidata.ucar.edu>
Subject: Re: [netcdfgroup] cmake option NC_USE_STATIC_CRT

this can be fixed if in CMakeLists.txt, you move the definition of

MACRO(specify_static_crt_flag)

before its call at

IF(MSVC)
  OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)

could anyone push this fix to the repo?

I am relying on a script that assumes the github versions of the libraries build

thanks

----------------------
Pedro Vicente
http://www.space-research.org/

----- Original Message -----
From: Pedro Vicente<mailto:pedro.vicente@space-research.org>
To: netcdfgroup@unidata.ucar.edu<mailto:netcdfgroup@unidata.ucar.edu>
Sent: Thursday, December 28, 2017 1:22 PM
Subject: [netcdfgroup] cmake option NC_USE_STATIC_CRT

I am trying to build a script that clones and builds a series of libraries , including netcdf

On Windows, in a command prompt, I did

git clone https://github.com/Unidata/netcdf-c
cd netcdf-c
mkdir build
cd build
cmake .. -DNC_USE_STATIC_CRT=ON

and I get this error
CMake Error at CMakeLists.txt:334 (specify_static_crt_flag):
  Unknown CMake command "specify_static_crt_flag".
this is the code called
IF(MSVC)
  OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)
  IF(NC_USE_STATIC_CRT)
    SET(USE_STATIC_CRT ON)
    specify_static_crt_flag()
  ENDIF()
ENDIF()
"specify_static_crt_flag" is a macro included in CMakeLists.txt
MACRO(specify_static_crt_flag)
so, I'm not sure why this gives that error
thanks
----------------------
Pedro Vicente
http://www.space-research.org/

_______________________________________________
NOTE: All exchanges posted to Unidata maintained email lists are
recorded in the Unidata inquiry tracking system and made publicly
available through the web. Users who post to any of the lists we
maintain are reminded to remove any personal information that they
do not want to be made public.

netcdfgroup mailing list
netcdfgroup@unidata.ucar.edu<mailto:netcdfgroup@unidata.ucar.edu>
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/

Hi Barbara
CC netcdf devs

I was not asking that you change the way the header files are located.

This was more of a request to the netcdf group to add this line

INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})

In their Cmakelists.txt file

For the reasons explained

I know that doing an “install” would probably avoid the need for that line

But is it not doing an “install” a valid build of the software?

I think so.
I develop mostly on Windows, and typically I never do an install,
Because I am not a user of the software but a writer.
So, I just need to use the binaries in whatever place they were build,
And not having to copy files to some other place, whatever the reason may be

This is all part of an effort to have a remote automatic way to build NCO in Windows,
Like in AppVeyor

This can be now done with

git clone GitHub - nco/nco: netCDF Operators
cd nco/cmake
clone.bat
bld.bat

If you try this on a Windows Visual Studio x64 command line prompt you will see that you will
Get errors

At the moment the errors can be fixed manually by doing what is explained here

NCO depends on a number of libraries, HDF5 and netCDF being 2 of them

As you can see, changes in the Cmakelists.txt of HDF5 and netCDF are needed

There are 2 separate builds and issues

bld.bat
Builds a Win64 debug non static CRT

bld.bat crt
builds a static CRT build

so, the full laundry list of errors are, and the fix I would like to have in both HDF5 and netCDF CMake are

1)

Netcdf

Add this line

INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})

So that the HDF5 HL folder is detected

2)
Netcdf

MACRO(specify_static_crt_flag)

This function needs to be placed before it’s call

This is a bug

I reported this 2 months ago to the netcdf list, and it was not fixed in 4.6.0

3)

netcdf
Detection of ZLIB and SZIP is wrong, these are not the symbols to look for

  CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_deflate "" HAVE_H5PSET_DEFLATE)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Z_SZIP "" USE_SZIP)

I recently wrote the Cmake script for NCO

This is the correct way to detect ZLIB and SZIP

I don’t have time now to explain this in detail, I will get back to this at another time

Netcdf devs
Are you familiar with AppVeyor?

it provides an automatic way to build /test git commits for Windows
This is something that you should add to detect these things

4)

Netcdf
Just doing a git clone of master and building on Windows fails
I have to checkout to the 4.6.0 tag to build

5)

HDF5

To build with CRT, I have to uncomment this line

edit CMakeLists.txt at root and add for case when static linking of the C Run-time Library (CRT)
INCLUDE(config/cmake/UserMacros/WINDOWS_MT.cmake)

We discussed this 5 years ago on that long forum thread, when I asked to add CRT support
As an option

Why the need to have to uncomment one line in a script just to have an option enabled?

Regards

-Pedro

···

From: Barbara Jones
Sent: Thursday, February 1, 2018 10:56 AM
To: HDF Users Discussion List
Subject: Re: [Hdf-forum] [netcdfgroup] cmake changes

Hi Pedro,

We understand that this issue is a valid concern. However, because the build directory
is a working space, making the proposed change may introduce errors later on.

This is not an issue that we plan to work on. For a simple solution perform the install step.

-Barbara

From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of Pedro Vicente
Sent: Friday, December 29, 2017 1:26 PM
To: netcdfgroup@unidata.ucar.edu
Cc: hdf-forum@lists.hdfgroup.org
Subject: Re: [Hdf-forum] [netcdfgroup] cmake changes

Another thing that needs fixing in the Cmake script

Hdf5 is a bit of a mess regarding the use use of header files
Instead of simply having one “hdf5.h”, there are many and they are scattered all over the place

When using cmake and *NOT* doing an install, there are 3 header files that netCDF needs

From hdf5

In this example %root% is some path

“hdf5.h”
needs
-DHDF5_INCLUDE_DIR=%root%/hdf5/src

Also needed is “H5pubconf.h”
That is generated by cmake
Here in the “build” subfolder because that was the location of the cmake build
-DHAVE_HDF5_H=%root%/hdf5/build

And finally the high level header files

Located in
-DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src

So this new symbol “HDF5_HL_INCLUDE_DIR”
Needs to be added , like this

INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})

Another symbol would be needed for the location of
“H5pubconf.h”

But the script has a “HAVE_HDF5_H” that can be used like this

cmake .. -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Debug ^
-DBUILD_SHARED_LIBS=OFF ^
-DHDF5_HL_LIBRARY=%root%/hdf5/build/bin/libhdf5_hl_D.lib ^
-DHDF5_C_LIBRARY=%root%/hdf5/build/bin/libhdf5_D.lib ^
-DHDF5_INCLUDE_DIR=%root%/hdf5/src ^
-DZLIB_LIBRARY:FILE=%root%/zlib/build/zlibstaticd.lib ^
-DZLIB_INCLUDE_DIR:PATH=%root%/zlib ^
-DHAVE_HDF5_H=%root%/hdf5/build ^
-DHDF5_HL_INCLUDE_DIR=%root%/hdf5/hl/src ^
-DCURL_LIBRARY=%root%/curl/build/lib/libcurl-d_imp.lib ^
-DCURL_INCLUDE_DIR=%root%/curl/include

----------------------
Pedro Vicente
http://www.space-research.org/

From: Pedro Vicente
Sent: Thursday, December 28, 2017 1:51 PM
To: netcdfgroup@unidata.ucar.edu
Subject: Re: [netcdfgroup] cmake option NC_USE_STATIC_CRT

this can be fixed if in CMakeLists.txt, you move the definition of

MACRO(specify_static_crt_flag)

before its call at

IF(MSVC)
OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)

could anyone push this fix to the repo?

I am relying on a script that assumes the github versions of the libraries build

thanks

----------------------
Pedro Vicente
http://www.space-research.org/

----- Original Message -----
From: Pedro Vicente
To: netcdfgroup@unidata.ucar.edu
Sent: Thursday, December 28, 2017 1:22 PM
Subject: [netcdfgroup] cmake option NC_USE_STATIC_CRT

I am trying to build a script that clones and builds a series of libraries , including netcdf

On Windows, in a command prompt, I did

git clone GitHub - Unidata/netcdf-c: Official GitHub repository for netCDF-C libraries and utilities.
cd netcdf-c
mkdir build
cd build
cmake .. -DNC_USE_STATIC_CRT=ON

and I get this error
CMake Error at CMakeLists.txt:334 (specify_static_crt_flag):
Unknown CMake command "specify_static_crt_flag".
this is the code called
IF(MSVC)
OPTION(NC_USE_STATIC_CRT "Use static CRT Libraries ('\\MT')." OFF)
IF(NC_USE_STATIC_CRT)
SET(USE_STATIC_CRT ON)
specify_static_crt_flag()
ENDIF()
ENDIF()
"specify_static_crt_flag" is a macro included in CMakeLists.txt
MACRO(specify_static_crt_flag)
so, I'm not sure why this gives that error
thanks
----------------------
Pedro Vicente
http://www.space-research.org/

_______________________________________________
NOTE: All exchanges posted to Unidata maintained email lists are
recorded in the Unidata inquiry tracking system and made publicly
available through the web. Users who post to any of the lists we
maintain are reminded to remove any personal information that they
do not want to be made public.

netcdfgroup mailing list
netcdfgroup@unidata.ucar.edu
For list information or to unsubscribe, visit: Unidata | Support