Build hints (cmake)

Build requirements

The minimum requirements are:

  • CMake >= 3.10, and an associated build system (make, ninja, Visual Studio, etc.)

  • C99 compiler

  • C++11 compiler

  • PROJ >= 6.0

But a number of optional libraries are also strongly recommended for most builds: SQLite3, expat, libcurl, zlib, libtiff, libgeotiff, libpng, libjpeg, etc.

CMake

With the CMake build system you can compile and install GDAL on more or less any platform. After unpacking the source distribution archive step into the source- tree:

cd gdal-{VERSION}

Create a build directory and step into it:

mkdir build
cd build

From the build directory you can now configure CMake, build and install the binaries:

cmake ..
cmake --build .
cmake --build . --target install

On Windows, one may need to specify generator:

cmake -G "Visual Studio 15 2017" ..

If a dependency is installed in a custom location, specify the paths to the include directory and the library:

cmake -DSQLITE3_INCLUDE_DIR=/opt/SQLite/include -DSQLITE3_LIBRARY=/opt/SQLite/lib/libsqlite3.so ..

Alternatively, a custom prefix can be specified:

cmake -DCMAKE_PREFIX_PATH=/opt/SQLite ..

You can unset existing cached variables, by using the -U switch of cmake, for example with wildcards:

cmake .. -UGDAL_USE_*

You can assemble dependency settings in a file ConfigUser.cmake and use it with the -C option. The file contains set() commands that use the CACHE option. You can set for example a different name for the shared lib, e.g. set (GDAL_LIB_OUTPUT_NAME gdal_x64 CACHE STRING "" FORCE):

cmake .. -C ConfigUser.cmake

Warning

When iterating to configure GDAL to add/modify/remove dependencies, some cache variables can remain in CMakeCache.txt from previous runs, and conflict with new settings. If strange errors appear during cmake run, you may try removing CMakeCache.txt to start from a clean state.

CMake general configure options

Options to configure a CMake are provided using -D<var>=<value>. All cached entries can be viewed using cmake -LAH from a build directory.

BUILD_APPS=ON

Build applications. Default is ON.

BUILD_SHARED_LIBS

Build GDAL library shared. Default is ON. See also the CMake documentation for BUILD_SHARED_LIBS.

CMAKE_BUILD_TYPE

Choose the type of build, options are: None (default), Debug, Release, RelWithDebInfo, or MinSizeRel. See also the CMake documentation for CMAKE_BUILD_TYPE.

Note

A default build is not optimized without specifying -DCMAKE_BUILD_TYPE=Release (or similar) during configuration, or by specifying --config Release with CMake multi-configuration build tools (see example below).

CMAKE_C_COMPILER

C compiler. Ignored for some generators, such as Visual Studio.

CMAKE_C_FLAGS

Flags used by the C compiler during all build types. This is initialized by the CFLAGS environment variable.

CMAKE_CXX_COMPILER

C++ compiler. Ignored for some generators, such as Visual Studio.

CMAKE_CXX_FLAGS

Flags used by the C++ compiler during all build types. This is initialized by the CXXFLAGS environment variable.

CMAKE_INSTALL_PREFIX

Where to install the software. Default for Unix-like is /usr/local/.

CMAKE_PREFIX_PATH

List of directories specifying installation prefixes to be searched when external dependencies are looked for.

Starting with CMake 3.12, it is also possible to use a <Packagename>_ROOT variable to define the prefix for a particular package. See https://cmake.org/cmake/help/latest/release/3.12.html?highlight=root#commands

ENABLE_IPO=OFF

Build library using the compiler’s interprocedural optimization (IPO), if available, default OFF.

GDAL_SET_INSTALL_RELATIVE_RPATH=OFF

Set to ON so that the rpath of installed binaries is written as a relative path to the library. This option overrides the CMAKE_INSTALL_RPATH variable, and assumes that the CMAKE_SKIP_INSTALL_RPATH variable is not set.

CMake package dependent options

Generally speaking, packages (external dependencies) will be automatically found if they are in default locations used by CMake. This can be also tuned for example with the CMAKE_PREFIX_PATH variable.

Starting with CMake 3.12, it is also possible to use a <Packagename>_ROOT variable to define the prefix for a particular package. See https://cmake.org/cmake/help/latest/release/3.12.html?highlight=root#commands Note that the case of the package name matters for the _ROOT, _INCLUDE_DIR and _LIBRARY variables.

Most dependencies that would be found can also be disabled by setting the following option:

GDAL_USE_<Packagename_in_upper_case>:BOOL=ON/OFF

Control whether a found dependency can be used for the GDAL build.

It is also possible to ask GDAL to disable the use of any external dependency (besides the required one, PROJ) by default by setting the following option to OFF. Individual libraries shall then be enabled explicitly with GDAL_USE_<Packagename_in_upper_case>:BOOL=ON.

GDAL_USE_EXTERNAL_LIBS:BOOL=ON/OFF

Defaults to ON. When set to OFF, all external dependencies (but mandatory ones) will be disabled, unless individually enabled with GDAL_USE_<Packagename_in_upper_case>:BOOL=ON. This option should be set before CMakeCache.txt is created. If it is set to OFF after CMakeCache.txt is created, then cmake should be reinvoked with “-UGDAL_USE_*” to cancel the activation of previously detected libraries.

Some of the GDAL dependencies (GEOTIFF, GIF, JPEG, JSONC, LERC, OPENCAD, PNG, QHULL, TIFF, ZLIB) have a copy of their source code inside the GDAL source code tree. It is possible to enable this internal copy by setting the GDAL_USE_<Packagename_in_upper_case>_INTERNAL:BOOL=ON variable. When set, this has precedence over the external library that may be detected. The behavior can also be globally controlled with the following variable:

GDAL_USE_INTERNAL_LIBS=ON/OFF/WHEN_NO_EXTERNAL

Control how internal libraries should be used. If set to ON, they will always be used. If set to OFF, they will never be used (unless individually enabled with GDAL_USE_<Packagename_in_upper_case>_INTERNAL:BOOL=ON) If set to WHEN_NO_EXTERNAL (default value), they will be used only if no corresponding external library is found and enabled. This option should be set before CMakeCache.txt is created.

Armadillo

The Armadillo C++ library is used to speed up computations related to the Thin Plate Spline transformer. See https://cmake.org/cmake/help/latest/module/FindArmadillo.html for details. On Windows builds using Conda-Forge dependencies, the following packages may also need to be installed: blas blas-devel libblas libcblas liblapack liblapacke

GDAL_USE_ARMADILLO=ON/OFF

Control whether to use Armadillo. Defaults to ON when Armadillo is found.

Arrow

The Apache Arrow C++ <https://github.com/apache/arrow/tree/master/cpp> library is required for the (Geo)Arrow IPC File Format / Stream and (Geo)Parquet drivers. Specify install prefix in the CMAKE_PREFIX_PATH variable.

