/CMake 3.19


New in version 3.12.

Find an Open Database Connectivity (ODBC) include directory and library.

On Windows, when building with Visual Studio, this module assumes the ODBC library is provided by the available Windows SDK.

On Unix, this module allows to search for ODBC library provided by unixODBC or iODBC implementations of ODBC API. This module reads hint about location of the config program:


Location of odbc_config or iodbc-config program

Otherwise, this module tries to find the config program, first from unixODBC, then from iODBC. If no config program found, this module searches for ODBC header and library in list of known locations.

Imported targets

This module defines the following IMPORTED targets:


Imported target for using the ODBC library, if found.

Result variables


Set to true if ODBC library found, otherwise false or undefined.


Paths to include directories listed in one variable for use by ODBC client. May be empty on Windows, where the include directory corresponding to the expected Windows SDK is already available in the compilation environment.


Paths to libraries to linked against to use ODBC. May just a library name on Windows, where the library directory corresponding to the expected Windows SDK is already available in the compilation environment.


Path to unixODBC or iODBC config program, if found or specified.

Cache variables

For users who wish to edit and control the module behavior, this module reads hints about search locations from the following variables:


Path to ODBC include directory with sql.h header.


Path to ODBC library to be linked.

These variables should not be used directly by project code.


On Windows, this module does not search for iODBC. On Unix, there is no way to prefer unixODBC over iODBC, or vice versa, other than providing the config program location using the ODBC_CONFIG. This module does not allow to search for a specific ODBC driver.

© 2000–2020 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.