From e8f9c3391d9aadc90c8ee0334e9deef02550061d Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Mon, 22 Aug 2022 18:33:47 +0200 Subject: [PATCH] [gdal] Fix static windows builds, fix debug builds (#26457) * Fix static builds * Update versions * Fix Qhull usage * Update versions --- ports/gdal/cpl-disable-dll.patch | 45 ++++++++++++++++++++++++++++++++ ports/gdal/portfile.cmake | 6 +++++ ports/gdal/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/g-/gdal.json | 5 ++++ 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 ports/gdal/cpl-disable-dll.patch diff --git a/ports/gdal/cpl-disable-dll.patch b/ports/gdal/cpl-disable-dll.patch new file mode 100644 index 00000000000000..fd1c81191d0de2 --- /dev/null +++ b/ports/gdal/cpl-disable-dll.patch @@ -0,0 +1,45 @@ +diff --git a/cmake/helpers/configure.cmake b/cmake/helpers/configure.cmake +index 652edf1..0d1441b 100644 +--- a/cmake/helpers/configure.cmake ++++ b/cmake/helpers/configure.cmake +@@ -42,6 +42,10 @@ check_type_size("int" SIZEOF_INT) + check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) + check_type_size("void*" SIZEOF_VOIDP) + ++if(MSVC AND NOT BUILD_SHARED_LIBS) ++ set(CPL_DISABLE_DLL 1) ++endif() ++ + if (MSVC) + set(HAVE_VSNPRINTF 1) + +diff --git a/cmake/template/cpl_config.h.in b/cmake/template/cpl_config.h.in +index c85d3b0..19d3f0a 100644 +--- a/cmake/template/cpl_config.h.in ++++ b/cmake/template/cpl_config.h.in +@@ -177,6 +177,9 @@ + /* Define to 1 if the compiler supports -Wzero-as-null-pointer-constant */ + #cmakedefine HAVE_GCC_WARNING_ZERO_AS_NULL_POINTER_CONSTANT @HAVE_GCC_WARNING_ZERO_AS_NULL_POINTER_CONSTANT@ + ++/* Define if building a static windows lib */ ++#cmakedefine CPL_DISABLE_DLL @CPL_DISABLE_DLL@ ++ + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_ATLBASE_H 1 + +diff --git a/gdal.cmake b/gdal.cmake +index ff1ca7e..7712f1d 100644 +--- a/gdal.cmake ++++ b/gdal.cmake +@@ -336,11 +336,6 @@ if (MINGW AND BUILD_SHARED_LIBS) + set_target_properties(${GDAL_LIB_TARGET_NAME} PROPERTIES SUFFIX "-${GDAL_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif () + +- +-if (MSVC AND NOT BUILD_SHARED_LIBS) +- target_compile_definitions(${GDAL_LIB_TARGET_NAME} PUBLIC CPL_DISABLE_DLL=) +-endif () +- + if (MINGW) + if (TARGET_CPU MATCHES "x86_64") + add_definitions(-m64) diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake index 39c9eda11956b3..a2657bb2b183d0 100644 --- a/ports/gdal/portfile.cmake +++ b/ports/gdal/portfile.cmake @@ -6,6 +6,7 @@ vcpkg_from_github( HEAD_REF master PATCHES find-link-libraries.patch + cpl-disable-dll.patch ) # `vcpkg clean` stumbles over one subdir file(REMOVE_RECURSE "${SOURCE_PATH}/autotest") @@ -64,6 +65,8 @@ if(VCPKG_TARGET_IS_ANDROID AND ANRDOID_PLATFORM VERSION_LESS 24 AND (VCPKG_TARGE list(APPEND FEATURE_OPTIONS -DBUILD_WITHOUT_64BIT_OFFSET=ON) endif() +string(REPLACE "dynamic" "" qhull_target "Qhull::qhull${VCPKG_LIBRARY_LINKAGE}_r") + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS @@ -82,6 +85,9 @@ vcpkg_cmake_configure( -DOGR_BUILD_OPTIONAL_DRIVERS=ON -DGDAL_CHECK_PACKAGE_NetCDF_NAMES=netCDF -DGDAL_CHECK_PACKAGE_NetCDF_TARGETS=netCDF::netcdf + -DGDAL_CHECK_PACKAGE_QHULL_NAMES=Qhull + "-DGDAL_CHECK_PACKAGE_QHULL_TARGETS=${qhull_target}" + "-DQHULL_LIBRARY=${qhull_target}" OPTIONS_RELEASE ${FEATURE_OPTIONS_RELEASE} OPTIONS_DEBUG diff --git a/ports/gdal/vcpkg.json b/ports/gdal/vcpkg.json index e50ff156635913..343bc1b2c151ad 100644 --- a/ports/gdal/vcpkg.json +++ b/ports/gdal/vcpkg.json @@ -1,7 +1,7 @@ { "name": "gdal", "version-semver": "3.5.1", - "port-version": 5, + "port-version": 6, "description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data", "homepage": "https://gdal.org", "license": null, diff --git a/versions/baseline.json b/versions/baseline.json index 7eb87d58f187e9..fcc75f3404dcd7 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2482,7 +2482,7 @@ }, "gdal": { "baseline": "3.5.1", - "port-version": 5 + "port-version": 6 }, "gdcm": { "baseline": "3.0.12", diff --git a/versions/g-/gdal.json b/versions/g-/gdal.json index c2888c04850143..e067ef8e547c5d 100644 --- a/versions/g-/gdal.json +++ b/versions/g-/gdal.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "548d8ee81b0b34493dc57b3610fb19db2403bb50", + "version-semver": "3.5.1", + "port-version": 6 + }, { "git-tree": "e875fbb6dc288ea2719e00a6b71b4834b8814640", "version-semver": "3.5.1",