GDAL_USE_ARROW=ON/OFF

Control whether to use Arrow. Defaults to ON when Arrow is found.

Blosc

Blosc is a library which offers a meta-compression, with different backends (LZ4, Snappy, Zlib, Zstd, etc.). It is used by the Zarr driver.

BLOSC_INCLUDE_DIR

Path to an include directory with the blosc.h header file.

BLOSC_LIBRARY

Path to a shared or static library file.

GDAL_USE_BLOSC=ON/OFF

Control whether to use Blosc. Defaults to ON when Blosc is found.

BRUNSLI

The Brunsli <https://github.com/google/brunsli> JPEG repacking library, used by the MRF – Meta Raster Format driver.

BRUNSLI_INCLUDE_DIR

Path to an include directory with the brunsli/decode.h and brunsli\encode.h header files.

BRUNSLI_ENC_LIB

Path to the brunslienc-c library file.

BRUNSLI_DEC_LIB

Path to the brunslidec-c library file.

GDAL_USE_BRUNSLI=ON/OFF

Control whether to use BRUNSLI. Defaults to ON when Brunsli is found.

CFITSIO

The C FITS I/O library is required for the FITS – Flexible Image Transport System driver. It can be detected with pkg-config.

CFITSIO_INCLUDE_DIR

Path to an include directory with the fitsio.h header file.

CFITSIO_LIBRARY

Path to a shared or static library file.

GDAL_USE_CFITSIO=ON/OFF

Control whether to use CFITSIO. Defaults to ON when CFITSIO is found.

Crnlib

Crnlib / crunch is required for the DDS – DirectDraw Surface driver.

Crnlib_INCLUDE_DIR

Path to Crnlib include directory with crunch/crnlib.h header.

Crnlib_LIBRARY

Path to Crnlib library to be linked.

GDAL_USE_CRNLIB=ON/OFF

Control whether to use Crnlib. Defaults to ON when Crnlib is found.

CURL

libcurl is required for all network accesses (HTTP, etc.).

CURL_INCLUDE_DIR

Path to an include directory with the curl directory.

CURL_LIBRARY_RELEASE

Path to a shared or static library file, such as libcurl.dll, libcurl.so, libcurl.lib, or other name.

GDAL_USE_CURL=ON/OFF

Control whether to use Curl. Defaults to ON when Curl is found.

CryptoPP

The Crypto++ library can be used for the RSA SHA256 signing functionality used by some authentication methods of Google Cloud. It might be required to use the EEDAI - Google Earth Engine Data API Image images or use the /vsigs/ virtual file system. It is also required for the /vsicrypt/ virtual file system.

CRYPTOPP_INCLUDE_DIR

Path to the base include directory.

CRYPTOPP_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable CRYPTOPP_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

CRYPTOPP_USE_ONLY_CRYPTODLL_ALG=ON/OFF

Defaults to OFF. Might be required to set to ON when linking against cryptopp.dll

GDAL_USE_CRYPTOPP=ON/OFF

Control whether to use CryptoPP. Defaults to ON when CryptoPP is found.

Deflate

libdeflate is a compression library which offers the lossless Deflate/Zip compression algorithm. It offers faster performance than ZLib, but is not a full replacement for it, consequently it must be used as a complement to ZLib.

Deflate_INCLUDE_DIR

Path to an include directory with the libdeflate.h header file.

Deflate_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable Deflate_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_DEFLATE=ON/OFF

Control whether to use Deflate. Defaults to ON when Deflate is found.

ECW

The Hexagon ECW SDK (closed source/proprietary) is required for the ECW – Enhanced Compressed Wavelets (.ecw) driver. Currently only support for ECW SDK 3.3 and 5.5 is offered.

For ECW SDK 5.5, ECW_ROOT or CMAKE_PREFIX_PATH should point to the directory into which there are include and lib subdirectories, typically ending with ERDAS-ECW_JPEG_2000_SDK-5.5.0/Desktop_Read-Only.

ECW_INCLUDE_DIR

Path to the include directory with the NCSECWClient.h header file.

ECW_LIBRARY

Path to library file libNCSEcw

ECWnet_LIBRARY

Path to library file libNCSCnet (only needed for SDK 3.3)

ECWC_LIBRARY

Path to library file libNCSEcwC (only needed for SDK 3.3)

NCSUtil_LIBRARY

Path to library file libNCSUtil (only needed for SDK 3.3)

GDAL_USE_ECW=ON/OFF

Control whether to use ECW. Defaults to ON when ECW is found.

EXPAT

Expat is a stream-oriented XML parser library which is required to enable XML parsing capabilities in an important number of OGR drivers (GML, GeoRSS, GPX, KML, LVBAG, OSM, ODS, SVG, WFS, XSLX, etc.). It is strongly recommended. Other driver such as ILI or GMLAS may also require the XercesC library.

EXPAT_INCLUDE_DIR

Path to the include directory with the expat.h header file.

EXPAT_LIBRARY

Path to a shared or static library file.

GDAL_USE_EXPAT=ON/OFF

Control whether to use EXPAT. Defaults to ON when EXPAT is found.

FileGDB

The FileGDB SDK (closed source/proprietary) is required for the ESRI File Geodatabase (FileGDB) driver (not to be confused with the ESRI File Geodatabase (OpenFileGDB) driver that has no external requirements)

FileGDB_ROOT or CMAKE_PREFIX_PATH should point to the directory of the SDK.

FileGDB_INCLUDE_DIR

Path to the include directory with the FileGDBAPI.h header file.

FileGDB_LIBRARY

Path to library file

FileGDB_LIBRARY_RELEASE

Path to Release library file (only used on Windows)

FileGDB_LIBRARY_DEBUG

Path to Debug library file (only used on Windows)

GDAL_USE_FILEGDB=ON/OFF

Control whether to use FileGDB. Defaults to ON when FileGDB is found.

FreeXL

The FreeXL library is required for the XLS - MS Excel format driver.

FREEXL_INCLUDE_DIR

Path to an include directory with the freexl.h header file.

FREEXL_LIBRARY

Path to a shared or static library file.

GDAL_USE_FREEXL=ON/OFF

Control whether to use FreeXL. Defaults to ON when FreeXL is found.

FYBA

The OpenFyba libraries are needed to build the Norwegian SOSI Standard driver.

FYBA_INCLUDE_DIR

Path to an include directory with the fyba.h header file.

FYBA_FYBA_LIBRARY

Path to a library file fyba

FYBA_FYGM_LIBRARY

Path to a library file fygm

FYBA_FYUT_LIBRARY

Path to a library file fyut

GDAL_USE_FYBA=ON/OFF

Control whether to use FYBA. Defaults to ON when FYBA is found.

GEOTIFF

It is required for the GTiff – GeoTIFF File Format drivers, and a few other drivers. If not found, an internal copy of libgeotiff can be used.

GEOTIFF_INCLUDE_DIR

