OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.94k stars 2.57k forks source link

CMake: build with GDAL optional drivers disabled, but OGR ones enabled, fails #6031

Closed mathstuf closed 2 years ago

mathstuf commented 2 years ago

Expected behavior and actual behavior.

When trying to make a minimal build, some OGR dependencies need manually turned off because their GDAL bits are disabled.

Full configure line for GDAL-specific bits:

    -DGDAL_USE_EXTERNAL_LIBS:BOOL=OFF
    -DGDAL_USE_INTERNAL_LIBS:BOOL=OFF
    -DGDAL_USE_BLOSC:BOOL=OFF
    -DGDAL_USE_GEOTIFF:BOOL=ON # actually required, why ask?
    -DGDAL_USE_ICONV:BOOL=ON
    -DGDAL_USE_JPEG:BOOL=OFF
    -DGDAL_USE_JSONC:BOOL=ON # actually required; why ask?
    -DGDAL_USE_OPENSSL:BOOL=OFF
    -DGDAL_USE_PNG:BOOL=ON
    -DGDAL_USE_SQLITE:BOOL=ON
    -DGDAL_USE_TIFF:BOOL=ON
    -DGDAL_USE_ZLIB:BOOL=ON
    -DGDAL_BUILD_OPTIONAL_DRIVERS:BOOL=OFF
    -DGDAL_ENABLE_DRIVER_ISO8211:BOOL=ON # required OGR plugin requires this
    -DOGR_ENABLE_OPTIONAL_DRIVERS:BOOL=OFF
    -DOGR_ENABLE_DRIVER_IDRISI:BOOL=OFF # manually specify; requires GDAL component
    -DOGR_ENABLE_DRIVER_SDTS:BOOL=OFF # ditto
    -DBUILD_APPS:BOOL=OFF
    -DBUILD_CSHARP_BINDINGS:BOOL=OFF
    -DBUILD_JAVA_BINDINGS:BOOL=OFF
    -DBUILD_PYTHON_BINDINGS:BOOL=OFF
    -DBUILD_TESTING:BOOL=OFF

Steps to reproduce the problem.

Use configure line above without the OGR_ENABLE_DRIVER_* and GDAL_ENABLE_DRIVER_* options. Generator expressions that reference non-existent targets are used which errors out at generate time.

Operating system

Linux

GDAL version and provenance

Source tarball for 3.5.1.

rouault commented 2 years ago

https://github.com/OSGeo/gdal/pull/6032 fixes your issue. See the amended documentation in it for your "why ask?" questions.

I'd note that there's a typo in your CMake options. OGR_ENABLE_OPTIONAL_DRIVERS is not the correct name. It should be OGR_BUILD_OPTIONAL_DRIVERS=OFF. If you use that one, you won't go into the generator expression failures. This configuration (disabling GDAL optional drivers but still enabling OGR ones hadn't been tested before apparently)