diff --git a/projects/cmb.cmake b/projects/cmb.cmake index 0aa6488eaa95303971fe4a2b216b095b5f2b763c..41dbd805fd8215877e96aa9610c21f376f469b70 100644 --- a/projects/cmb.cmake +++ b/projects/cmb.cmake @@ -67,7 +67,7 @@ superbuild_add_project(cmb DEFAULT_ON ${cmb_step_keyword} ${cmb_lfs_steps} download update DEPENDS boost moab nlohmannjson python3 paraview pybind11 - qt5 smtk + qt5 smtk cxx17 DEPENDS_OPTIONAL ${cmb_extra_optional_dependencies} cmbusersguide smtkusersguide cmbworkflows opencascadesession diff --git a/projects/moab.cmake b/projects/moab.cmake index c6ebe53d9f801feef3fdbef2411b331379ad42f6..db3d609e5a13df9b25a303b3d5885468c493482f 100644 --- a/projects/moab.cmake +++ b/projects/moab.cmake @@ -15,8 +15,7 @@ elseif (UNIX) endif () superbuild_add_project(moab - DEPENDS eigen hdf5 netcdf - DEPENDS_OPTIONAL cxx11 + DEPENDS eigen hdf5 netcdf cxx17 CMAKE_ARGS -Wno-dev ${moab_shared_settings} @@ -71,6 +70,9 @@ superbuild_apply_patch(moab ext-deps superbuild_apply_patch(moab no-mtune "Disable `-mtune=native` flag") +superbuild_apply_patch(moab cxx17-support + "Support consuming from C++17 projects") + # macOS on arm64 makes copies of classes it can completely see and the `typeid` # mechanism ends up being confused. This is used inside of MOAB to determine # what kind of interface to generate, so the calling library needs to agree on diff --git a/projects/patches/moab-cxx17-support.patch b/projects/patches/moab-cxx17-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..0643818542c7694eff97f75d189391ddfed519e0 --- /dev/null +++ b/projects/patches/moab-cxx17-support.patch @@ -0,0 +1,267 @@ +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/HigherOrderFactory.cpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/HigherOrderFactory.cpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/HigherOrderFactory.cpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/HigherOrderFactory.cpp 2025-03-02 03:58:24.858227879 +0100 +@@ -940,21 +940,21 @@ + std::vector adj_list_1, adj_list_2, adj_entities; + a_fact->get_adjacencies(connectivity[0], adj_list_1); + + // remove meshsets + adj_list_1.erase(std::remove_if(adj_list_1.begin(), adj_list_1.end(), +- std::bind2nd(std::greater(),low_meshset)), adj_list_1.end()); ++ [&low_meshset](EntityHandle const& h) { return low_meshset > h; }), adj_list_1.end()); + + size_t i; + for( i=1; iget_adjacencies(connectivity[i], adj_list_2); + + // remove meshsets + adj_list_2.erase(std::remove_if(adj_list_2.begin(), adj_list_2.end(), +- std::bind2nd(std::greater(),low_meshset)), adj_list_2.end()); ++ [&low_meshset](EntityHandle const& h) { return low_meshset > h; }), adj_list_2.end()); + + //intersect the 2 lists + adj_entities.clear(); + std::set_intersection(adj_list_1.begin(), adj_list_1.end(), + adj_list_2.begin(), adj_list_2.end(), +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/io/DamselUtil.hpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/io/DamselUtil.hpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/io/DamselUtil.hpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/io/DamselUtil.hpp 2025-03-03 11:53:39.772300014 +0100 +@@ -6,10 +6,12 @@ + #include "DebugOutput.hpp" + + #include "damsel.h" + #include "damsel-internal.h" + ++#include ++ + // Some macros to handle error checking (cribbed from WriteHDF5). + // All macros contain a "return" statement. These macros are coded with a do if while + // to allow statements calling them to be terminated with a ; + #define CHK_DMSL_ERR(A, B) \ + do { \ +@@ -60,18 +62,18 @@ + Tag mTagh; + damsel_handle dTagh; + TagType tagType; + }; + +- template struct MtagP : std::unary_function { ++ template struct MtagP : std::function { + public: + MtagP(const Tag &th) { tH = th; } + bool operator() (const T &tclass) { return tclass.mTagh == tH; } + Tag tH; + }; + +- template struct DtagP : std::unary_function { ++ template struct DtagP : std::function { + public: + DtagP(const damsel_handle &th) { tH = th; } + bool operator() (const T &tclass) { return tclass.dTagh == tH; } + damsel_handle tH; + }; +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/io/ReadHDF5.cpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/io/ReadHDF5.cpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/io/ReadHDF5.cpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/io/ReadHDF5.cpp 2025-03-02 03:59:25.908151896 +0100 +@@ -1223,11 +1223,11 @@ + if (MB_SUCCESS != rval || is_error(status)) + MB_SET_ERR(MB_FAILURE, "ReadHDF5 Failure"); + // Convert from table indices to file IDs and add to result list + std::sort(indices.begin(), indices.end(), std::greater()); + std::transform(indices.begin(), indices.end(), range_inserter(file_ids), +- std::bind1st(std::plus(), start_id)); ++ [&start_id](long idx) { return idx + start_id; }); + indices.clear(); + } + + if (!tag.have_sparse) + return MB_SUCCESS; +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/mesquite/Mesh/MeshImpl.cpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/mesquite/Mesh/MeshImpl.cpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/mesquite/Mesh/MeshImpl.cpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/mesquite/Mesh/MeshImpl.cpp 2025-02-28 23:55:10.365634955 +0100 +@@ -1252,11 +1252,11 @@ + myMesh->set_vertex_byte( (size_t)vertex[i], byte_array[i], err ); + MSQ_ERRRTN(err); + } + } + +-template struct cast_handle : public std::unary_function ++template struct cast_handle : public std::function + { + T operator()( size_t idx ) const + { + return reinterpret_cast(idx); + } +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/BVHTree.hpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/BVHTree.hpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/BVHTree.hpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/BVHTree.hpp 2025-03-03 11:53:39.586299828 +0100 +@@ -14,10 +14,11 @@ + #include "moab/CN.hpp" + + #include + #include + #include ++#include + #include + #include + #include + + namespace moab { +@@ -151,22 +152,22 @@ + return *this; + } + }; //SplitData + + class Split_comparator : +- public std::binary_function< SplitData, SplitData, bool> { ++ public std::function< bool(SplitData, SplitData)> { + inline double objective(const SplitData & a) const{ + return a.Lmax*a.nl - a.Rmin*a.nr; + } + public: + bool operator()(const SplitData &a, const SplitData &b) const { + return objective( a) < objective( b); + } + }; //Split_comparator + + class HandleData_comparator : +- public std::binary_function { ++ public std::function { + public: + bool operator()(const HandleData &a, const HandleData &b) { + return a.myDim < b.myDim || + (a.myDim == b.myDim && + a.myHandle < b.myHandle); +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/Interface.hpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/Interface.hpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/Interface.hpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/Interface.hpp 2025-02-28 23:55:10.332634833 +0100 +@@ -2050,11 +2050,11 @@ + + //! predicate for STL algorithms. Returns true if the entity handle is + //! of the specified type. For example, to remove all the tris out of a list + //! of 2D entities retrieved using get_adjacencies you could do + //! std::remove_if(list.begin(), list.end(), type_equals(gMB, MBTRI)); +-class type_equals : public std::unary_function ++class type_equals : public std::function + { + public: + //! interface object + Interface* meshDB; + +@@ -2073,11 +2073,11 @@ + + //! predicate for STL algorithms. Returns true if the entity handle is not + //! of the specified type. For example, to remove all but the tris out of a list + //! of 2D entities retrieved using get_adjacencies you could do + //! std::remove_if(list.begin(), list.end(), type_not_equals(gMB, MBTRI)); +-class type_not_equals : public std::unary_function ++class type_not_equals : public std::function + { + public: + + //! interface object + Interface* meshDB; +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/point_locater/tree/bvh_tree.hpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/point_locater/tree/bvh_tree.hpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/point_locater/tree/bvh_tree.hpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/point_locater/tree/bvh_tree.hpp 2025-03-03 11:53:39.615299857 +0100 +@@ -12,10 +12,11 @@ + #include + #include + #include + #include + #include ++#include + #include + #include + #include + #include + #include "common_tree.hpp" +@@ -56,11 +57,11 @@ + }; // _Node + + + template< typename Split> + class Split_comparator : +- public std::binary_function< Split, Split, bool> { ++ public std::function< bool(Split, Split)> { + inline double objective( const Split & a) const{ + return a.Lmax*a.nl - a.Rmin*a.nr; + } + public: + bool operator()( const Split & a, const Split & b) const{ +@@ -68,11 +69,11 @@ + } + }; //Split_comparator + + template< typename Iterator> + class Iterator_comparator : +- public std::binary_function< Iterator, Iterator, bool> { ++ public std::function< bool(Iterator, Iterator)> { + public: + bool operator()( const Iterator & a, const Iterator & b) const{ + return a->second.second < b->second.second || + ( !(b->second.second < a->second.second) + && a->first < b->first); +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/point_locater/tree/common_tree.hpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/point_locater/tree/common_tree.hpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/moab/point_locater/tree/common_tree.hpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/moab/point_locater/tree/common_tree.hpp 2025-03-03 11:53:39.662299904 +0100 +@@ -8,10 +8,11 @@ + #include + #include + #include + #include + #include ++#include + #include + #include + #include + #include + +@@ -74,11 +75,11 @@ + return true; + } + + namespace { + template< typename T> +- struct Compute_center: public std::binary_function< T, T, T> { ++ struct Compute_center: public std::function< T(T, T)> { + T operator()( const T a, const T b) const{ + return (a+b)/2.0; + } + }; //Compute_center + } //non-exported center computation. +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/parallel/ParallelComm.cpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/parallel/ParallelComm.cpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/parallel/ParallelComm.cpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/parallel/ParallelComm.cpp 2025-03-02 03:58:51.756187939 +0100 +@@ -4226,11 +4226,11 @@ + + // Remove rmv_ents from the contents list + iface_ents = subtract(iface_ents, rmv_ents); + // Compress the pstat vector (removing 0x0's) + std::remove_if(pstat.begin(), pstat.end(), +- std::bind2nd(std::equal_to(), 0x0)); ++ [](unsigned char c) { return c == 0x0; }); + // Fold the not_owned bit into remaining values + unsigned int sz = iface_ents.size(); + for (i = 0; i < sz; i++) + pstat[i] |= PSTATUS_NOT_OWNED; + +diff -u -Nr -U5 moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/ScdInterface.cpp moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/ScdInterface.cpp +--- moab-6425a480ffe8e08b96453618fc5530e08e68ae8a/src/ScdInterface.cpp 2017-11-29 17:03:38.000000000 +0100 ++++ moab-6425a480ffe8e08b96453618fc5530e08e68ae8a.cxx17-support/src/ScdInterface.cpp 2025-03-02 03:56:53.680372428 +0100 +@@ -80,12 +80,11 @@ + boxes, Interface::UNION); + searchedBoxes = true; + if (!boxes.empty()) { + scdBoxes.resize(boxes.size()); + rval = mbImpl->tag_get_data(boxSetTag, boxes, &scdBoxes[0]); +- ScdBox *dum = NULL; +- std::remove_if(scdBoxes.begin(), scdBoxes.end(), std::bind2nd(std::equal_to(), dum) ) ; ++ std::remove_if(scdBoxes.begin(), scdBoxes.end(), [](ScdBox* box) { return box == NULL; }) ; + } + } + + for (std::vector::iterator vit = scdBoxes.begin(); vit != scdBoxes.end(); ++vit) + scd_boxes.insert((*vit)->box_set());