Path to an include directory with the libgeotiff header files.

GEOTIFF_LIBRARY_RELEASE

Path to a shared or static library file, such as geotiff.dll, libgeotiff.so, geotiff.lib, or other name. A similar variable GEOTIFF_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_GEOTIFF=ON/OFF

Control whether to use external libgeotiff. Defaults to ON when external libgeotiff is found.

GDAL_USE_GEOTIFF_INTERNAL=ON/OFF

Control whether to use internal libgeotiff copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_GEOTIFF=ON

GEOS

GEOS is a C++ library for performing operations on two-dimensional vector geometries. It is used as the backend for most geometry processing operations available in OGR (intersection, buffer, etc.). The geos-config program can be used to detect it.

GEOS_INCLUDE_DIR

Path to an include directory with the geos_c.h header file.

GEOS_LIBRARY

Path to a shared or static library file (libgeos_c).

GDAL_USE_GEOS=ON/OFF

Control whether to use GEOS. Defaults to ON when GEOS is found.

GIF

giflib is required for the GIF – Graphics Interchange Format driver. If not found, an internal copy can be used.

GIF_INCLUDE_DIR

Path to an include directory with the gif_lib.h header file.

GIF_LIBRARY

Path to a shared or static library file.

GDAL_USE_GIF=ON/OFF

Control whether to use external giflib. Defaults to ON when external giflib is found.

GDAL_USE_GIF_INTERNAL=ON/OFF

Control whether to use internal giflib copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_GIF=ON

GTA

The GTA library is required for the GTA - Generic Tagged Arrays driver.

GTA_INCLUDE_DIR

Path to an include directory with the gta/gta.h header file.

GTA_LIBRARY

Path to a shared or static library file.

GDAL_USE_GTA=ON/OFF

Control whether to use GTA. Defaults to ON when GTA is found.

HEIF

The HEIF (>= 1.1) library used by the HEIF / HEIC – ISO/IEC 23008-12:2017 High Efficiency Image File Format driver. It can be detected with pkg-config.

HEIF_INCLUDE_DIR

Path to an include directory with the libheif/heif.h header file.

HEIF_LIBRARY

Path to a shared or static library file.

GDAL_USE_HEIF=ON/OFF

Control whether to use HEIF. Defaults to ON when HEIF is found.

HDF4

The HDF4 C library is needed for the HDF4 – Hierarchical Data Format Release 4 (HDF4) driver.

HDF4_INCLUDE_DIR

Path to an include directory with the hdf.h header file.

HDF4_df_LIBRARY_RELEASE

Path to a shared or static dfalt or df library file. A similar variable HDF4_df_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

HDF4_mfhdf_LIBRARY_RELEASE

Path to a shared or static mfhdfalt or mfhdf library file. A similar variable HDF4_mfhdf_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

HDF4_xdr_LIBRARY_RELEASE

Path to a shared or static xdr library file. A similar variable HDF4_xdr_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases. It is generally not needed for Linux builds

HDF4_szip_LIBRARY_RELEASE

Path to a shared or static szip library file. A similar variable HDF4_szip_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases. It is generally not needed for Linux builds

HDF4_COMPONENTS

The value of this option is a list which defaults to df;mfhdf;xdr;szip. It may be customized if the linking of HDF4 require different libraries, in which case HDF4_{comp_name}_LIBRARY_[RELEASE/DEBUG] variables will be available to configure the library file.

GDAL_USE_HDF4=ON/OFF

Control whether to use HDF4. Defaults to ON when HDF4 is found.

HDF5

The HDF5 C library is needed for the HDF5 – Hierarchical Data Format Release 5 (HDF5) and BAG – Bathymetry Attributed Grid drivers. The HDF5 CXX library is needed for the KEA driver. The https://cmake.org/cmake/help/latest/module/FindHDF5.html module is used to detect the HDF5 library.

GDAL_USE_HDF5=ON/OFF

Control whether to use HDF5. Defaults to ON when HDF5 is found.

HDFS

The Hadoop File System native library is needed for the /vsihdfs/ virtual file system.

HDFS_INCLUDE_DIR

Path to an include directory with the hdfs.h header file.

HDFS_LIBRARY

Path to a shared or static hdfs library file.

GDAL_USE_HDFS=ON/OFF

Control whether to use HDFS. Defaults to ON when HDFS is found.

Iconv

The Iconv library is used to convert text from one encoding to another encoding. It is generally available as a system library for Unix-like systems. On Windows, GDAL can leverage the API of the operating system for a few base conversions, but using Iconv will provide additional capabilities.

Iconv_INCLUDE_DIR

Path to an include directory with the iconv.h header file.

Iconv_LIBRARY

Path to a shared or static library file.

GDAL_USE_ICONV=ON/OFF

Control whether to use Iconv. Defaults to ON when Iconv is found.

IDB

The Informix DataBase Client SDK (closed source/proprietary) is needed to build the IDB driver. IDB_ROOT or CMAKE_PREFIX_PATH should point to the directory of the SDK.

IDB_INCLUDE_DIR

Path to an include directory (typically ending with incl) with the c++/it.h header file.

IDB_IFCPP_LIBRARY

Path to a library file ifc++ (typically in the lib/c++ sub directory)

IDB_IFDMI_LIBRARY

Path to a library file ifdmi (typically in the lib/dmi sub directory)

IDB_IFSQL_LIBRARY

Path to a library file ifsql (typically in the lib/esql sub directory)

IDB_IFCLI_LIBRARY

Path to a library file ifcli (typically in the lib/cli sub directory)

GDAL_USE_IDB=ON/OFF

Control whether to use IDB. Defaults to ON when IDB is found.

JPEG

libjpeg is required for the JPEG – JPEG JFIF File Format driver, and may be used by a few other drivers (GPKG – GeoPackage raster, MRF – Meta Raster Format, internal libtiff, etc.) If not found, an internal copy of libjpeg (6b) can be used. Using libjpeg-turbo is highly recommended to get best performance. See https://cmake.org/cmake/help/latest/module/FindJPEG.html for more details on how the library is detected.

Note

When using libjpeg-turbo, JPEG_LIBRARY[_RELEASE/_DEBUG] should point to a library with libjpeg ABI, not TurboJPEG. See https://libjpeg-turbo.org/About/TurboJPEG for the difference.

JPEG_INCLUDE_DIR

Path to an include directory with the jpeglib.h header file.

JPEG_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable JPEG_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_JPEG=ON/OFF

Control whether to use external libjpeg. Defaults to ON when external libjpeg is found.

GDAL_USE_JPEG_INTERNAL=ON/OFF

Control whether to use internal libjpeg copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_JPEG=ON

JPEG12

libjpeg-12 bit can be used by the JPEG – JPEG JFIF File Format, GTiff – GeoTIFF File Format (when using internal libtiff), JPEG – JPEG JFIF File Format, MRF – Meta Raster Format and NITF – National Imagery Transmission Format drivers to handle JPEG images with a 12 bit depth. It is only supported with the internal libjpeg (6b). This can be used independently of if for regular 8 bit JPEG an external or internal libjpeg is used.

