Skip to content

Commit

Permalink
CMake: Export -DGDAL_DEBUG as PUBLIC for debug builds
Browse files Browse the repository at this point in the history
Fixes #11311
  • Loading branch information
rouault committed Nov 20, 2024
1 parent 1344d8d commit 78518be
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10 deletions.
9 changes: 9 additions & 0 deletions autotest/postinstall/test_cpp/test_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
#endif
#include <cpl_vsi_virtual.h>
#include <ogr_geometry.h>
#include <ogr_spatialref.h>

int main(int argc, char **argv)
{
OGRGeometry *poGeom = nullptr;
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);
}
4 changes: 4 additions & 0 deletions gdal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<CONFIG:DEBUG>:GDAL_DEBUG>)

# Install properties
if (GDAL_ENABLE_MACOSX_FRAMEWORK)
set(FRAMEWORK_VERSION ${GDAL_VERSION_MAJOR}.${GDAL_VERSION_MINOR})
Expand Down
10 changes: 5 additions & 5 deletions ogr/ogr_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogr_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogr_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogr_srs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ogr/ograpispy.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* @since GDAL 2.0
*/

#ifdef DEBUG
#if defined(DEBUG) || defined(GDAL_DEBUG)
#define OGRAPISPY_ENABLED
#endif

Expand Down
2 changes: 1 addition & 1 deletion port/cpl_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 78518be

Please sign in to comment.