netCDF  4.3.0
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Building-with-CMake.md
1 \page netCDF-CMake Build Instructions for netCDF-C using CMake
2 
3 
4 # Overview
5 
6 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.
7 
8 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.
9 
10 # Requirements
11 The following packages are required to build netCDF-C using CMake.
12 
13 * netCDF-C Source Code
14 * CMake version 2.9+
15 * Optional Requirements:
16  * HDF5 Libraries for netCDF4/HDF5 support.
17  * libcurl for DAP support.
18 
19 <center>
20 <img src="deptree.jpg" height="250px" />
21 </center>
22 
23 # The CMake Build Process
24 
25 There are four steps in the Build Process when using CMake
26 
27 1. Configuration: Before compiling, the software is configured based on the desired options.
28 2. Building: Once configuration is complete, the libraries are compiled.
29 3. Testing: Post-build, it is possible to run tests to ensure the functionality of the netCDF-C libraries.
30 4. Installation: If all tests pass, the libraries can be installed in the location specified during configuration.
31 
32 For users who prefer pre-built binaries, installation packages are available at \ref winbin
33 
34 ## Configuration
35 
36 The output of the configuration step is a project file based on the appropriate configurator specified. Common configurators include:
37 
38 * Unix Makefiles
39 * Visual Studio
40 * CodeBlocks
41 * ... and others
42 
43 ### Common CMake Options
44 
45 | **Option** | **Autotools** | **CMake** |
46 | :------- | :----: | :-----: |
47 Specify Install Location | --prefix=PREFIX | -D"CMAKE\_INSTALL\_PREFIX=PREFIX"
48 Enable/Disable netCDF-4 | --enable-netcdf-4<br>--disable-netcdf-4 | -D"ENABLE\_NETCDF\_4=ON" <br> -D"ENABLE\_NETCDF\_4=OFF"
49 Enable/Disable DAP | --enable-dap <br> --disable-dap | -D"ENABLE\_DAP=ON" <br> -D"ENABLE\_DAP=OFF"
50 Enable/Disable Utilities | --enable-utilities <br> --disable-utilities | -D"BUILD\_UTILITIES=ON" <br> -D"BUILD\_UTILITIES=OFF"
51 Specify shared/Static Libraries | --enable-shared <br> --enable-static | -D"BUILD\_SHARED\_LIBS=ON" <br> -D"BUILD\_SHARED\_LIBS=OFF"
52 Enable/Disable Tests | --enable-testsets <br> --disable-testsets | -D"ENABLE\_TESTS=ON" <br> -D"ENABLE\_TESTS=OFF"
53 
54 ## Building
55 
56 The compiler can be executed directly with 'make' or the appropriate command for the configurator which was used.
57 
58 > \> make
59 
60 Building can also be executed indirectly via cmake:
61 
62 > \> cmake --build [Build Directory]
63 
64 ## Testing
65 
66 Testing can be executed several different ways:
67 
68 > \> make test
69 or
70 > \> ctest
71 or
72 > \> cmake --build [Build Directory] --target test
73 
74 ## Installation
75 
76 Once netCDF has been built and tested, it may be installed using the following commands:
77 
78 > \> make install
79 or
80 > \> cmake --build [Build Directory] --target install

Generated on Tue Jul 9 2013 19:18:05 for netCDF. NetCDF is a Unidata library.