GDAL_USE_JPEG12_INTERNAL=ON/OFF

Control whether to use internal libjpeg-12 copy. Defaults to ON.

JSON-C

The json-c library is required to read and write JSON content. It can be detected with pkg-config. If not found, an internal copy of json-c can be used.

JSONC_INCLUDE_DIR

Path to an include directory with the json.h header file.

JSONC_LIBRARY

Path to a shared or static library file.

GDAL_USE_JSONC=ON/OFF

Control whether to use JSON-C. Defaults to ON when JSON-C is found.

GDAL_USE_JSONC_INTERNAL=ON/OFF

Control whether to use internal JSON-C copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_JSONC=ON

JXL

The libjxl <https://github.com/libjxl/libjxl> library used by the GTiff – GeoTIFF File Format driver, when built against internal libtiff. It can be detected with pkg-config.

JXL_INCLUDE_DIR

Path to an include directory with the jxl/decode.h header file.

JXL_LIBRARY

Path to a shared or static library file.

GDAL_USE_JXL=ON/OFF

Control whether to use JXL. Defaults to ON when JXL is found.

KDU

The Kakadu library (proprietary) is required for the JP2KAK – JPEG-2000 (based on Kakadu) and JPIPKAK - JPIP Streaming drivers. There is no standardized installation layout, nor fixed library file names, so finding Kakadu artifacts is a bit challenging. Currently automatic finding of it from the KDU_ROOT variable is only implemented for Linux, Mac and Windows x86_64 builds. For other platforms, users need to manually specify the KDU_LIBRARY and KDU_AUX_LIBRARY variable.

KDU_INCLUDE_DIR

Path to the root of the Kakadu build tree, from which the coresys/common/kdu_elementary.h header file should be found.

KDU_LIBRARY

Path to a shared library file whose name is like libkdu_vXYR.so on Unix or kdu_vXYR.lib on Windows, where X.Y is the Kakadu version.

KDU_AUX_LIBRARY

Path to a shared library file whose name is like libkdu_aXYR.so on Unix or kdu_aXYR.lib on Windows, where X.Y is the Kakadu version.

GDAL_USE_KDU=ON/OFF

Control whether to use KDU. Defaults to ON when KDU is found.

KEA

The KEA library is required for the KEA driver. The HDF5 CXX library is also required.

KEA_INCLUDE_DIR

Path to an include directory with the libkea/KEACommon.h header file.

KEA_LIBRARY

Path to a shared or static library file.

GDAL_USE_KEA=ON/OFF

Control whether to use KEA. Defaults to ON when KEA is found.

LERC

LERC is an open-source image or raster format which supports rapid encoding and decoding for any pixel type (not just RGB or Byte). Users set the maximum compression error per pixel while encoding, so the precision of the original input image is preserved (within user defined error bounds).

LERC_INCLUDE_DIR

Path to an include directory with the Lerc_c_api.h header file.

LERC_LIBRARY

Path to a shared or static library file.

GDAL_USE_LERC=ON/OFF

Control whether to use LERC. Defaults to ON when LERC is found.

GDAL_USE_LERC_INTERNAL=ON/OFF

Control whether to use the LERC internal library. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_LERC=ON

LibKML

LibKML is required for the LIBKML Driver (.kml .kmz) driver. It can be detected with pkg-config.

LIBKML_INCLUDE_DIR

Path to the base include directory.

LIBKML_BASE_LIBRARY

Path to a shared or static library file for kmlbase

LIBKML_DOM_LIBRARY

Path to a shared or static library file for kmldom

LIBKML_ENGINE_LIBRARY

Path to a shared or static library file for kmlengine

GDAL_USE_LIBKML=ON/OFF

Control whether to use LibKML. Defaults to ON when LibKML is found.

LibLZMA

LibLZMA is a compression library which offers the lossless LZMA2 compression algorithm. It is used by the internal libtiff library or the Zarr driver.

LIBLZMA_INCLUDE_DIR

Path to an include directory with the lzma.h header file.

LIBLZMA_LIBRARY

Path to a shared or static library file.

GDAL_USE_LIBLZMA=ON/OFF

Control whether to use LibLZMA. Defaults to ON when LibLZMA is found.

LibXml2

The LibXml2 processing library is used to do validation of XML files against a XML Schema (.xsd) in a few drivers (PDF, GMLAS, GML OGR VRT) and for advanced capabilities in GMLJP2v2 generation.

LIBXML2_INCLUDE_DIR

Path to the base include directory.

LIBXML2_LIBRARY

Path to a shared or static library file.

GDAL_USE_LIBXML2=ON/OFF

Control whether to use LibXml2. Defaults to ON when LibXml2 is found.

LURATECH

The Luratech JPEG2000 SDK (closed source/proprietary) is required for the JP2Lura – JPEG2000 driver based on Lurawave library driver.

LURATECH_ROOT or CMAKE_PREFIX_PATH should point to the directory of the SDK.

LURATECH_INCLUDE_DIR

Path to the include directory with the lwf_jp2.h header file.

LURATECH_LIBRARY

Path to library file lib_lwf_jp2.a / lwf_jp2.lib

GDAL_USE_LURATECH=ON/OFF

Control whether to use LURATECH. Defaults to ON when LURATECH is found.

LZ4

LZ4 is a compression library which offers the lossless LZ4 compression algorithm. It is used by the Zarr driver.

LZ4_INCLUDE_DIR

Path to an include directory with the lz4.h header file.

LZ4_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable LZ4_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_LZ4=ON/OFF

Control whether to use LZ4. Defaults to ON when LZ4 is found.

MONGOCXX

The MongoCXX and BsonCXX libraries are needed to build the MongoDBv3 driver. They can be detected with pkg-config.

MONGOCXX_INCLUDE_DIR

Path to an include directory with the mongocxx/client.hpp header file.

BSONCXX_INCLUDE_DIR

Path to an include directory with the bsoncxx/config/version.hpp header file.

MONGOCXX_LIBRARY

Path to a library file mongocxx

BSONCXX_LIBRARY

Path to a library file bsoncxx

GDAL_USE_MONGOCXX=ON/OFF

Control whether to use MONGOCXX. Defaults to ON when MONGOCXX is found.

MRSID

The MRSID Raster DSDK (closed source/proprietary) is required for the MrSID – Multi-resolution Seamless Image Database driver.

MRSID_ROOT or CMAKE_PREFIX_PATH should point to the directory of the SDK ending with Raster_DSDK. Note that on Linux, its lib subdirectory should be in the LD_LIBRARY_PATH so that the linking of applications succeeds and libtbb.so can be found.

MRSID_INCLUDE_DIR

Path to the include directory with the lt_base.h header file.

MRSID_LIBRARY

