[gdal-dev] Why can't find_package(GDAL CONFIG) find GDAL_LIBRARIES?
Kai Pastor, DG0YT
dg0yt at darc.de
Tue Jun 7 00:43:28 PDT 2022
Am 07.06.22 um 09:28 schrieb Even Rouault:
> Note: If you really wanted to get the equivalent of GDAL_INCLUDE_DIRS
> and GDAL_LIBRARIES, you could use the following expressions:
>
> $<TARGET_PROPERTY:GDAL::GDAL,INTERFACE_INCLUDE_DIRECTORIES>
>
> $<TARGET_PROPERTY:GDAL::GDAL,INTERFACE_LINK_LIBRARIES>
>
It is not so trivial.
$<TARGET_PROPERTY:GDAL::GDAL,INTERFACE_LINK_LIBRARIES>
- won't carry GDAL itself
- may use generator expressions (in particular for multi-config support)
- may use targets with transitive usage requirements (in particular for
static builds)
GDAL has code to expand the tree of link libraries during the build for
generating `gdal.pc`:
https://github.com/OSGeo/gdal/blob/master/cmake/helpers/GdalGenerateConfig.cmake
And so you might use pkg-config support in CMake to get something
similar to the traditional GDAL_LIBRARIES.
If you need a value for GDAL_LIBRARIES without many changes, it may be
enough to set it GDAL::GDAL.
Kai.
More information about the gdal-dev
mailing list