From d349cd4a6732fb7b1a59c29b161b4cef00635c5d Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Fri, 5 Dec 2025 16:05:07 +0000 Subject: [PATCH] Configuration - Update compiler flags and includes for macOS (#884) - Added flags to suppress elaborated-enum-base warnings for newer Clang versions on macOS - Updated includes in TDF_AttributeMap.hxx to include Standard_Handle.hxx - Modified hash functions in GeomHash and Geom2dHash classes to use Standard_CStringHasher instead of Standard_HashUtils --- adm/cmake/occt_defs_flags.cmake | 9 +++++++-- src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeMap.hxx | 1 + src/ApplicationFramework/TKLCAF/TDF/TDF_Label.lxx | 6 ++++-- .../TKG2d/Geom2dHash/Geom2dHash_CurveHasher.cxx | 4 ++-- src/ModelingData/TKG3d/GeomHash/GeomHash_CurveHasher.cxx | 4 ++-- .../TKG3d/GeomHash/GeomHash_SurfaceHasher.cxx | 4 ++-- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/adm/cmake/occt_defs_flags.cmake b/adm/cmake/occt_defs_flags.cmake index 51f14f9f81..995d7b0c3b 100644 --- a/adm/cmake/occt_defs_flags.cmake +++ b/adm/cmake/occt_defs_flags.cmake @@ -42,6 +42,10 @@ else() if (APPLE) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") + # Suppress elaborated-enum-base warnings from Apple system headers (CoreFoundation/CoreGraphics) + # when using newer Clang versions (LLVM 18+) that are stricter about this C++ standard violation + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-elaborated-enum-base") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-elaborated-enum-base") endif() add_definitions(-DOCC_CONVERT_SIGNALS) endif() @@ -195,8 +199,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]") # CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated. set (CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") endif() - if (NOT WIN32) - # Optimize size of binaries + if (NOT WIN32 AND NOT APPLE) + # Optimize size of binaries (strip symbols) + # Note: -s is obsolete on macOS, so we only apply it on Linux set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") endif() endif() diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeMap.hxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeMap.hxx index 219465a546..20dae0ed05 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeMap.hxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_AttributeMap.hxx @@ -16,6 +16,7 @@ #ifndef TDF_AttributeMap_HeaderFile #define TDF_AttributeMap_HeaderFile +#include #include #include diff --git a/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.lxx b/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.lxx index 080cf25801..c468e1709c 100644 --- a/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.lxx +++ b/src/ApplicationFramework/TKLCAF/TDF/TDF_Label.lxx @@ -23,14 +23,16 @@ #include #include +#include + namespace std { template <> struct hash { - size_t operator()(const TDF_Label& theNode) const + size_t operator()(const TDF_Label& theLabel) const noexcept { - return std::hash{}(theNode.myLabelNode); + return static_cast(reinterpret_cast(theLabel.myLabelNode)); } }; } // namespace std diff --git a/src/ModelingData/TKG2d/Geom2dHash/Geom2dHash_CurveHasher.cxx b/src/ModelingData/TKG2d/Geom2dHash/Geom2dHash_CurveHasher.cxx index 8b29a7642b..728bb1bafb 100644 --- a/src/ModelingData/TKG2d/Geom2dHash/Geom2dHash_CurveHasher.cxx +++ b/src/ModelingData/TKG2d/Geom2dHash/Geom2dHash_CurveHasher.cxx @@ -13,7 +13,7 @@ #include -#include +#include #include #include #include @@ -83,7 +83,7 @@ std::size_t Geom2dHash_CurveHasher::operator()(const Handle(Geom2d_Curve)& theCu } // Unknown curve type - hash the type name - return std::hash{}(theCurve->DynamicType()->Name()); + return Standard_CStringHasher{}(theCurve->DynamicType()->Name()); } //================================================================================================= diff --git a/src/ModelingData/TKG3d/GeomHash/GeomHash_CurveHasher.cxx b/src/ModelingData/TKG3d/GeomHash/GeomHash_CurveHasher.cxx index f742e6cb42..33aac0711d 100644 --- a/src/ModelingData/TKG3d/GeomHash/GeomHash_CurveHasher.cxx +++ b/src/ModelingData/TKG3d/GeomHash/GeomHash_CurveHasher.cxx @@ -13,7 +13,7 @@ #include -#include +#include #include #include #include @@ -83,7 +83,7 @@ std::size_t GeomHash_CurveHasher::operator()(const Handle(Geom_Curve)& theCurve) } // Unknown curve type - hash the type name - return std::hash{}(theCurve->DynamicType()->Name()); + return Standard_CStringHasher{}(theCurve->DynamicType()->Name()); } //================================================================================================= diff --git a/src/ModelingData/TKG3d/GeomHash/GeomHash_SurfaceHasher.cxx b/src/ModelingData/TKG3d/GeomHash/GeomHash_SurfaceHasher.cxx index 01fa9dbb83..94683a2479 100644 --- a/src/ModelingData/TKG3d/GeomHash/GeomHash_SurfaceHasher.cxx +++ b/src/ModelingData/TKG3d/GeomHash/GeomHash_SurfaceHasher.cxx @@ -13,7 +13,7 @@ #include -#include +#include #include #include #include @@ -100,7 +100,7 @@ std::size_t GeomHash_SurfaceHasher::operator()( } // Unknown surface type - hash the type name - return std::hash{}(theSurface->DynamicType()->Name()); + return Standard_CStringHasher{}(theSurface->DynamicType()->Name()); } //=================================================================================================