Path to library file libltidsdk

GDAL_ENABLE_DRIVER_JP2MRSID

Whether to enable JPEG2000 support through the MrSID SDK. The default value of this option is OFF.

GDAL_USE_MRSID=ON/OFF

Control whether to use MRSID. Defaults to ON when MRSID is found.

MSSQL_NCLI

The Microsoft SQL Native Client Library (closed source/proprietary) is required to enable bulk copy in the MSSQLSpatial - Microsoft SQL Server Spatial Database driver. If both MSSQL_NCLI and MSSQL_ODBC are found and enabled, MSSQL_ODBC will be used. The library is normally found if installed in standard location, and at version 11.

MSSQL_NCLI_VERSION

Major version of the Native Client, typically 11

MSSQL_NCLI_INCLUDE_DIR

Path to include directory with sqlncli.h header.

MSSQL_NCLI_LIBRARY

Path to library to be linked.

GDAL_USE_MSSQL_NCLI=ON/OFF

Control whether to use MSSQL_NCLI. Defaults to ON when MSSQL_NCLI is found.

MSSQL_ODBC

The Microsoft SQL Native ODBC driver Library (closed source/proprietary) is required to enable bulk copy in the MSSQLSpatial - Microsoft SQL Server Spatial Database driver. If both MSSQL_NCLI and MSSQL_ODBC are found and enabled, MSSQL_ODBC will be used. The library is normally found if installed in standard location, and at version 17.

MSSQL_ODBC_VERSION

Major version of the Native Client, typically 17

MSSQL_ODBC_INCLUDE_DIR

Path to include directory with msodbcsql.h header.

MSSQL_ODBC_LIBRARY

Path to library to be linked.

GDAL_USE_MSSQL_ODBC=ON/OFF

Control whether to use MSSQL_ODBC. Defaults to ON when MSSQL_ODBC is found.

MYSQL

The MySQL or MariaDB client library is required to enable the MySQL driver.

MYSQL_INCLUDE_DIR

Path to include directory with mysql.h header file.

MYSQL_LIBRARY

Path to library to be linked.

GDAL_USE_MYSQL=ON/OFF

Control whether to use MYSQL. Defaults to ON when MYSQL is found.

NetCDF

The netCDF is required to enable the NetCDF: Network Common Data Form driver. The nc-config program can be used to detect it.

NETCDF_INCLUDE_DIR

Path to an include directory with the netcdf.h header file.

NETCDF_LIBRARY

Path to a shared or static library file.

GDAL_USE_NETCDF=ON/OFF

Control whether to use netCDF. Defaults to ON when netCDF is found.

ODBC

ODBC is required for various drivers: ODBC RDBMS, ESRI Personal GeoDatabase, SAP HANA and MSSQLSpatial - Microsoft SQL Server Spatial Database. It is normally automatically found in system directories on Unix and Windows.

ODBC_INCLUDE_DIR

Path to ODBC include directory with sql.h header.

ODBC_LIBRARY

Path to ODBC library to be linked.

GDAL_USE_ODBC=ON/OFF

Control whether to use ODBC. Defaults to ON when ODBC is found.

ODBC-CPP

The odbc-cpp-wrapper library is required for the SAP HANA driver.

ODBCCPP_INCLUDE_DIR

Path to an include directory with the odbc/Environment.h header file.

ODBCCPP_LIBRARY

Path to a shared or static library file.

GDAL_USE_ODBCCPP=ON/OFF

Control whether to use ODBC-CPP. Defaults to ON when ODBC-CPP is found.

OGDI

The OGDI library is required for the OGDI Vectors driver. It can be detected with pkg-config.

OGDI_INCLUDE_DIR

Path to an include directory with the ecs.h header file.

OGDI_LIBRARY

Path to a shared or static library file.

GDAL_USE_OGDI=ON/OFF

Control whether to use OGDI. Defaults to ON when OGDI is found.

OpenCAD

libopencad is required for the CAD – AutoCAD DWG driver. If not found, an internal copy can be used.

OPENCAD_INCLUDE_DIR

Path to an include directory with the opencad.h header file.

OPENCAD_LIBRARY

Path to a shared or static library file.

GDAL_USE_OPENCAD=ON/OFF

Control whether to use external libopencad. Defaults to ON when external libopencad is found.

GDAL_USE_OPENCAD_INTERNAL=ON/OFF

Control whether to use internal libopencad copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_OPENCAD=ON

OpenCL

The OpenCL library may be used to accelerate warping computations, typically with a GPU.

Note

It is disabled by default even when detected, since the current OpenCL warping implementation lags behind the generic implementation.

OpenCL_INCLUDE_DIR

Path to an include directory with the CL/cl.h header file.

OpenCL_LIBRARY

Path to a shared or static library file.

GDAL_USE_OPENCL=ON/OFF

Control whether to use OPENCL. Defaults to OFF when OPENCL is found.

OpenEXR

OpenEXR is required for the EXR – Extended Dynamic Range Image File Format driver

Specify OpenEXR_ROOT variable pointing to the parent directory of /lib and /include subdirectories, i.e. /DEV/lib/openexr-3.0. For OpenEXR >= 3 additionally specify Imath_ROOT as this is a separate library now, i.e. /DEV/lib/imath-3.1.3

or

Specify root directory adding to the CMAKE_PREFIX_PATH variable to find OpenEXR’s pkgconfig. For example -DCMAKE_PREFIX_PATH=/DEV/lib/openexr-3.0;/DEV/lib/imath-3.1.3

or

Get real specific and set OpenEXR_INCLUDE_DIR, Imath_INCLUDE_DIR, OpenEXR_LIBRARY, OpenEXR_UTIL_LIBRARY, OpenEXR_HALF_LIBRARY, OpenEXR_IEX_LIBRARY explicitly

GDAL_USE_OPENEXR=ON/OFF

Control whether to use OpenEXR. Defaults to ON when OpenEXR is found.

OpenJPEG

The OpenJPEG library is an open-source JPEG-2000 codec written in C language. It is required for the JP2OpenJPEG – JPEG2000 driver based on OpenJPEG library driver, or other drivers that use JPEG-2000 functionality.

OPENJPEG_INCLUDE_DIR

Path to an include directory with the openjpeg.h header file.

OPENJPEG_LIBRARY

Path to a shared or static library file.

GDAL_USE_OPENJPEG=ON/OFF

Control whether to use OpenJPEG. Defaults to ON when OpenJPEG is found.

OpenSSL

The Crypto component of the OpenSSL library can be used for the RSA SHA256 signing functionality used by some authentication methods of Google Cloud. It might be required to use the EEDAI - Google Earth Engine Data API Image images or use the /vsigs/ virtual file system.

See https://cmake.org/cmake/help/latest/module/FindOpenSSL.html for details on how to configure the library

GDAL_USE_OPENSSL=ON/OFF

Control whether to use OpenSSL. Defaults to ON when OpenSSL is found.

