gdal-dev : CMake find_package() fails because CONFIG mode CMake files are not included
Alpine Linux Version: alpine:3.16
, or alpine:latest
from Docker
Package: gdal-dev
According to gdal's docs, it can be consumed in CMake like so:
find_package(GDAL CONFIG REQUIRED)
target_link_libraries(MyApp PRIVATE GDAL::GDAL)
However, when I build a sample project, find_package()
fails.
bash-5.1# cmake -S . -B build
CMake Error at CMakeLists.txt:12 (find_package):
Could not find a package configuration file provided by "GDAL" with any of
the following names:
GDALConfig.cmake
gdal-config.cmake
Add the installation prefix of "GDAL" to CMAKE_PREFIX_PATH or set
"GDAL_DIR" to a directory containing one of the above files. If "GDAL"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/ws/build/CMakeFiles/CMakeOutput.log".
Searching the entire alpine
image for either of those results in no files.
bash-5.1# apk info gdal-dev
gdal-dev-3.5.3-r0 description:
A translator library for raster and vector geospatial data formats (development files)
gdal-dev-3.5.3-r0 webpage:
https://gdal.org/
gdal-dev-3.5.3-r0 installed size:
1404 KiB
I have also tried with latest alpine, it is also broken.
bash-5.1# apk info gdal-dev
gdal-dev-3.5.3-r0 description:
A translator library for raster and vector geospatial data formats (development files)
gdal-dev-3.5.3-r0 webpage:
https://gdal.org/
gdal-dev-3.5.3-r0 installed size:
1404 KiB
bash-5.1# rm -r build
bash-5.1# cmake -S . -B build
-- The CXX compiler identification is GNU 11.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:12 (find_package):
Could not find a package configuration file provided by "GDAL" with any of
the following names:
GDALConfig.cmake
gdal-config.cmake
Add the installation prefix of "GDAL" to CMAKE_PREFIX_PATH or set
"GDAL_DIR" to a directory containing one of the above files. If "GDAL"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/ws/build/CMakeFiles/CMakeOutput.log".
I have verified gdal-dev is installed:
bash-5.1# ls /usr/lib | grep gdal
gdalplugins
libgdal.so
libgdal.so.31
libgdal.so.31.0.3
On Ubuntu, if I do a source install, gdal-dev
exposes the find-package successfully.
The cmake config script exists at /usr/local/lib/cmake/gdal/GDALConfig.cmake
I did find a different cmake script. Perhaps this is a cmake module?
bash-5.1# pwd
/usr/share/cmake/Modules
bash-5.1# find . | grep -i gdal
./FindGDAL.cmake
I would much prefer a CONFIG mode, because of the support that target_link_libraries
has for include dirs and library files.