File: cmake_faq.md

package info (click to toggle)
netcdf 1%3A4.4.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 96,828 kB
  • ctags: 15,369
  • sloc: ansic: 163,650; sh: 9,294; yacc: 2,457; makefile: 1,208; lex: 1,161; xml: 173; f90: 7; fortran: 6; awk: 2
file content (69 lines) | stat: -rw-r--r-- 2,579 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
CMake-Related Frequently-Asked-Questions (FAQ) {#cmake_faq}
==============================================

Below are a list of commonly-asked questions regarding NetCDF and CMake.

## How can I see the options available to CMake? {#listoptions}

        $ cmake [path to source tree] -L	- This will show the basic options.
        $ cmake [path to source tree] -LA	- This will show the basic and advanced options.


## How do I specify how to build a shared or static library? {#sharedstatic}

    This is controlled with the internal `cmake` option, `BUILD_SHARED_LIBS`.

        $ cmake [Source Directory] -DBUILD_SHARED_LIBS=[ON/OFF]


## Can I build both shared and static libraries at the same time with cmake? {#sharedstaticboth}

    Not at this time; it is required to instead build first one version, and then the other, if you need both.

    ## What if I want to link against multiple libraries in a non-standard location? {#nonstdloc}

        You can specify the path to search when looking for dependencies and header files using the `CMAKE_PREFIX_PATH` variable:

    * Windows:

            $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=c:\shared\libs\


    * Linux/Unix/OSX:

            $ cmake [Source Directory] -DCMAKE_PREFIX_PATH=/usr/custom_library_locations/		


## How can I specify linking against a particular library? {#partlib}

    It depends on the library.  To specify a custom `ZLib`, for example, you would do the following:

        $ cmake [Source Directory] -DZLIB_LIBRARY=/path/to/my/zlib.lib


    `HDF5` is more complex, since it requires both the `hdf5` and `hdf5_hl` libraries. You would specify custom `HDF5` libraries as follows:

        $ cmake [Source Directory] -DHDF5_LIB=/path/to/hdf5.lib \
            -DHDF5_HL_LIB=/path/to/hdf5_hl.lib \
            -DHDF5_INCLUDE_DIR=/path/to/hdf5/include


    Alternatively, you may specify:

        $ cmake [Source Directory] \
            -DHDF5_LIBRARIES="/path/to/hdf5.lib;/path/to/hdf5_hl.lib" \
            -DHDF5_INCLUDE_DIR=/path/to/hdf5/include/


## How can I specify a Parallel Build using HDF5 {#parallelhdf}

    If cmake is having problems finding the parallel `HDF5` install, you can specify the location manually:


        $ cmake [Source Directory] -DENABLE_PARALLEL=ON \
            -DHDF5_LIB=/usr/lib64/openmpi/lib/libhdf5.so \
            -DHDF5_HL_LIB=/usr/lib64/openmpi/lib/libhdf5.hl.so \
            -DHDF5_INCLUDE_DIR=/usr/include/openmpi-x86_64 \


    You will, of course, need to use the location of the libraries specific to your development environment.