Oracle

The Oracle Instant Client SDK (closed source/proprietary) is required for the Oracle Spatial and the Oracle Spatial GeoRaster drivers

Oracle_ROOT

Path to the root directory of the Oracle Instant Client SDK

GDAL_USE_ORACLE=ON/OFF

Control whether to use Oracle. Defaults to ON when Oracle is found.

Parquet

The Parquet component of the Apache Arrow C++ <https://github.com/apache/arrow/tree/master/cpp> library is required for the (Geo)Parquet driver. Specify install prefix in the CMAKE_PREFIX_PATH variable.

GDAL_USE_PARQUET=ON/OFF

Control whether to use Parquet. Defaults to ON when Parquet is found.

PCRE2

PCRE2 implements Perl-compatible Regular Expressions support. It is used for the REGEXP operator in drivers using SQLite3.

PCRE2_INCLUDE_DIR

Path to an include directory with the pcre2.h header file.

PCRE2_LIBRARY

Path to a shared or static library file with “pcre2-8” in its name

GDAL_USE_PCRE2=ON/OFF

Control whether to use PCRE2. Defaults to ON when PCRE2 is found.

PDFIUM

The PDFium library is one of the possible backends for the PDF – Geospatial PDF driver.

PDFIUM_INCLUDE_DIR

Path to an include directory with the public/fpdfview.h header file.

PDFIUM_LIBRARY

Path to a shared or static library file.

GDAL_USE_PDFIUM=ON/OFF

Control whether to use PDFIUM. Defaults to ON when PDFIUM is found.

PNG

libpng is required for the PNG – Portable Network Graphics driver, and may be used by a few other drivers (GRIB – WMO General Regularly-distributed Information in Binary form, GPKG – GeoPackage raster, etc.) If not found, an internal copy of libpng can be used. See https://cmake.org/cmake/help/latest/module/FindPNG.html for more details on how the library is detected.

PNG_PNG_INCLUDE_DIR

Path to an include directory with the png.h header file.

PNG_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable PNG_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_PNG=ON/OFF

Control whether to use external libpng. Defaults to ON when external libpng is found.

GDAL_USE_PNG_INTERNAL=ON/OFF

Control whether to use internal libpng copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_PNG=ON

Poppler

The Poppler library is one of the possible backends for the PDF – Geospatial PDF driver.

Poppler_INCLUDE_DIR

Path to an include directory with the poppler-config.h header file.

Poppler_LIBRARY

Path to a shared or static library file.

GDAL_USE_POPPLER=ON/OFF

Control whether to use Poppler. Defaults to ON when Poppler is found.

PostgreSQL

The PostgreSQL client library is required for the PostgreSQL / PostGIS and PostGISRaster – PostGIS Raster driver drivers.

PostgreSQL_INCLUDE_DIR

Path to an include directory with the libpq-fe.h header file.

PostgreSQL_LIBRARY_RELEASE

Path to a shared or static library file pq / libpq. A similar variable PostgreSQL_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_POSTGRESQL=ON/OFF

Control whether to use PostgreSQL. Defaults to ON when PostgreSQL is found.

PROJ

PROJ >= 6 is a required dependency for GDAL.

PROJ_INCLUDE_DIR

Path to an include directory with the proj.h header file.

PROJ_LIBRARY_RELEASE

Path to a shared or static library file, such as proj.dll, libproj.so, proj.lib, or other name. A similar variable PROJ_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

QHULL

The QHULL library is used for the linear interpolation of gdal_grid. If not found, an internal copy can be used.

QHULL_PACKAGE_NAME

Name of the pkg-config package, typically qhull_r or qhullstatic_r. Defaults to qhull_r

QHULL_INCLUDE_DIR

Path to an include directory with the libqhull_r/libqhull_r.h header file.

QHULL_LIBRARY

Path to a shared or static library file to the reentrant library.

GDAL_USE_QHULL=ON/OFF

Control whether to use QHULL. Defaults to ON when QHULL is found.

GDAL_USE_QHULL_INTERNAL=ON/OFF

Control whether to use internal QHULL copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_QHULL=ON

RASTERLITE2

The RasterLite2 (>= 1.1.0) library used by the RasterLite2 - Rasters in SQLite DB driver. It can be detected with pkg-config.

RASTERLITE2_INCLUDE_DIR

Path to an include directory with the rasterlite2/rasterlite2.h header file.

RASTERLITE2_LIBRARY

Path to a shared or static library file.

GDAL_USE_RASTERLITE2=ON/OFF

Control whether to use RasterLite2. Defaults to ON when RasterLite2 is found.

rdb

The RDB <https://repository.riegl.com/software/libraries/rdblib> (closed source/proprietary) library is required for the RDB - RIEGL Database driver. Specify install prefix in the CMAKE_PREFIX_PATH variable.

GDAL_USE_RDB=ON/OFF

Control whether to use rdb. Defaults to ON when rdb is found.

SPATIALITE

The Spatialite library used by the SQLite / Spatialite RDBMS and GPKG – GeoPackage vector drivers, and the SQL SQLite dialect. It can be detected with pkg-config.

SPATIALITE_INCLUDE_DIR

Path to an include directory with the spatialite.h header file.

SPATIALITE_LIBRARY

Path to a shared or static library file.

GDAL_USE_SPATIALITE=ON/OFF

Control whether to use Spatialite. Defaults to ON when Spatialite is found.

SQLite3

The SQLite3 library is required for the SQLite / Spatialite RDBMS and GPKG – GeoPackage vector drivers (and also used by other drivers), and the SQL SQLite dialect.

SQLite3_INCLUDE_DIR

Path to an include directory with the sqlite3.h header file.

SQLite3_LIBRARY

Path to a shared or static library file, such as sqlite3.dll, libsqlite3.so, sqlite3.lib or other name.

GDAL_USE_SQLITE3=ON/OFF

Control whether to use SQLite3. Defaults to ON when SQLite3 is found.

SFCGAL

SFCGAL is a geometry library which supports ISO 19107:2013 and OGC Simple Features Access 1.2 for 3D operations (PolyhedralSurface, TINs, …)

SFCGAL_INCLUDE_DIR

Path to the base include directory.

SFCGAL_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable SFCGAL_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_SFCGAL=ON/OFF

Control whether to use SFCGAL. Defaults to ON when SFCGAL is found.

SWIG

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. It is used for the Python, Java and CSharp bindings.

SWIG_EXECUTABLE

Path to the SWIG executable

TEIGHA

The TEIGHA / Open Design Alliance libraries (closed source/proprietary) are required for the AutoCAD DWG and Microstation DGN v8 drivers. Note that on Linux, with a SDK consisting of shared libraries, the bin/{platform_name} subdirectory of the SDK should be in the LD_LIBRARY_PATH so that the linking of applications succeeds. The TEIGHA_ROOT variable must be set.

TEIGHA_ROOT

