Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cgal] update to 6.0 #41300

Merged
merged 11 commits into from
Oct 8, 2024
212 changes: 212 additions & 0 deletions ports/cgal/PR-8523__CGAL_CGAL-protect_against_macro_free-GF.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
diff --git a/CGAL_Core/include/CGAL/CORE/ExprRep.h b/CGAL_Core/include/CGAL/CORE/ExprRep.h
index 0e721dda16a8..a325930a2ab4 100644
--- a/CGAL_Core/include/CGAL/CORE/ExprRep.h
+++ b/CGAL_Core/include/CGAL/CORE/ExprRep.h
@@ -595,7 +595,7 @@ class CGAL_CORE_EXPORT ConstPolyRep : public ConstRep {
}

void operator delete( void *p, size_t ){
- MemoryPool<ConstPolyRep>::global_allocator().free(p);
+ (MemoryPool<ConstPolyRep>::global_allocator().free)(p);
}

private:
@@ -1248,7 +1248,7 @@ void * AddSubRep<O>::operator new( size_t size)

template <typename O>
void AddSubRep<O>::operator delete( void *p, size_t )
-{ MemoryPool<AddSubRep<O> >::global_allocator().free(p); }
+{ (MemoryPool<AddSubRep<O> >::global_allocator().free)(p); }


/// \typedef AddRep
diff --git a/CGAL_Core/include/CGAL/CORE/Impl.h b/CGAL_Core/include/CGAL/CORE/Impl.h
index 4ff8b4fa3d48..8ae4c53fe7d1 100644
--- a/CGAL_Core/include/CGAL/CORE/Impl.h
+++ b/CGAL_Core/include/CGAL/CORE/Impl.h
@@ -58,7 +58,7 @@
{ return MemoryPool<C<T> >::global_allocator().allocate(size); } \
template <typename T> \
CGAL_INLINE_FUNCTION void C<T>::operator delete( void *p, size_t ) \
- { MemoryPool<C<T> >::global_allocator().free(p); }
+ { (MemoryPool<C<T> >::global_allocator().free)(p); }
#endif

