diff --git a/.github/workflows/ubuntu_20.04/build.sh b/.github/workflows/ubuntu_20.04/build.sh index b8bc8702ba56..54fe24572fba 100755 --- a/.github/workflows/ubuntu_20.04/build.sh +++ b/.github/workflows/ubuntu_20.04/build.sh @@ -23,6 +23,12 @@ unset CFLAGS make "-j$(nproc)" make "-j$(nproc)" install +# Download Oracle SDK +wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-basic-linux.x64-19.23.0.0.0dbru.zip +wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip +unzip -o instantclient-basic-linux.x64-19.23.0.0.0dbru.zip +unzip -o instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip + # Test building MrSID driver in standalone mode mkdir build_mrsid cd build_mrsid @@ -34,15 +40,19 @@ cd .. # Test building OCI driver in standalone mode mkdir build_oci cd build_oci -wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-basic-linux.x64-19.23.0.0.0dbru.zip -wget https://download.oracle.com/otn_software/linux/instantclient/1923000/instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip -unzip -o instantclient-basic-linux.x64-19.23.0.0.0dbru.zip -unzip -o instantclient-sdk-linux.x64-19.23.0.0.0dbru.zip -cmake -S "${GDAL_SOURCE_DIR:=..}/ogr/ogrsf_frmts/oci" "-DOracle_ROOT=$PWD/instantclient_19_23" -DCMAKE_PREFIX_PATH=/tmp/install-gdal +cmake -S "${GDAL_SOURCE_DIR:=..}/ogr/ogrsf_frmts/oci" "-DOracle_ROOT=$PWD/../instantclient_19_23" -DCMAKE_PREFIX_PATH=/tmp/install-gdal cmake --build . "-j$(nproc)" test -f ogr_OCI.so cd .. +# Test building GeoRaster driver in standalone mode +mkdir build_georaster +cd build_georaster +cmake -S "${GDAL_SOURCE_DIR:=..}/frmts/georaster" -DCMAKE_PREFIX_PATH=/tmp/install-gdal "-DOracle_ROOT=$PWD/../instantclient_19_23" +cmake --build . "-j$(nproc)" +test -f gdal_GEOR.so +cd .. + # Test building Parquet driver in standalone mode mkdir build_parquet cd build_parquet @@ -74,3 +84,11 @@ cmake -S "${GDAL_SOURCE_DIR:=..}/frmts/tiledb" -DCMAKE_PREFIX_PATH=/tmp/install- cmake --build . "-j$(nproc)" test -f gdal_TileDB.so cd .. + +# Test building ECW driver in standalone mode +mkdir build_ecw +cd build_ecw +cmake -S "${GDAL_SOURCE_DIR:=..}/frmts/ecw" -DCMAKE_PREFIX_PATH=/tmp/install-gdal -DECW_ROOT=/opt/libecwj2-3.3 +cmake --build . "-j$(nproc)" +test -f gdal_ECW_JP2ECW.so +cd .. diff --git a/cmake/helpers/CheckDependentLibraries.cmake b/cmake/helpers/CheckDependentLibraries.cmake index 48d29b9971b8..122cf53a932e 100644 --- a/cmake/helpers/CheckDependentLibraries.cmake +++ b/cmake/helpers/CheckDependentLibraries.cmake @@ -99,8 +99,7 @@ endif() gdal_check_package(XercesC "Read and write XML formats (needed for GMLAS and ILI drivers)" CAN_DISABLE) -gdal_check_package(ZLIB "zlib (external)" CAN_DISABLE) -gdal_internal_library(ZLIB REQUIRED) +include(CheckDependentLibrariesZLIB) gdal_check_package(Deflate "Enable libdeflate compression library (complement to ZLib)" CAN_DISABLE) @@ -168,46 +167,7 @@ include(CheckDependentLibrariesGeoTIFF) gdal_check_package(PNG "PNG compression library (external)" CAN_DISABLE RECOMMENDED VERSION "1.6") gdal_internal_library(PNG) -gdal_check_package(JPEG "JPEG compression library (external)" CAN_DISABLE RECOMMENDED) -if (GDAL_USE_JPEG AND (JPEG_LIBRARY MATCHES ".*turbojpeg\.(so|lib)")) - message( - FATAL_ERROR - "JPEG_LIBRARY should point to a library with libjpeg ABI, not TurboJPEG. See https://libjpeg-turbo.org/About/TurboJPEG for the difference" - ) -endif () -if (GDAL_USE_JPEG AND TARGET JPEG::JPEG) - set(EXPECTED_JPEG_LIB_VERSION "" CACHE STRING "Expected libjpeg version number") - mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_NAMES) - if (EXPECTED_JPEG_LIB_VERSION) - get_property(_jpeg_old_icd TARGET JPEG::JPEG PROPERTY INTERFACE_COMPILE_DEFINITIONS) - set_property(TARGET JPEG::JPEG PROPERTY - INTERFACE_COMPILE_DEFINITIONS "${_jpeg_old_icd};EXPECTED_JPEG_LIB_VERSION=${EXPECTED_JPEG_LIB_VERSION}") - endif() - - # Check for jpeg12_read_scanlines() which has been added in libjpeg-turbo 2.2 - # for dual 8/12 bit mode. - include(CheckCSourceCompiles) - include(CMakePushCheckState) - cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") - check_c_source_compiles( - " - #include - #include - #include \"jpeglib.h\" - int main() - { - jpeg_read_scanlines(0,0,0); - jpeg12_read_scanlines(0,0,0); - return 0; - } - " - HAVE_JPEGTURBO_DUAL_MODE_8_12) - cmake_pop_check_state() - -endif() -gdal_internal_library(JPEG) +include(CheckDependentLibrariesJpeg) gdal_check_package(GIF "GIF compression library (external)" CAN_DISABLE) gdal_internal_library(GIF) @@ -443,7 +403,8 @@ gdal_check_package(GEOS "Geometry Engine - Open Source (GDAL core dependency)" R ) gdal_check_package(HDF4 "Enable HDF4 driver" CAN_DISABLE) -gdal_check_package(ECW "Enable ECW driver" CAN_DISABLE) +include(CheckDependentLibrariesECW) + gdal_check_package(NetCDF "Enable netCDF driver" CAN_DISABLE NAMES netCDF TARGETS netCDF::netcdf NETCDF::netCDF @@ -501,8 +462,7 @@ gdal_check_package(PDFIUM "Enable PDF driver with Pdfium (read side)" CAN_DISABL gdal_check_package(Podofo "Enable PDF driver with Podofo (read side)" CAN_DISABLE) -set(Oracle_CAN_USE_CLNTSH_AS_MAIN_LIBRARY ON) -gdal_check_package(Oracle "Enable Oracle OCI driver" CAN_DISABLE) +include(CheckDependentLibrariesOracle) gdal_check_package(TEIGHA "Enable DWG and DGNv8 drivers" CAN_DISABLE) gdal_check_package(FileGDB "Enable FileGDB (based on closed-source SDK) driver" CAN_DISABLE) diff --git a/cmake/helpers/CheckDependentLibrariesECW.cmake b/cmake/helpers/CheckDependentLibrariesECW.cmake new file mode 100644 index 000000000000..a89acdf4431c --- /dev/null +++ b/cmake/helpers/CheckDependentLibrariesECW.cmake @@ -0,0 +1 @@ +gdal_check_package(ECW "Enable ECW driver" CAN_DISABLE) diff --git a/cmake/helpers/CheckDependentLibrariesJpeg.cmake b/cmake/helpers/CheckDependentLibrariesJpeg.cmake new file mode 100644 index 000000000000..8227c85fdd45 --- /dev/null +++ b/cmake/helpers/CheckDependentLibrariesJpeg.cmake @@ -0,0 +1,40 @@ +gdal_check_package(JPEG "JPEG compression library (external)" CAN_DISABLE RECOMMENDED) +if (GDAL_USE_JPEG AND (JPEG_LIBRARY MATCHES ".*turbojpeg\.(so|lib)")) + message( + FATAL_ERROR + "JPEG_LIBRARY should point to a library with libjpeg ABI, not TurboJPEG. See https://libjpeg-turbo.org/About/TurboJPEG for the difference" + ) +endif () +if (GDAL_USE_JPEG AND TARGET JPEG::JPEG) + set(EXPECTED_JPEG_LIB_VERSION "" CACHE STRING "Expected libjpeg version number") + mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_NAMES) + if (EXPECTED_JPEG_LIB_VERSION) + get_property(_jpeg_old_icd TARGET JPEG::JPEG PROPERTY INTERFACE_COMPILE_DEFINITIONS) + set_property(TARGET JPEG::JPEG PROPERTY + INTERFACE_COMPILE_DEFINITIONS "${_jpeg_old_icd};EXPECTED_JPEG_LIB_VERSION=${EXPECTED_JPEG_LIB_VERSION}") + endif() + + # Check for jpeg12_read_scanlines() which has been added in libjpeg-turbo 2.2 + # for dual 8/12 bit mode. + include(CheckCSourceCompiles) + include(CMakePushCheckState) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") + check_c_source_compiles( + " + #include + #include + #include \"jpeglib.h\" + int main() + { + jpeg_read_scanlines(0,0,0); + jpeg12_read_scanlines(0,0,0); + return 0; + } + " + HAVE_JPEGTURBO_DUAL_MODE_8_12) + cmake_pop_check_state() + +endif() +gdal_internal_library(JPEG) diff --git a/cmake/helpers/CheckDependentLibrariesOCI.cmake b/cmake/helpers/CheckDependentLibrariesOCI.cmake deleted file mode 100644 index 76d2644b1965..000000000000 --- a/cmake/helpers/CheckDependentLibrariesOCI.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(Oracle_CAN_USE_CLNTSH_AS_MAIN_LIBRARY ON) -gdal_check_package(Oracle "Enable Oracle OCI driver" CAN_DISABLE) diff --git a/cmake/helpers/CheckDependentLibrariesOracle.cmake b/cmake/helpers/CheckDependentLibrariesOracle.cmake new file mode 100644 index 000000000000..5a7f85289320 --- /dev/null +++ b/cmake/helpers/CheckDependentLibrariesOracle.cmake @@ -0,0 +1,2 @@ +set(Oracle_CAN_USE_CLNTSH_AS_MAIN_LIBRARY ON) +gdal_check_package(Oracle "Enable Oracle OCI and GeoRaster drivers" CAN_DISABLE) diff --git a/cmake/helpers/CheckDependentLibrariesZLIB.cmake b/cmake/helpers/CheckDependentLibrariesZLIB.cmake new file mode 100644 index 000000000000..e253a7890426 --- /dev/null +++ b/cmake/helpers/CheckDependentLibrariesZLIB.cmake @@ -0,0 +1,2 @@ +gdal_check_package(ZLIB "zlib (external)" CAN_DISABLE) +gdal_internal_library(ZLIB REQUIRED) diff --git a/doc/source/drivers/raster/ecw.rst b/doc/source/drivers/raster/ecw.rst index 3029927610d3..f30d728f1ea4 100644 --- a/doc/source/drivers/raster/ecw.rst +++ b/doc/source/drivers/raster/ecw.rst @@ -290,6 +290,31 @@ File Metadata Keys: uncompressed file size by 5), etc... - VERSION +Standalone plugin compilation +----------------------------- + +.. versionadded:: 3.10 + +While this driver may be built as part of a whole GDAL build, either in libgdal +itself, or as a plugin, it is also possible to only build this driver as a plugin, +against an already built libgdal. + +The version of the GDAL sources used to build the driver must match the version +of the libgdal it is built against. + +For example, from a "build_georaster" directory under the root of the GDAL source tree: + +:: + + cmake -S ../frmts/ecw -DCMAKE_PREFIX_PATH=/path/to/GDAL_installation_prefix -DECW_ROOT=/path/to/ecw_sdk_root + cmake --build . + + +Note that such a plugin, when used against a libgdal not aware of it, will be +systematically loaded at GDAL driver initialization time, and will not benefit from +`deferred plugin loading capabilities `. For that, libgdal itself must be built with the +CMake variable GDAL_REGISTER_DRIVER_ECW_FOR_LATER_PLUGIN=ON set. + See Also -------- diff --git a/doc/source/drivers/raster/georaster.rst b/doc/source/drivers/raster/georaster.rst index b221c6d2d5ba..c900917f7972 100644 --- a/doc/source/drivers/raster/georaster.rst +++ b/doc/source/drivers/raster/georaster.rst @@ -490,3 +490,28 @@ system so one alternative is to create VRT to represent the GeoRaster descriptio % gdal_translate -of VRT geor:scott/tiger@dbdemo,landsat,scene,id=54 view_54.vrt % openenv view_54.vrt + +Standalone plugin compilation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 3.10 + +While this driver may be built as part of a whole GDAL build, either in libgdal +itself, or as a plugin, it is also possible to only build this driver as a plugin, +against an already built libgdal. + +The version of the GDAL sources used to build the driver must match the version +of the libgdal it is built against. + +For example, from a "build_georaster" directory under the root of the GDAL source tree: + +:: + + cmake -S ../frmts/georaster -DCMAKE_PREFIX_PATH=/path/to/GDAL_installation_prefix -DOracle_ROOT=/path/to/instantclient_sdk_root + cmake --build . + + +Note that such a plugin, when used against a libgdal not aware of it, will be +systematically loaded at GDAL driver initialization time, and will not benefit from +`deferred plugin loading capabilities `. For that, libgdal itself must be built with the +CMake variable GDAL_REGISTER_DRIVER_GEOR_FOR_LATER_PLUGIN=ON set. diff --git a/frmts/CMakeLists.txt b/frmts/CMakeLists.txt index d0618f34ad7e..073dfc9667a9 100644 --- a/frmts/CMakeLists.txt +++ b/frmts/CMakeLists.txt @@ -165,8 +165,8 @@ gdal_dependent_format(jp2lura "JPEG-2000 (based on Luratech)" "GDAL_USE_LURATECH gdal_dependent_format(sde "ESRI ArcSDE Raster" "HAVE_SDE") # LizardTech's decoding software development kit (DSDK) include(mrsid/driver_declaration.cmake) -gdal_dependent_format(georaster "Oracle Spatial GeoRaster" "GDAL_USE_ORACLE" DRIVER_NAME_OPTION GEOR) -gdal_dependent_format(ecw "ERDAS JPEG2000 (.jp2)" "GDAL_USE_ECW") +include(georaster/driver_declaration.cmake) +include(ecw/driver_declaration.cmake) # Register all frmt drivers according to FRMT_ flags gdal_standard_includes(gdal_frmts) diff --git a/frmts/ecw/CMakeLists.txt b/frmts/ecw/CMakeLists.txt index 8369bad2452a..97df2c59be75 100644 --- a/frmts/ecw/CMakeLists.txt +++ b/frmts/ecw/CMakeLists.txt @@ -1,3 +1,14 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers/GdalCMakeMinimumRequired.cmake") +cmake_minimum_required(VERSION ${GDAL_CMAKE_VERSION_MIN}...${GDAL_CMAKE_VERSION_MAX}) + +if(NOT DEFINED PROJECT_SOURCE_DIR) + # Standalone plugin building + project(gdal_ECW_JP2ECW) + include("${PROJECT_SOURCE_DIR}/../../cmake/helpers/SetupStandalonePlugin.cmake" ) + include(CheckDependentLibrariesECW) + standalone_driver_finalize(GDAL_ENABLE_DRIVER_ECW) +endif() + set(SOURCE ecwdataset.cpp ecwcreatecopy.cpp ecwasyncreader.cpp jp2userbox.cpp) add_gdal_driver( TARGET gdal_ECW_JP2ECW diff --git a/frmts/ecw/driver_declaration.cmake b/frmts/ecw/driver_declaration.cmake new file mode 100644 index 000000000000..6ddccd432f65 --- /dev/null +++ b/frmts/ecw/driver_declaration.cmake @@ -0,0 +1 @@ +gdal_dependent_format(ecw "ERDAS JPEG2000 (.jp2)" "GDAL_USE_ECW") diff --git a/frmts/georaster/CMakeLists.txt b/frmts/georaster/CMakeLists.txt index 8f5eaa4a1d6e..df02240b360e 100644 --- a/frmts/georaster/CMakeLists.txt +++ b/frmts/georaster/CMakeLists.txt @@ -1,3 +1,22 @@ +include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers/GdalCMakeMinimumRequired.cmake") +cmake_minimum_required(VERSION ${GDAL_CMAKE_VERSION_MIN}...${GDAL_CMAKE_VERSION_MAX}) + +if(NOT DEFINED PROJECT_SOURCE_DIR) + # Standalone plugin building + project(gdal_GEOR) + include("${PROJECT_SOURCE_DIR}/../../cmake/helpers/SetupStandalonePlugin.cmake") + include(CheckDependentLibrariesZLIB) + include(CheckDependentLibrariesJpeg) + include(CheckDependentLibrariesOracle) + if (GDAL_USE_ZLIB_INTERNAL) + message(FATAL_ERROR "Internal zlib not supported for GeoRaster standalone plugin build") + endif() + if (GDAL_USE_JPEG_INTERNAL) + message(FATAL_ERROR "Internal libjpeg not supported for GeoRaster standalone plugin build") + endif() + standalone_driver_finalize(GDAL_ENABLE_DRIVER_GEOR) +endif() + add_gdal_driver( TARGET gdal_GEOR SOURCES georaster_dataset.cpp georaster_priv.h georaster_rasterband.cpp georaster_wrapper.cpp oci_wrapper.cpp diff --git a/frmts/georaster/driver_declaration.cmake b/frmts/georaster/driver_declaration.cmake new file mode 100644 index 000000000000..4c1b60decb26 --- /dev/null +++ b/frmts/georaster/driver_declaration.cmake @@ -0,0 +1 @@ +gdal_dependent_format(georaster "Oracle Spatial GeoRaster" "GDAL_USE_ORACLE" DRIVER_NAME_OPTION GEOR) diff --git a/ogr/ogrsf_frmts/oci/CMakeLists.txt b/ogr/ogrsf_frmts/oci/CMakeLists.txt index 2f7df9b59a0d..159c1f2c89a8 100644 --- a/ogr/ogrsf_frmts/oci/CMakeLists.txt +++ b/ogr/ogrsf_frmts/oci/CMakeLists.txt @@ -5,7 +5,7 @@ if(NOT DEFINED PROJECT_SOURCE_DIR) # Standalone plugin building project(ogr_OCI) include("${PROJECT_SOURCE_DIR}/../../../cmake/helpers/SetupStandalonePlugin.cmake" ) - include(CheckDependentLibrariesOCI) + include(CheckDependentLibrariesOracle) standalone_driver_finalize(OGR_ENABLE_DRIVER_OCI) endif()