Path to the base directory where the Kernel and Drawings package must be extracted.

TEIGHA_ACTIVATION_FILE_DIRECTORY

Path to a directory where a OdActivationInfo file is located. If the file is somewhere under TEIGHA_ROOT, it will be automatically discovered. Otherwise this variable must be set for recent SDK versions (at least with 2021 and later).

GDAL_USE_TEIGHA=ON/OFF

Control whether to use TEIGHA. Defaults to ON when TEIGHA is found.

TIFF

libtiff is required for the GTiff – GeoTIFF File Format drivers, and a few other drivers. If not found, an internal copy of libtiff can be used.

TIFF_INCLUDE_DIR

Path to an include directory with the tiff.h header file.

TIFF_LIBRARY_RELEASE

Path to a shared or static library file, such as tiff.dll, libtiff.so, tiff.lib, or other name. A similar variable TIFF_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_TIFF=ON/OFF

Control whether to use external libtiff. Defaults to ON when external libtiff is found.

GDAL_USE_TIFF_INTERNAL=ON/OFF

Control whether to use internal libtiff copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_TIFF=ON

TileDB

The TileDB <https://github.com/TileDB-Inc/TileDB> library is required for the TileDB - TileDB driver. Specify install prefix in the CMAKE_PREFIX_PATH variable.

GDAL_USE_TILEDB=ON/OFF

Control whether to use TileDB. Defaults to ON when TileDB is found.

WebP

WebP is a image compression library. It is required for the WEBP - WEBP driver, and may be used by the GPKG – GeoPackage raster and the internal libtiff library.

WEBP_INCLUDE_DIR

Path to an include directory with the webp/encode.h header file.

WEBP_LIBRARY

Path to a shared or static library file.

GDAL_USE_WEBP=ON/OFF

Control whether to use WebP. Defaults to ON when WebP is found.

XercesC

Xerces-C is a stream-oriented XML parser library which is required to enable XML parsing capabilities in the NAS - ALKIS, “INTERLIS 1” and “INTERLIS 2” drivers and GMLAS - Geography Markup Language (GML) driven by application schemas drivers. It can also be used as an alternative to Expat for the GML driver.

XercesC_INCLUDE_DIR

Path to the base include directory.

XercesC_LIBRARY

Path to a shared or static library file.

GDAL_USE_XERCESC=ON/OFF

Control whether to use XercesC. Defaults to ON when XercesC is found.

ZLIB

ZLib is a compression library which offers the lossless Deflate/Zip compression algorithm.

ZLIB_INCLUDE_DIR

Path to an include directory with the zlib.h header file.

ZLIB_LIBRARY_RELEASE

Path to a shared or static library file. A similar variable ZLIB_LIBRARY_DEBUG can also be specified to a similar library for building Debug releases.

GDAL_USE_ZLIB=ON/OFF

Control whether to use ZLIB. Defaults to ON when ZLIB is found.

GDAL_USE_ZLIB_INTERNAL=ON/OFF

Control whether to use internal zlib copy. Defaults depends on GDAL_USE_INTERNAL_LIBS. When set to ON, has precedence over GDAL_USE_ZLIB=ON

ZSTD

ZSTD is a compression library which offers the lossless ZStd compression algorithm (faster than Deflate/ZIP, but incompatible with it). It is used by the internal libtiff library or the Zarr driver.

ZSTD_INCLUDE_DIR

Path to an include directory with the zstd.h header file.

ZSTD_LIBRARY

Path to a shared or static library file.

GDAL_USE_ZSTD=ON/OFF

Control whether to use ZSTD. Defaults to ON when ZSTD is found.

Selection of drivers

By default, all drivers that have their build requirements satisfied will be built-in in the GDAL core library.

The following options are available to select a subset of drivers:

GDAL_ENABLE_DRIVER_<driver_name>:BOOL=ON/OFF
OGR_ENABLE_DRIVER_<driver_name>:BOOL=ON/OFF

Independently of options that control global behavior, drivers can be individually enabled or disabled with those options.

GDAL_BUILD_OPTIONAL_DRIVERS:BOOL=ON/OFF
OGR_BUILD_OPTIONAL_DRIVERS:BOOL=ON/OFF

Globally enable/disable all GDAL/raster or OGR/vector drivers. More exactly, setting those variables to ON affect the default value of the GDAL_ENABLE_DRIVER_<driver_name> or OGR_ENABLE_DRIVER_<driver_name> variables (when they are not yet set).

This can be combined with individual activation of a subset of drivers by using the GDAL_ENABLE_DRIVER_<driver_name>:BOOL=ON or OGR_ENABLE_DRIVER_<driver_name>:BOOL=ON variables. Note that changing the value of GDAL_BUILD_OPTIONAL_DRIVERS/ OGR_BUILD_OPTIONAL_DRIVERS after a first run of CMake does not change the activation of individual drivers. It might be needed to pass -UGDAL_ENABLE_DRIVER_* -UOGR_ENABLE_DRIVER_* to reset their state.

Example of minimal build with the JP2OpenJPEG and SVG drivers enabled:

cmake .. -UGDAL_ENABLE_DRIVER_* -UOGR_ENABLE_DRIVER_* \
         -DGDAL_BUILD_OPTIONAL_DRIVERS:BOOL=OFF -DOGR_BUILD_OPTIONAL_DRIVERS:BOOL=OFF \
         -DGDAL_ENABLE_DRIVER_JP2OPENPEG:BOOL=ON \
         -DOGR_ENABLE_DRIVER_SVG:BOOL=ON

Build drivers as plugins

An important subset, but not all, drivers can be also built as plugin, that is to say as standalone .dll/.so shared libraries, to be installed in the gdalplugins subdirectory of the GDAL installation. This can be useful in particular for drivers that depend on libraries that have a license different (proprietary, copyleft, …) from the core GDAL library.

The list of drivers that can be built as plugins can be obtained with:

cmake .. -L | grep -e "_ENABLE.*PLUGIN"

The following options are available to select the plugin/builtin status of a driver:

GDAL_ENABLE_DRIVER_<driver_name>_PLUGIN:BOOL=ON/OFF
OGR_ENABLE_DRIVER_<driver_name>_PLUGIN:BOOL=ON/OFF

Independently of options that control global behavior, drivers can be individually enabled or disabled with those options.

Note that for the driver to be built, the corresponding base GDAL_ENABLE_DRIVER_{driver_name}:BOOL=ON or OGR_ENABLE_DRIVER_{driver_name}:BOOL=ON option must be set.

GDAL_ENABLE_PLUGINS:BOOL=ON/OFF

Globally enable/disable building all (plugin capable), GDAL and OGR, drivers as plugins. More exactly, setting that variable to ON affects the default value of the GDAL_ENABLE_DRIVER_<driver_name>_PLUGIN or OGR_ENABLE_DRIVER_<driver_name>_PLUGIN variables (when they are not yet set).

