Skip to content

Commit

Permalink
[gdal] Fix static windows builds, fix debug builds (microsoft#26457)
Browse files Browse the repository at this point in the history
* Fix static builds

* Update versions

* Fix Qhull usage

* Update versions
  • Loading branch information
dg0yt authored Aug 22, 2022
1 parent 58df5a8 commit e8f9c33
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
45 changes: 45 additions & 0 deletions ports/gdal/cpl-disable-dll.patch
Original file line number Diff line number Diff line change
@@ -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 <atlbase.h> 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)
6 changes: 6 additions & 0 deletions ports/gdal/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ports/gdal/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@
},
"gdal": {
"baseline": "3.5.1",
"port-version": 5
"port-version": 6
},
"gdcm": {
"baseline": "3.0.12",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/gdal.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "548d8ee81b0b34493dc57b3610fb19db2403bb50",
"version-semver": "3.5.1",
"port-version": 6
},
{
"git-tree": "e875fbb6dc288ea2719e00a6b71b4834b8814640",
"version-semver": "3.5.1",
Expand Down

0 comments on commit e8f9c33

Please sign in to comment.