From 78518bef378b816376b1e4f95b25d5d2c4964553 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Nov 2024 14:09:38 +0100 Subject: [PATCH] CMake: Export -DGDAL_DEBUG as PUBLIC for debug builds Fixes #11311 --- autotest/postinstall/test_cpp/test_cpp.cpp | 9 +++++++++ gdal.cmake | 4 ++++ ogr/ogr_api.h | 10 +++++----- ogr/ogr_feature.h | 2 +- ogr/ogr_geometry.h | 2 +- ogr/ogr_srs_api.h | 2 +- ogr/ograpispy.h | 2 +- port/cpl_error.h | 2 +- 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/autotest/postinstall/test_cpp/test_cpp.cpp b/autotest/postinstall/test_cpp/test_cpp.cpp index b928a03b9205..173daa14f6f2 100644 --- a/autotest/postinstall/test_cpp/test_cpp.cpp +++ b/autotest/postinstall/test_cpp/test_cpp.cpp @@ -9,6 +9,7 @@ #endif #include #include +#include int main(int argc, char **argv) { @@ -16,5 +17,13 @@ int main(int argc, char **argv) OGRGeometryFactory::createFromWkt("POINT(1 2)", nullptr, &poGeom); OGRGeometryFactory::destroyGeometry(poGeom); std::cout << GDALVersionInfo("RELEASE_NAME") << std::endl; + + // Check fix for https://github.com/OSGeo/gdal/issues/11311 + OGRSpatialReference oSRS; + int nEntries = 0; + int *panMatchCondidence = nullptr; + oSRS.FindMatches(nullptr, &nEntries, &panMatchCondidence); + CPLFree(panMatchCondidence); + return (0); } diff --git a/gdal.cmake b/gdal.cmake index 1799ea709019..80c7ddf7ce68 100644 --- a/gdal.cmake +++ b/gdal.cmake @@ -196,6 +196,10 @@ if (MINGW AND BUILD_SHARED_LIBS) set_target_properties(${GDAL_LIB_TARGET_NAME} PROPERTIES SUFFIX "-${GDAL_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") endif () +# Some of the types in our public headers are dependent on whether GDAL_DEBUG +# is defined or not +target_compile_definitions(${GDAL_LIB_TARGET_NAME} PUBLIC $<$:GDAL_DEBUG>) + # Install properties if (GDAL_ENABLE_MACOSX_FRAMEWORK) set(FRAMEWORK_VERSION ${GDAL_VERSION_MAJOR}.${GDAL_VERSION_MINOR}) diff --git a/ogr/ogr_api.h b/ogr/ogr_api.h index d17fd9028d35..8a3e674f35dd 100644 --- a/ogr/ogr_api.h +++ b/ogr/ogr_api.h @@ -43,7 +43,7 @@ bool CPL_DLL OGRGetGEOSVersion(int *pnMajor, int *pnMinor, int *pnPatch); /*! @cond Doxygen_Suppress */ #define DEFINEH_OGRGeometryH /*! @endcond */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRGeometryHS *OGRGeometryH; #else /** Opaque type for a geometry */ @@ -57,7 +57,7 @@ typedef void *OGRGeometryH; /*! @endcond */ #ifndef DOXYGEN_XML -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRSpatialReferenceHS *OGRSpatialReferenceH; typedef struct OGRCoordinateTransformationHS *OGRCoordinateTransformationH; #else @@ -396,7 +396,7 @@ int CPL_DLL OGRPreparedGeometryContains(OGRPreparedGeometryH hPreparedGeom, /*! @cond Doxygen_Suppress */ #define DEFINE_OGRFeatureH /*! @endcond */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRFieldDefnHS *OGRFieldDefnH; typedef struct OGRFeatureDefnHS *OGRFeatureDefnH; typedef struct OGRFeatureHS *OGRFeatureH; @@ -667,7 +667,7 @@ const char CPL_DLL *OGR_GlobFldDomain_GetGlob(OGRFieldDomainH); /* ogrsf_frmts.h */ /* -------------------------------------------------------------------- */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRLayerHS *OGRLayerH; typedef struct OGRDataSourceHS *OGRDataSourceH; typedef struct OGRDriverHS *OGRSFDriverH; @@ -949,7 +949,7 @@ void CPL_DLL OGRCleanupAll(void); /* ogrsf_featurestyle.h */ /* -------------------------------------------------------------------- */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRStyleMgrHS *OGRStyleMgrH; typedef struct OGRStyleToolHS *OGRStyleToolH; #else diff --git a/ogr/ogr_feature.h b/ogr/ogr_feature.h index d710dfd54a93..3ffd6b0201cb 100644 --- a/ogr/ogr_feature.h +++ b/ogr/ogr_feature.h @@ -37,7 +37,7 @@ /*! @cond Doxygen_Suppress */ #define DEFINE_OGRFeatureH /*! @endcond */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRFieldDefnHS *OGRFieldDefnH; typedef struct OGRFeatureDefnHS *OGRFeatureDefnH; typedef struct OGRFeatureHS *OGRFeatureH; diff --git a/ogr/ogr_geometry.h b/ogr/ogr_geometry.h index 2e07be78d05e..4d354cce8f02 100644 --- a/ogr/ogr_geometry.h +++ b/ogr/ogr_geometry.h @@ -36,7 +36,7 @@ /*! @cond Doxygen_Suppress */ #ifndef DEFINEH_OGRGeometryH #define DEFINEH_OGRGeometryH -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRGeometryHS *OGRGeometryH; #else typedef void *OGRGeometryH; diff --git a/ogr/ogr_srs_api.h b/ogr/ogr_srs_api.h index e9eb02ea90ca..2116821b80bc 100644 --- a/ogr/ogr_srs_api.h +++ b/ogr/ogr_srs_api.h @@ -426,7 +426,7 @@ const char CPL_DLL *OSRAxisEnumToName(OGRAxisOrientation eOrientation); #define DEFINED_OGRSpatialReferenceH /*! @endcond */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) typedef struct OGRSpatialReferenceHS *OGRSpatialReferenceH; typedef struct OGRCoordinateTransformationHS *OGRCoordinateTransformationH; #else diff --git a/ogr/ograpispy.h b/ogr/ograpispy.h index 70d98b5ea16f..f04d3758657b 100644 --- a/ogr/ograpispy.h +++ b/ogr/ograpispy.h @@ -45,7 +45,7 @@ * @since GDAL 2.0 */ -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) #define OGRAPISPY_ENABLED #endif diff --git a/port/cpl_error.h b/port/cpl_error.h index d15d875e619c..c4f1cde43626 100644 --- a/port/cpl_error.h +++ b/port/cpl_error.h @@ -179,7 +179,7 @@ void CPL_DLL CPLDebugProgress(const char *, CPL_FORMAT_STRING(const char *), ...) CPL_PRINT_FUNC_FORMAT(2, 3); #endif -#ifdef DEBUG +#if defined(DEBUG) || defined(GDAL_DEBUG) /** Same as CPLDebug(), but expands to nothing for non-DEBUG builds. * @since GDAL 3.1 */