This can be combined with individual activation/deactivation of the plugin status with the GDAL_ENABLE_DRIVER_{driver_name}_PLUGIN:BOOL or OGR_ENABLE_DRIVER_{driver_name}_PLUGIN:BOOL variables. Note that changing the value of GDAL_ENABLE_PLUGINS after a first run of CMake does not change the activation of the plugin status of individual drivers. It might be needed to pass -UGDAL_ENABLE_DRIVER_* -UOGR_ENABLE_DRIVER_* to reset their state.

Example of build with all potential drivers as plugins, except the JP2OpenJPEG one:

cmake .. -UGDAL_ENABLE_DRIVER_* -UOGR_ENABLE_DRIVER_* \
         -DGDAL_ENABLE_PLUGINS:BOOL=ON \
         -DGDAL_ENABLE_DRIVER_JP2OPENPEG_PLUGIN:BOOL=OFF

There is a subtelty regarding GDAL_ENABLE_PLUGINS:BOOL=ON. It only controls the plugin status of plugin-capable drivers that have external dependencies, that are not part of GDAL core dependencies (e.g. are netCDF, HDF4, Oracle, PDF, etc.).

GDAL_ENABLE_PLUGINS_NO_DEPS:BOOL=ON/OFF

Globally enable/disable building all (plugin capable), GDAL and OGR, drivers as plugins, for drivers that have no external dependencies (e.g. BMP, FlatGeobuf), or that have dependencies that are part of GDAL core dependencies (e.g GPX). Building such drivers as plugins is generally not necessary, hence the use of a different option from GDAL_ENABLE_PLUGINS.

In some circumstances, it might be desirable to prevent loading of GDAL plugins. This can be done with:

GDAL_AUTOLOAD_PLUGINS:BOOL=ON/OFF

Set to OFF to disable loading of GDAL plugins. Default is ON.

Python bindings options

BUILD_PYTHON_BINDINGS:BOOL=ON/OFF

Whether Python bindings should be built. It is ON by default, but only effective if a Python installation is found.

A nominal Python installation should comprise the Python runtime (>= 3.6) and the setuptools module. numpy and its header and development library are also strongly recommended.

The Python installation is normally found if found in the path or registered through other standard installation mechanisms of the Python installers. It is also possible to specify it using several variables, as detailed in https://cmake.org/cmake/help/git-stage/module/FindPython.html

GDAL also provides the following option:

Python_LOOKUP_VERSION:STRING=major.minor.patch

When it is specified, Python_FIND_STRATEGY=VERSION is assumed. Note that the patch number must be provided, as the EXACT strategy is used

Other useful options:

Python_FIND_VIRTUALENV

Specify ‘ONLY’ to use virtualenv activated.

Python_ROOT

Specify Python installation prefix.

Examples:

cmake -DPython_LOOKUP_VERSION=3.6.0 ..
cmake -DPython_FIND_VIRTUALENV=ONLY ..
cmake -DPython_ROOT=C:\Python36 ..

The following options are advanced ones and only taken into account during the install CMake target.

GDAL_PYTHON_INSTALL_PREFIX

This option can be specified to a directory name, to override the CMAKE_INSTALL_PREFIX option. It is used to set the value of the --prefix option of python setup.py install.

GDAL_PYTHON_INSTALL_LAYOUT

This option can be specified to set the value of the --install-layout option of python setup.py install. The install layout is by default set to deb when it is detected that the Python installation looks for the site-packages subdirectory. Otherwise it is unspecified.

GDAL_PYTHON_INSTALL_LIB

This option can be specified to set the value of the --install-lib option of python setup.py install. It is only taken into account on MacOS systems, when the Python installation is a framework.

Java bindings options

BUILD_JAVA_BINDINGS:BOOL=ON/OFF

Whether Java bindings should be built. It is ON by default, but only effective if Java runtime and development packages are found. The relevant options that can be set are described in https://cmake.org/cmake/help/latest/module/FindJava.html and https://cmake.org/cmake/help/latest/module/FindJNI.html. The ant binary must also be available in the PATH.

GDAL_JAVA_INSTALL_DIR

Subdirectory into which to install the gdalalljni library and the .jar files. It defaults to “${CMAKE_INSTALL_DATADIR}/java”

Option only to be used by maintainers:

GPG_KEY

GPG key to sign build artifacts. Needed to generate bundle.jar.

GPG_PASS

GPG pass phrase to sign build artifacts.

C# bindings options

BUILD_CSHARP_BINDINGS:BOOL=ON/OFF

Whether C# bindings should be built. It is ON by default, but only effective if C# runtime and development packages are found. Either .NET SDK can be used or Mono. The relevant options that can be set are described in cmake/modules/thirdparty/FindDotNetFrameworkSdk.cmake and cmake/modules/thirdparty/FindMono.cmake.

Driver specific options

GDAL_USE_PUBLICDECOMPWT

The MSG – Meteosat Second Generation driver is built only if this option is set to ON (default is OFF). Its effect is to download the https://gitlab.eumetsat.int/open-source/PublicDecompWT.git repository (requires the git binary to be available at configuration time) into the build tree and build the needed files from it into the driver.

Building on Windows with Conda dependencies and Visual Studio

It is less appropriate for Debug builds of GDAL, than other methods, such as using vcpkg.

Install git

Install git

Install miniconda

Install miniconda

Install GDAL dependencies

Start a Conda enabled console and assuming there is a c:\dev directory

cd c:\dev
conda create --name gdal
conda activate gdal
conda install --yes --quiet curl libiconv icu git python=3.7 swig numpy pytest zlib clcache
conda install --yes --quiet -c conda-forge compilers
conda install --yes --quiet -c conda-forge \
    cmake proj geos hdf4 hdf5 \
    libnetcdf openjpeg poppler libtiff libpng xerces-c expat libxml2 kealib json-c \
    cfitsio freexl geotiff jpeg libpq libspatialite libwebp-base pcre postgresql \
    sqlite tiledb zstd charls cryptopp cgal librttopo libkml openssl xz

Note

The compilers package will install vs2017_win-64 (at time of writing) to set the appropriate environment for cmake to pick up. It is also possible to use the vs2019_win-64 package if Visual Studio 2019 is to be used.

Checkout GDAL sources

cd c:\dev
git clone https://github.com/OSGeo/gdal.git

Build GDAL

From a Conda enabled console

conda activate gdal
cd c:\dev\gdal
cmake -S . -B build -DCMAKE_PREFIX_PATH:FILEPATH="%CONDA_PREFIX%" \
                    -DCMAKE_C_COMPILER_LAUNCHER=clcache
                    -DCMAKE_CXX_COMPILER_LAUNCHER=clcache
cmake --build build --config Release -j 8

Cross-compiling for Android

First refer to https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android and to https://github.com/OSGeo/gdal/blob/master/.github/workflows/android_cmake/start.sh for an example of a build script to cross-compile from Ubuntu.