a distribution package.
2.9 KiB
\page netCDF-CMake Build Instructions for netCDF-C using CMake
Overview
Starting with netCDF-C 4.3, we are happy to announce the inclusion of CMake support. CMake will allow for building netCDF on a wider range of platforms, include Microsoft Windows with Visual Studio. CMake support also provides robust unit and regression testing tools. We will also maintain the standard autotools-based build system in parallel.
In addition to providing new build options for netCDF-C, we will also provide pre-built binary downloads for the shared versions of netCDF for use with Visual Studio.
Requirements
The following packages are required to build netCDF-C using CMake.
- netCDF-C Source Code
- CMake version 2.9+
- Optional Requirements:
- HDF5 Libraries for netCDF4/HDF5 support.
- libcurl for DAP support.
The CMake Build Process
There are four steps in the Build Process when using CMake
- Configuration: Before compiling, the software is configured based on the desired options.
- Building: Once configuration is complete, the libraries are compiled.
- Testing: Post-build, it is possible to run tests to ensure the functionality of the netCDF-C libraries.
- Installation: If all tests pass, the libraries can be installed in the location specified during configuration.
For users who prefer pre-built binaries, installation packages are available at \ref winbin
Configuration
The output of the configuration step is a project file based on the appropriate configurator specified. Common configurators include:
- Unix Makefiles
- Visual Studio
- CodeBlocks
- ... and others
Common CMake Options
Option | Autotools | CMake |
---|---|---|
Specify Install Location | --prefix=PREFIX | -D"CMAKE_INSTALL_PREFIX=PREFIX" |
Enable/Disable netCDF-4 | --enable-netcdf-4 --disable-netcdf-4 |
-D"ENABLE_NETCDF_4=ON" -D"ENABLE_NETCDF_4=OFF" |
Enable/Disable DAP | --enable-dap --disable-dap |
-D"ENABLE_DAP=ON" -D"ENABLE_DAP=OFF" |
Enable/Disable Utilities | --enable-utilities --disable-utilities |
-D"BUILD_UTILITIES=ON" -D"BUILD_UTILITIES=OFF" |
Specify shared/Static Libraries | --enable-shared --enable-static |
-D"BUILD_SHARED_LIBS=ON" -D"BUILD_SHARED_LIBS=OFF" |
Enable/Disable Tests | --enable-testsets --disable-testsets |
-D"ENABLE_TESTS=ON" -D"ENABLE_TESTS=OFF" |
Building
The compiler can be executed directly with 'make' or the appropriate command for the configurator which was used.
> make
Building can also be executed indirectly via cmake:
> cmake --build [Build Directory]
Testing
Testing can be executed several different ways:
> make test or > ctest or > cmake --build [Build Directory] --target test
Installation
Once netCDF has been built and tested, it may be installed using the following commands:
> make install or > cmake --build [Build Directory] --target install