// include some common header files
diff --git a/CGAL_Core/include/CGAL/CORE/MemoryPool.h b/CGAL_Core/include/CGAL/CORE/MemoryPool.h
index 2db3de8736e1..d218a871bec5 100644
--- a/CGAL_Core/include/CGAL/CORE/MemoryPool.h
+++ b/CGAL_Core/include/CGAL/CORE/MemoryPool.h
@@ -73,7 +73,7 @@ class MemoryPool {


void* allocate(std::size_t size);
- void free(void* p);
+ void free BOOST_PREVENT_MACRO_SUBSTITUTION (void* p);

// Access the corresponding static global allocator.
static MemoryPool<T,nObjects>& global_allocator() {
diff --git a/CGAL_Core/include/CGAL/CORE/RealRep.h b/CGAL_Core/include/CGAL/CORE/RealRep.h
index 1c5d0f13a405..f2ec1e90cb3b 100644
--- a/CGAL_Core/include/CGAL/CORE/RealRep.h
+++ b/CGAL_Core/include/CGAL/CORE/RealRep.h
@@ -154,7 +154,7 @@ void * Realbase_for<T>::operator new( size_t size)

template <class T>
void Realbase_for<T>::operator delete( void *p, size_t )
-{ MemoryPool<Realbase_for<T> >::global_allocator().free(p); }
+{ (MemoryPool<Realbase_for<T> >::global_allocator().free)(p); }

typedef Realbase_for<long> RealLong;
typedef Realbase_for<double> RealDouble;

diff --git a/CGAL_Core/include/CGAL/CORE/MemoryPool.h b/CGAL_Core/include/CGAL/CORE/MemoryPool.h
index d218a871bec5..1cfa96fa93d1 100644
--- a/CGAL_Core/include/CGAL/CORE/MemoryPool.h
+++ b/CGAL_Core/include/CGAL/CORE/MemoryPool.h
@@ -116,7 +116,7 @@ void* MemoryPool< T, nObjects >::allocate(std::size_t) {
}

template< class T, int nObjects >
-void MemoryPool< T, nObjects >::free(void* t) {
+void MemoryPool< T, nObjects >::free BOOST_PREVENT_MACRO_SUBSTITUTION (void* t) {
CGAL_assertion(t != 0);
if (t == 0) return; // for safety
if(blocks.empty()){

diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h
index 53f8968f86f4..9a217389d82e 100644
--- a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h
+++ b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h
@@ -116,8 +116,8 @@ void partition_dual_graph(const TriangleMesh& tm,
delete[] eptr;
delete[] eind;

- std::free(npart);
- std::free(epart);
+ (std::free)(npart);
+ (std::free)(epart);
}

template<typename TriangleMesh, typename NamedParameters>
diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h
index 08926a641169..42f8c240f011 100644
--- a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h
+++ b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h
@@ -151,8 +151,8 @@ void partition_graph(const TriangleMesh& tm,
delete[] eptr;
delete[] eind;

- std::free(npart);
- std::free(epart);
+ (std::free)(npart);
+ (std::free)(epart);
}

template<typename TriangleMesh, typename NamedParameters>
diff --git a/CGAL_Core/include/CGAL/CORE/Impl.h b/CGAL_Core/include/CGAL/CORE/Impl.h
index 8ae4c53fe7d1..2e21aab5ac0a 100644
--- a/CGAL_Core/include/CGAL/CORE/Impl.h
+++ b/CGAL_Core/include/CGAL/CORE/Impl.h
@@ -51,7 +51,7 @@
CGAL_INLINE_FUNCTION void *T::operator new( size_t size) \
{ return MemoryPool<T>::global_allocator().allocate(size); } \
CGAL_INLINE_FUNCTION void T::operator delete( void *p, size_t ) \
- { MemoryPool<T>::global_allocator().free(p); }
+ { (MemoryPool<T>::global_allocator().free)(p); }
#define CORE_MEMORY_IMPL_TEMPLATE_WITH_ONE_ARG(C) \
template <typename T> \
CGAL_INLINE_FUNCTION void *C<T>::operator new( size_t size) \
diff --git a/Classification/include/CGAL/Classification/Feature/Elevation.h b/Classification/include/CGAL/Classification/Feature/Elevation.h
index 175b20b6a44e..9ea9f267cc46 100644
--- a/Classification/include/CGAL/Classification/Feature/Elevation.h
+++ b/Classification/include/CGAL/Classification/Feature/Elevation.h
@@ -130,7 +130,7 @@ class Elevation : public Feature_base
std::nth_element (z.begin(), z.begin() + (z.size() / 10), z.end());
dtm_x(i,j) = z[z.size() / 10];
}
- dem.free();
+ (dem.free)();

if (grid.width() * grid.height() > input.size())
values.resize (input.size(), compressed_float(0));
@@ -162,7 +162,7 @@ class Elevation : public Feature_base
values[*it] = v;
}
}
- dtm_x.free();
+ (dtm_x.free)();

}

diff --git a/Classification/include/CGAL/Classification/Feature/Height_above.h b/Classification/include/CGAL/Classification/Feature/Height_above.h
index b59b108c1aca..3c85d27f91e2 100644
--- a/Classification/include/CGAL/Classification/Feature/Height_above.h
+++ b/Classification/include/CGAL/Classification/Feature/Height_above.h
@@ -100,7 +100,7 @@ class Height_above : public Feature_base
std::size_t J = grid.y(i);
values[i] = float(dtm(I,J) - get (point_map, *(input.begin() + i)).z());
}
- dtm.free();
+ (dtm.free)();
}

}
diff --git a/Classification/include/CGAL/Classification/Feature/Height_below.h b/Classification/include/CGAL/Classification/Feature/Height_below.h
index 223719341555..f71195dd3489 100644
--- a/Classification/include/CGAL/Classification/Feature/Height_below.h
+++ b/Classification/include/CGAL/Classification/Feature/Height_below.h
@@ -100,7 +100,7 @@ class Height_below : public Feature_base
std::size_t J = grid.y(i);
values[i] = float(get (point_map, *(input.begin() + i)).z() - dtm(I,J));
}
- dtm.free();
+ (dtm.free)();
}

}
diff --git a/Classification/include/CGAL/Classification/Feature/Vertical_range.h b/Classification/include/CGAL/Classification/Feature/Vertical_range.h
index 45b9c98d3ee7..a4df1591c13f 100644
--- a/Classification/include/CGAL/Classification/Feature/Vertical_range.h
+++ b/Classification/include/CGAL/Classification/Feature/Vertical_range.h
@@ -102,7 +102,7 @@ class Vertical_range : public Feature_base
std::size_t J = grid.y(i);
values[i] = dtm(I,J);
}
- dtm.free();
+ (dtm.free)();
}

}
diff --git a/Classification/include/CGAL/Classification/Image.h b/Classification/include/CGAL/Classification/Image.h
index 084e9572764a..3bd915f0b5d7 100644
--- a/Classification/include/CGAL/Classification/Image.h
+++ b/Classification/include/CGAL/Classification/Image.h
@@ -71,7 +71,7 @@ class Image
{
}

