From 3632c8143596eadf2018a1725bf7dbb451ca746d Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 9 Jun 2020 15:30:42 +0200 Subject: [PATCH] clang/gcc/cmake: move handling of suppressed deprecated-copy warnings from source file to CMake file to more easily support gcc 10 --- cMake/FreeCAD_Helpers/SetupEigen.cmake | 9 +++++++++ src/Gui/CMakeLists.txt | 5 +++++ src/Gui/NaviCube.cpp | 6 ------ src/Mod/Mesh/App/CMakeLists.txt | 10 ++++++++++ src/Mod/Mesh/App/Core/Approximation.cpp | 6 ------ src/Mod/Mesh/App/Core/CylinderFit.cpp | 6 ------ src/Mod/Mesh/App/Core/KDTree.cpp | 6 ------ src/Mod/Mesh/App/Core/SphereFit.cpp | 6 ------ src/Mod/Part/App/CMakeLists.txt | 8 ++++++++ src/Mod/Part/App/GeometryCurvePyImp.cpp | 6 ------ src/Mod/Part/App/GeometrySurfacePyImp.cpp | 6 ------ src/Mod/Sketcher/App/CMakeLists.txt | 10 +++++++++- src/Mod/Sketcher/App/planegcs/GCS.cpp | 6 ------ src/Mod/Sketcher/App/planegcs/qp_eq.cpp | 6 ------ 14 files changed, 41 insertions(+), 55 deletions(-) diff --git a/cMake/FreeCAD_Helpers/SetupEigen.cmake b/cMake/FreeCAD_Helpers/SetupEigen.cmake index 8e09027a07..48ae286728 100644 --- a/cMake/FreeCAD_Helpers/SetupEigen.cmake +++ b/cMake/FreeCAD_Helpers/SetupEigen.cmake @@ -17,4 +17,13 @@ macro(SetupEigen) set (BUILD_FLAT_MESH OFF) endif() + # Older versions raise the warning -Wdeprecated-copy with clang10/gcc10 + if (${EIGEN3_VERSION} VERSION_LESS "3.3.8") + unset(_flag_found CACHE) + check_cxx_compiler_flag("-Wno-deprecated-copy" _flag_found) + if (_flag_found) + set (EIGEN3_NO_DEPRECATED_COPY "-Wno-deprecated-copy") + endif () + endif() + endmacro(SetupEigen) diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 6f3b925a70..287a38ddac 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -1345,6 +1345,11 @@ if (FREECAD_USE_QT_FILEDIALOG) set_source_files_properties(FileDialog.cpp PROPERTIES COMPILE_FLAGS -DUSE_QT_FILEDIALOG) endif() +# Suppress some very long Eigen3 warnings of older versions +if (EIGEN3_NO_DEPRECATED_COPY) + set_source_files_properties(NaviCube.cpp PROPERTIES COMPILE_FLAGS ${EIGEN3_NO_DEPRECATED_COPY}) +endif () + add_library(FreeCADGui SHARED ${FreeCADGui_SRCS}) target_link_libraries(FreeCADGui ${FreeCADGui_LIBS}) diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index 1b5d56243b..2690031d42 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -114,12 +114,6 @@ # include #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - //#include #include #include diff --git a/src/Mod/Mesh/App/CMakeLists.txt b/src/Mod/Mesh/App/CMakeLists.txt index 7ef7aa1354..2ecfb6084d 100644 --- a/src/Mod/Mesh/App/CMakeLists.txt +++ b/src/Mod/Mesh/App/CMakeLists.txt @@ -376,6 +376,16 @@ if(FREECAD_USE_PCH) ADD_MSVC_PRECOMPILED_HEADER(Mesh PreCompiled.h PreCompiled.cpp PCH_SRCS) endif(FREECAD_USE_PCH) +# Suppress some very long Eigen3 warnings of older versions +if (EIGEN3_NO_DEPRECATED_COPY) + set_source_files_properties( + Core/Approximation.cpp + Core/CylinderFit.cpp + Core/SphereFit.cpp + Core/KDTree.cpp + PROPERTIES COMPILE_FLAGS ${EIGEN3_NO_DEPRECATED_COPY}) +endif () + add_library(Mesh SHARED ${Core_SRCS} ${WildMagic4_SRCS} ${Mesh_SRCS}) target_link_libraries(Mesh ${Mesh_LIBS}) diff --git a/src/Mod/Mesh/App/Core/Approximation.cpp b/src/Mod/Mesh/App/Core/Approximation.cpp index 42494427ef..a115792c2d 100644 --- a/src/Mod/Mesh/App/Core/Approximation.cpp +++ b/src/Mod/Mesh/App/Core/Approximation.cpp @@ -29,12 +29,6 @@ # include #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #include "Approximation.h" #include "Elements.h" #include "Utilities.h" diff --git a/src/Mod/Mesh/App/Core/CylinderFit.cpp b/src/Mod/Mesh/App/Core/CylinderFit.cpp index 6b46b6baec..d5bfb3480f 100644 --- a/src/Mod/Mesh/App/Core/CylinderFit.cpp +++ b/src/Mod/Mesh/App/Core/CylinderFit.cpp @@ -61,12 +61,6 @@ # include #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #include "CylinderFit.h" #include #include diff --git a/src/Mod/Mesh/App/Core/KDTree.cpp b/src/Mod/Mesh/App/Core/KDTree.cpp index 5c8d126cf9..c7a7f72377 100644 --- a/src/Mod/Mesh/App/Core/KDTree.cpp +++ b/src/Mod/Mesh/App/Core/KDTree.cpp @@ -28,12 +28,6 @@ #ifndef _PreComp_ #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #include "KDTree.h" #include diff --git a/src/Mod/Mesh/App/Core/SphereFit.cpp b/src/Mod/Mesh/App/Core/SphereFit.cpp index fcf0cdcc53..dfc1166858 100644 --- a/src/Mod/Mesh/App/Core/SphereFit.cpp +++ b/src/Mod/Mesh/App/Core/SphereFit.cpp @@ -28,12 +28,6 @@ # include #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #include "SphereFit.h" #include diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt index d2582cc562..21d63cf558 100644 --- a/src/Mod/Part/App/CMakeLists.txt +++ b/src/Mod/Part/App/CMakeLists.txt @@ -397,6 +397,14 @@ if(FREECAD_USE_PCH) ADD_MSVC_PRECOMPILED_HEADER(Part PreCompiled.h PreCompiled.cpp PCH_SRCS) endif(FREECAD_USE_PCH) +# Suppress some very long Eigen3 warnings of older versions +if (EIGEN3_NO_DEPRECATED_COPY) + set_source_files_properties( + GeometryCurvePyImp.cpp + GeometrySurfacePyImp.cpp + PROPERTIES COMPILE_FLAGS ${EIGEN3_NO_DEPRECATED_COPY}) +endif () + add_library(Part SHARED ${Part_SRCS}) target_link_libraries(Part ${Part_LIBS}) diff --git a/src/Mod/Part/App/GeometryCurvePyImp.cpp b/src/Mod/Part/App/GeometryCurvePyImp.cpp index 16b424eebc..813a8932ab 100644 --- a/src/Mod/Part/App/GeometryCurvePyImp.cpp +++ b/src/Mod/Part/App/GeometryCurvePyImp.cpp @@ -23,12 +23,6 @@ #include "PreCompiled.h" -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #ifndef _PreComp_ # include # include diff --git a/src/Mod/Part/App/GeometrySurfacePyImp.cpp b/src/Mod/Part/App/GeometrySurfacePyImp.cpp index c4bb984e77..832c62fef0 100644 --- a/src/Mod/Part/App/GeometrySurfacePyImp.cpp +++ b/src/Mod/Part/App/GeometrySurfacePyImp.cpp @@ -23,12 +23,6 @@ #include "PreCompiled.h" -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #ifndef _PreComp_ # include # include diff --git a/src/Mod/Sketcher/App/CMakeLists.txt b/src/Mod/Sketcher/App/CMakeLists.txt index c9413bec43..013adeedf9 100644 --- a/src/Mod/Sketcher/App/CMakeLists.txt +++ b/src/Mod/Sketcher/App/CMakeLists.txt @@ -90,7 +90,6 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS}) SET(PlaneGCS_SRCS - planegcs/qp_eq.h planegcs/GCS.cpp planegcs/GCS.h planegcs/Util.h @@ -139,6 +138,15 @@ if(FREECAD_USE_PCH) ADD_MSVC_PRECOMPILED_HEADER(Sketcher PreCompiled.h PreCompiled.cpp Sketcher_CPP_SRCS) endif(FREECAD_USE_PCH) +# Suppress some very long Eigen3 warnings of older versions +if (EIGEN3_NO_DEPRECATED_COPY) + set_source_files_properties( + planegcs/GCS.cpp + planegcs/SubSystem.cpp + planegcs/qp_eq.cpp + PROPERTIES COMPILE_FLAGS ${EIGEN3_NO_DEPRECATED_COPY}) +endif () + SET_BIN_DIR(Sketcher Sketcher /Mod/Sketcher) SET_PYTHON_PREFIX_SUFFIX(Sketcher) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index a65dc65825..76ecb4fef5 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -25,12 +25,6 @@ #pragma warning(disable : 4996) #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - //#define _GCS_DEBUG //#define _GCS_DEBUG_SOLVER_JACOBIAN_QR_DECOMPOSITION_TRIANGULAR_MATRIX //#define _DEBUG_TO_FILE // Many matrices surpass the report view string size. diff --git a/src/Mod/Sketcher/App/planegcs/qp_eq.cpp b/src/Mod/Sketcher/App/planegcs/qp_eq.cpp index 3133937b7e..7eeb58fafc 100644 --- a/src/Mod/Sketcher/App/planegcs/qp_eq.cpp +++ b/src/Mod/Sketcher/App/planegcs/qp_eq.cpp @@ -24,12 +24,6 @@ #pragma warning(disable : 4244) #endif -#if defined(__clang__) && defined(__has_warning) -#if __has_warning("-Wdeprecated-copy") -# pragma clang diagnostic ignored "-Wdeprecated-copy" -#endif -#endif - #include #include