Skip to content

Commit

Permalink
CMake: also export -DDEBUG 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 dae81ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 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 ()

# To also export for external users what we did with add_compile_definitions($<$<CONFIG:DEBUG>:DEBUG>)
# in cmake/helpers/GdalCompilationFlags.cmake
target_compile_definitions(${GDAL_LIB_TARGET_NAME} PUBLIC $<$<CONFIG:DEBUG>:DEBUG>)

# Install properties
if (GDAL_ENABLE_MACOSX_FRAMEWORK)
set(FRAMEWORK_VERSION ${GDAL_VERSION_MAJOR}.${GDAL_VERSION_MINOR})
Expand Down

0 comments on commit dae81ed

Please sign in to comment.