- void free()
+ void free BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
m_raw.reset();
m_sparse.reset();

diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h
index bd5dafbf0171..92a4ac768f58 100644
--- a/Installation/include/CGAL/config.h
+++ b/Installation/include/CGAL/config.h
@@ -37,6 +37,13 @@
#endif

#ifdef CGAL_INCLUDE_WINDOWS_DOT_H
+
+#if defined(_MSC_VER) && defined(_DEBUG)
+// Include support for memory leak detection
+// This is only available in debug mode and when _CRTDBG_MAP_ALLOC is defined.
+// It will include <crtdbg.h> which will redefine `malloc` and `free`.
+# define _CRTDBG_MAP_ALLOC 1
+#endif
// Mimic users including this file which defines min max macros
// and other names leading to name clashes
#include <windows.h>
16 changes: 5 additions & 11 deletions ports/cgal/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# Header only
vcpkg_buildpath_length_warning(37)
set(VCPKG_BUILD_TYPE release) # header-only

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO CGAL/cgal
REF v5.6.1
SHA512 943413bf3b94da066d47051b22f1c1b66a39a43dad865dd0e4912a9ae6508d9a490bcfe4ef7d662844e9a1ba6e552748fad785b52b2cce98133c2dfdfbfe1a4d
REF v${VERSION}
SHA512 f61e608898d798b90ce07260928b682161f00e964b43b9876ef6604d10c30787a0814e13afde90f7d703efd6b83c61dd4a9d9f50d21068bd50c5c15f94b5755b
HEAD_REF master
PATCHES
PR-8523__CGAL_CGAL-protect_against_macro_free-GF.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
qt WITH_CGAL_Qt5
)
lrineau marked this conversation as resolved.
Show resolved Hide resolved

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
Expand All @@ -26,7 +21,6 @@ vcpkg_cmake_configure(
MAYBE_UNUSED_VARIABLES
CGAL_BUILD_THREE_DOC
CGAL_HEADER_ONLY
WITH_CGAL_Qt5
)

vcpkg_cmake_install()
Expand Down
11 changes: 4 additions & 7 deletions ports/cgal/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "cgal",
"version": "5.6.1",
"port-version": 1,
"version": "6.0",
"description": "The Computational Geometry Algorithms Library (CGAL) is a C++ library that aims to provide easy access to efficient and reliable algorithms in computational geometry.",
"homepage": "https://github.com/CGAL/cgal",
"license": "GPL-3.0-or-later AND LGPL-3.0-or-later AND BSL-1.0",
Expand Down Expand Up @@ -67,14 +66,12 @@
"description": "Qt GUI support for CGAL",
"dependencies": [
"eigen3",
"qt5-3d",
{
"name": "qt5-base",
"name": "qtbase",
"default-features": false
},
"qt5-script",
"qt5-svg",
"qt5-xmlpatterns"
"qtdeclarative",
"qtsvg"
]
}
}
Expand Down
24 changes: 0 additions & 24 deletions ports/cgal/x86_windows.patch

This file was deleted.

4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,8 +1585,8 @@
"port-version": 6
},
"cgal": {
"baseline": "5.6.1",
"port-version": 1
"baseline": "6.0",
"port-version": 0
},
"cgicc": {
"baseline": "3.2.20",
Expand Down
5 changes: 5 additions & 0 deletions versions/c-/cgal.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f1be286404a2a318493e10e1818b244e2772f2f0",
"version": "6.0",
"port-version": 0
},
{
"git-tree": "194089df2abf78f3701c7be7d51ddb25feaf108e",
"version": "5.6.1",
Expand Down