From 2d2bf0bbc76e39b4a4da7e2d76fb522048549688 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 26 Jan 2022 10:08:28 +0100 Subject: [PATCH] CMake : Improve handling of compiler flags (#8486) #8478 Code cleanup to fix some warnings Several adjustments to improve the specification and usage of compile flags. --- ApplicationLibCode/CMakeLists.txt | 58 +++++++++------ ApplicationLibCode/Commands/CMakeLists.txt | 33 ++++++++- .../Summary/RimEnsembleStatisticsCase.cpp | 2 +- .../WellPath/RimWellPathGroup.cpp | 2 +- .../UnitTests/RigSlice2D-Test.cpp | 4 +- .../UserInterface/RiuCadNavigation.cpp | 6 +- .../UserInterface/RiuGeoQuestNavigation.cpp | 4 +- .../UserInterface/RiuGridCrossQwtPlot.cpp | 2 +- .../UserInterface/RiuQwtPlotCurve.cpp | 2 +- .../UserInterface/RiuRmsNavigation.cpp | 4 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 2 +- CMakeLists.txt | 73 ++++++++++++++++++- Fwk/AppFwk/CommonCode/cafMouseState.cpp | 2 +- .../cafPdmUiCommandSystemProxy.cpp | 3 +- .../cafPdmUiFieldEditorHelper.cpp | 3 +- .../cafUserInterface/cafPdmUiTreeViewEditor.h | 3 +- Fwk/AppFwk/cafViewer/cafCadNavigation.cpp | 6 +- Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp | 2 +- .../cafViewer/cafCeetronPlusNavigation.cpp | 4 +- Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp | 2 +- GrpcInterface/CMakeLists.txt | 13 ++-- ThirdParty/clipper/CMakeLists.txt | 4 + ThirdParty/custom-opm-common/CMakeLists.txt | 16 ++-- .../custom-opm-flowdiag-app/CMakeLists.txt | 4 + 24 files changed, 190 insertions(+), 64 deletions(-) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 564ddf3e3b..586d91e4b1 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -339,30 +339,42 @@ if(RESINSIGHT_ENABLE_PRECOMPILED_HEADERS) ) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set_target_properties( - ${PROJECT_NAME} - PROPERTIES - COMPILE_FLAGS - "-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch" +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options( + ApplicationLibCode PRIVATE -Wall -Wno-unused-parameter -Wno-reorder + -Wno-parentheses -Wno-switch ) - # Treat warnings as errors if asked to do so - if(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS) - set_target_properties( - ${PROJECT_NAME} - PROPERTIES - COMPILE_FLAGS - "-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch -Werror" - ) - endif() +endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set_target_properties( - ${PROJECT_NAME} - PROPERTIES - COMPILE_FLAGS - "-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch -Wno-delete-abstract-non-virtual-dtor -Wno-undefined-var-template -Wno-invalid-source-encoding -Wno-enum-compare -Wno-call-to-pure-virtual-from-ctor-dtor -Wno-unused-variable -Wno-unused-private-field -Wno-unused-lambda-capture -Wno-delete-non-abstract-non-virtual-dtor -Wno-braced-scalar-init -Wno-tautological-constant-out-of-range-compare" - ) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + + target_compile_options( + ApplicationLibCode + PRIVATE -Wall + -Wno-unused-parameter + -Wno-reorder + -Wno-parentheses + -Wno-switch + -Wno-delete-abstract-non-virtual-dtor + -Wno-undefined-var-template + -Wno-invalid-source-encoding + -Wno-enum-compare + -Wno-call-to-pure-virtual-from-ctor-dtor + -Wno-unused-variable + -Wno-unused-private-field + -Wno-unused-lambda-capture + -Wno-delete-non-abstract-non-virtual-dtor + -Wno-braced-scalar-init + -Wno-tautological-constant-out-of-range-compare + -Wno-undefined-var-template + ) +endif() + +if(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS) + if(MSVC) + target_compile_options(ApplicationLibCode PRIVATE /WX) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_compile_options(ApplicationLibCode PRIVATE -Werror) endif() endif() @@ -376,7 +388,7 @@ if(MSVC) # set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190 # /wd4100 /wd4127") - set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005") + set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005 /wd4251") if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10) # Disable warning for deprecated functions in newer versions of Qt diff --git a/ApplicationLibCode/Commands/CMakeLists.txt b/ApplicationLibCode/Commands/CMakeLists.txt index a4ad719315..fdc96a1fbc 100644 --- a/ApplicationLibCode/Commands/CMakeLists.txt +++ b/ApplicationLibCode/Commands/CMakeLists.txt @@ -67,6 +67,37 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/ThirdParty/custom-opm-common/opm-common ) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options( + Commands + PRIVATE -Wall + -Wno-unused-parameter + -Wno-reorder + -Wno-parentheses + -Wno-switch + -Wno-delete-abstract-non-virtual-dtor + -Wno-undefined-var-template + -Wno-invalid-source-encoding + -Wno-enum-compare + -Wno-call-to-pure-virtual-from-ctor-dtor + -Wno-unused-variable + -Wno-unused-private-field + -Wno-unused-lambda-capture + -Wno-delete-non-abstract-non-virtual-dtor + -Wno-braced-scalar-init + -Wno-tautological-constant-out-of-range-compare + -Wno-undefined-var-template + ) +endif() + +if(RESINSIGHT_TREAT_WARNINGS_AS_ERRORS) + if(MSVC) + target_compile_options(Commands PRIVATE /WX) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_compile_options(Commands PRIVATE -Werror) + endif() +endif() + if(MSVC) # The following warnings are supposed to be used in ResInsight, but # temporarily disabled to avoid too much noise warning C4245: 'return': @@ -77,7 +108,7 @@ if(MSVC) # set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190 # /wd4100 /wd4127") - set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005") + set(BUILD_FLAGS_FOR_MSVC "/wd4190 /wd4100 /wd4127 /wd4245 /wd4005 /wd4573") if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10) # Disable warning for deprecated functions in newer versions of Qt diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp index 30113951f4..8fd7c45f0a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleStatisticsCase.cpp @@ -253,7 +253,7 @@ std::vector RimEnsembleStatisticsCase::validSummaryCases( const } } - for ( const auto [sumCase, lastTimeStep] : times ) + for ( const auto& [sumCase, lastTimeStep] : times ) { // Previous versions tested on identical first time step, this test is now removed. For large simulations with // numerical issues the first time step can be slightly different diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp index 6a54d448b3..febc831b98 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathGroup.cpp @@ -252,7 +252,7 @@ void RimWellPathGroup::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin std::vector RimWellPathGroup::wellPathGeometries() const { std::vector allGeometries; - for ( const auto child : m_childWellPaths() ) + for ( const auto& child : m_childWellPaths() ) { if ( child->wellPathGeometry() ) { diff --git a/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp b/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp index ddc639f4d7..1019551755 100644 --- a/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp +++ b/ApplicationLibCode/UnitTests/RigSlice2D-Test.cpp @@ -16,9 +16,9 @@ TEST( RigSlice2DTest, GetAndSet ) for ( size_t y = 0; y < ny; y++ ) for ( size_t x = 0; x < nx; x++ ) - slice.setValue( x, y, x * y ); + slice.setValue( x, y, static_cast( x * y ) ); for ( size_t y = 0; y < ny; y++ ) for ( size_t x = 0; x < nx; x++ ) - EXPECT_EQ( x * y, slice.getValue( x, y ) ); + EXPECT_EQ( static_cast( x * y ), slice.getValue( x, y ) ); } diff --git a/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp b/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp index c849a27821..1b2bda65de 100644 --- a/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp +++ b/ApplicationLibCode/UserInterface/RiuCadNavigation.cpp @@ -57,7 +57,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) int translatedMousePosX, translatedMousePosY; cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); - if ( me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) + if ( me->button() == Qt::MiddleButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) { this->pickAndSetPointOfInterest( me->x(), me->y() ); @@ -67,7 +67,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) isEventHandled = true; } else if ( me->button() == Qt::LeftButton || - ( me->button() == Qt::MidButton && ( me->modifiers() & Qt::ShiftModifier ) ) ) + ( me->button() == Qt::MiddleButton && ( me->modifiers() & Qt::ShiftModifier ) ) ) { m_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY ); m_isNavigating = true; @@ -82,7 +82,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::MidButton || me->button() == Qt::LeftButton ) + if ( me->button() == Qt::MiddleButton || me->button() == Qt::LeftButton ) { m_trackball->endNavigation(); diff --git a/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp b/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp index eb44867d0c..72c810824a 100644 --- a/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp +++ b/ApplicationLibCode/UserInterface/RiuGeoQuestNavigation.cpp @@ -66,7 +66,7 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent ) m_hasMovedMouseDuringNavigation = false; isEventHandled = true; } - else if ( me->button() == Qt::MidButton ) + else if ( me->button() == Qt::MiddleButton ) { if ( me->modifiers() == Qt::NoModifier ) { @@ -84,7 +84,7 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::LeftButton || me->button() == Qt::MidButton ) + if ( me->button() == Qt::LeftButton || me->button() == Qt::MiddleButton ) { m_trackball->endNavigation(); diff --git a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp index d67923ca52..e7a13fb9da 100644 --- a/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -76,7 +76,7 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren // MidButton for the panning QwtPlotPanner* panner = new QwtPlotPanner( qwtPlot()->canvas() ); - panner->setMouseButton( Qt::MidButton ); + panner->setMouseButton( Qt::MiddleButton ); auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot() ); diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp index babf2fee97..8ec169e04f 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp @@ -381,7 +381,7 @@ void RiuQwtPlotCurve::clearErrorBars() //-------------------------------------------------------------------------------------------------- int RiuQwtPlotCurve::numSamples() const { - return dataSize(); + return static_cast( dataSize() ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp b/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp index ec4b1a757b..945bfa186c 100644 --- a/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp +++ b/ApplicationLibCode/UserInterface/RiuRmsNavigation.cpp @@ -57,7 +57,7 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent ) int translatedMousePosX, translatedMousePosY; cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); - if ( me->button() == Qt::MidButton && isRotationEnabled() ) + if ( me->button() == Qt::MiddleButton && isRotationEnabled() ) { this->pickAndSetPointOfInterest( me->x(), me->y() ); @@ -100,7 +100,7 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::RightButton || me->button() == Qt::MidButton ) + if ( me->button() == Qt::RightButton || me->button() == Qt::MiddleButton ) { m_trackball->endNavigation(); diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp index c99f8f7f3c..12296d82cf 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -113,7 +113,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= // MidButton for the panning QwtPlotPanner* panner = new QwtPlotPanner( m_plotWidget->qwtPlot()->canvas() ); - panner->setMouseButton( Qt::MidButton ); + panner->setMouseButton( Qt::MiddleButton ); m_wheelZoomer = new RiuQwtPlotWheelZoomer( m_plotWidget->qwtPlot() ); diff --git a/CMakeLists.txt b/CMakeLists.txt index 85b1010c4b..62303eabc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,12 +226,25 @@ else() COMPILE_FLAGS "/wd4244 /wd4267 /wd4013 /wd4190 /wd4018 /wd4477 /wd4098 /wd4293 /wd4305 /wd4020 /wd4028 /wd4715 /wd4245 /wd4804 /wd4100 /wd4456 /wd4458 /wd4090 /wd4297 /wd4701 /wd4101 /wd4702 /wd4457" ) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set_target_properties( + ecl + PROPERTIES + COMPILE_FLAGS + "-Wno-deprecated -Wno-deprecated-declarations -Wno-sign-compare" + ) else() set_target_properties( ecl - PROPERTIES COMPILE_FLAGS - "-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered" + PROPERTIES + COMPILE_FLAGS + "-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered -Wno-int-in-bool-context" ) + + target_compile_options( + ecl PRIVATE $<$:-Wno-class-memaccess> + ) + endif() list(APPEND THIRD_PARTY_LIBRARIES ecl) @@ -421,6 +434,12 @@ endif() add_subdirectory(ThirdParty/qwt) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(qwt PRIVATE -Wno-deprecated-copy) +elseif(MSVC) + target_compile_options(qwt PRIVATE /wd4996 /wd4005) +endif() + if(RESINSIGHT_ENABLE_UNITY_BUILD) message("Cmake Unity build is enabled on : qwt") set_property(TARGET qwt PROPERTY UNITY_BUILD true) @@ -437,6 +456,9 @@ list(APPEND THIRD_PARTY_LIBRARIES qwt) # ############################################################################## add_subdirectory(ThirdParty/nightcharts) +if(MSVC) + target_compile_options(nightcharts PRIVATE /wd4996) +endif() list(APPEND THIRD_PARTY_LIBRARIES nightcharts) @@ -446,6 +468,10 @@ list(APPEND THIRD_PARTY_LIBRARIES nightcharts) add_subdirectory(ThirdParty/expressionparser) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(expressionparser PUBLIC -Wno-overloaded-virtual) +endif() + list(APPEND THIRD_PARTY_LIBRARIES expressionparser) # ############################################################################## @@ -454,6 +480,10 @@ list(APPEND THIRD_PARTY_LIBRARIES expressionparser) add_subdirectory(ThirdParty/clipper) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(clipper PUBLIC -Wno-deprecated-copy) +endif() + list(APPEND THIRD_PARTY_LIBRARIES clipper) # ############################################################################## @@ -509,6 +539,17 @@ list( LibCore ) +if(MSVC) + target_compile_options(LibGuiQt PRIVATE /wd4996) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options( + LibRender PRIVATE -Wno-undefined-var-template -Wno-invalid-source-encoding + -Wno-null-pointer-arithmetic + ) +endif() + set_property(TARGET ${VIZ_FWK_LIBRARIES} PROPERTY FOLDER "VizFwk") # ############################################################################## @@ -526,8 +567,10 @@ add_subdirectory(Fwk/AppFwk/cafProjectDataModel) add_subdirectory(Fwk/AppFwk/cafCommand) add_subdirectory(Fwk/AppFwk/cafUserInterface) add_subdirectory(Fwk/AppFwk/cafPdmCvf) + add_subdirectory(Fwk/AppFwk/CommonCode) add_subdirectory(Fwk/AppFwk/cafVizExtensions) + option(CAF_CVF_SCRIPTING "" ON) add_subdirectory(Fwk/AppFwk/cafPdmScripting) set_property(TARGET cafPdmScripting PROPERTY FOLDER "AppFwk") @@ -538,6 +581,32 @@ set_property(TARGET cafCommandFeatures PROPERTY FOLDER "AppFwk") add_subdirectory(Fwk/AppFwk/cafTensor) add_subdirectory(Fwk/AppFwk/cafHexInterpolator) +if(MSVC) + target_compile_options(cafViewer PRIVATE /wd4996) + target_compile_options(cafPdmCore PRIVATE /wd4996) + target_compile_options(cafPdmCore PRIVATE /wd4996) + target_compile_options(cafPdmXml PRIVATE /wd4996) + target_compile_options(cafUserInterface PRIVATE /wd4996) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(cafCommandFeatures PRIVATE -Wno-deprecated-copy) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options( + CommonCode PRIVATE -Wno-deprecated-copy -Wno-undefined-var-template + ) + target_compile_options( + cafCommandFeatures PRIVATE -Wno-deprecated-copy -Wno-undefined-var-template + ) + target_compile_options( + cafVizExtensions PRIVATE -Wno-deprecated-copy -Wno-undefined-var-template + -Wno-invalid-source-encoding + ) + target_compile_options(cafUserInterface PRIVATE -Wno-null-pointer-arithmetic) +endif() + list( APPEND APP_FWK_LIBRARIES diff --git a/Fwk/AppFwk/CommonCode/cafMouseState.cpp b/Fwk/AppFwk/CommonCode/cafMouseState.cpp index db8d7b09c3..53348763e2 100644 --- a/Fwk/AppFwk/CommonCode/cafMouseState.cpp +++ b/Fwk/AppFwk/CommonCode/cafMouseState.cpp @@ -237,7 +237,7 @@ int QtMouseState::numMouseButtonsInState( Qt::MouseButtons buttonState ) if ( buttonState & Qt::LeftButton ) iNum++; if ( buttonState & Qt::RightButton ) iNum++; - if ( buttonState & Qt::MidButton ) iNum++; + if ( buttonState & Qt::MiddleButton ) iNum++; return iNum; } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index 2f0b719b17..0fd4b8feb4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -164,7 +164,8 @@ std::vector PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi if ( items.size() < 2 ) return {}; const auto fieldKeyword = editorField->keyword(); - const auto& fieldOwnerTypeId = typeid( *editorField->ownerObject() ); + auto ownerObject = editorField->ownerObject(); + const auto& fieldOwnerTypeId = typeid( *ownerObject ); std::vector additionalFieldsToUpdate; for ( auto& item : items ) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp index deec96180f..1760042bc4 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp @@ -60,7 +60,8 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::createFieldEditorForFi else { // Find the default field editor - QString fieldTypeName = qStringTypeName( *( field->fieldHandle() ) ); + auto fieldHandle = field->fieldHandle(); + QString fieldTypeName = qStringTypeName( *fieldHandle ); if ( fieldTypeName.indexOf( "PdmPtrField" ) != -1 ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h index 6391c04ef7..9c74240959 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h @@ -129,8 +129,7 @@ public: static std::unique_ptr create() { return std::unique_ptr( new Tag ); } private: - Tag( const Tag& rhs ) = default; - Tag& operator =( const Tag& rhs ) { return *this; } + Tag& operator=( const Tag& rhs ) { return *this; } }; std::vector> tags; diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index e785945581..483e9fd5ec 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -74,7 +74,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) int translatedMousePosX, translatedMousePosY; cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); - if ( me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) + if ( me->button() == Qt::MiddleButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) { this->pickAndSetPointOfInterest( me->x(), me->y() ); @@ -85,7 +85,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) m_hasMovedMouseDuringNavigation = false; isEventHandled = true; } - else if ( me->button() == Qt::MidButton && ( me->modifiers() & Qt::ShiftModifier ) ) + else if ( me->button() == Qt::MiddleButton && ( me->modifiers() & Qt::ShiftModifier ) ) { m_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY ); m_isNavigating = true; @@ -100,7 +100,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_isNavigating ) { QMouseEvent* me = static_cast( inputEvent ); - if ( me->button() == Qt::MidButton ) + if ( me->button() == Qt::MiddleButton ) { m_trackball->endNavigation(); diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index 8e77a1d3b8..bdd52b41be 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -229,7 +229,7 @@ ManipulatorTrackball::NavigationType caf::CeetronNavigation::getNavigationTypeFr { return ManipulatorTrackball::ROTATE; } - else if ( mouseButtons == Qt::MidButton || mouseButtons == ( Qt::LeftButton | Qt::RightButton ) ) + else if ( mouseButtons == Qt::MiddleButton || mouseButtons == ( Qt::LeftButton | Qt::RightButton ) ) { return ManipulatorTrackball::WALK; } diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index ebce016cf3..e6df70a6d0 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -98,7 +98,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) isEventHandled = true; } } - else if ( me->button() == Qt::MidButton ) + else if ( me->button() == Qt::MiddleButton ) { if ( me->modifiers() == Qt::NoModifier ) { @@ -130,7 +130,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( m_hasMovedMouseDuringNavigation ) isEventHandled = true; m_hasMovedMouseDuringNavigation = false; } - else if ( me->button() == Qt::MidButton ) + else if ( me->button() == Qt::MiddleButton ) { m_isZooming = false; diff --git a/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp b/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp index 72a7d0bcda..cc28ad140b 100644 --- a/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp +++ b/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp @@ -246,7 +246,7 @@ int MouseState::numMouseButtonsInState(Qt::MouseButtons buttonState) if (buttonState & Qt::LeftButton) iNum++; if (buttonState & Qt::RightButton) iNum++; - if (buttonState & Qt::MidButton) iNum++; + if (buttonState & Qt::MiddleButton) iNum++; return iNum; } diff --git a/GrpcInterface/CMakeLists.txt b/GrpcInterface/CMakeLists.txt index b3b7d65bc5..a1bf143c16 100644 --- a/GrpcInterface/CMakeLists.txt +++ b/GrpcInterface/CMakeLists.txt @@ -231,13 +231,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PRIVATE ${_LINK_LIBRARIES}) if(MSVC) - # GRPC generates a lot of harmless warnings on MSVC - set_target_properties( - ${PROJECT_NAME} - PROPERTIES COMPILE_FLAGS "/wd4251 /wd4702 /wd4005 /wd4244 /wd4125 /wd4267") + target_compile_options( + GrpcInterface + PRIVATE /wd4251 /wd4244 /wd4267) else() - set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS - "-Wno-overloaded-virtual") + target_compile_options( + GrpcInterface + PRIVATE -Wno-switch -Wno-overloaded-virtual + ) endif() # install gRPC Python files diff --git a/ThirdParty/clipper/CMakeLists.txt b/ThirdParty/clipper/CMakeLists.txt index 300964eeb3..9f84a5e20b 100644 --- a/ThirdParty/clipper/CMakeLists.txt +++ b/ThirdParty/clipper/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required (VERSION 2.8.12) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") +endif() + project (clipper) set(project_source_files diff --git a/ThirdParty/custom-opm-common/CMakeLists.txt b/ThirdParty/custom-opm-common/CMakeLists.txt index c1e0e3d2a9..3428bb6a50 100644 --- a/ThirdParty/custom-opm-common/CMakeLists.txt +++ b/ThirdParty/custom-opm-common/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required (VERSION 2.8) -# -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_TEST_DYN_LINK -DHAVE_CASE_SENSITIVE_FILESYSTEM=1 -DHAVE_REGEX=1 -DOPM_PARSER_DECK_API=1 -Wall -std=c++11 -fopenmp -Wall -g -O0 -DDEBUG -ggdb3 - - # Languages and global compiler settings if(CMAKE_VERSION VERSION_LESS 3.8) message(WARNING "CMake version does not support c++17, guessing -std=c++17") @@ -13,12 +10,19 @@ else() set(CMAKE_CXX_EXTENSIONS OFF) endif() - if(MSVC) - add_definitions( "/wd4996 /wd4244 /wd4267" ) + add_definitions( "/wd4996 /wd4244 /wd4267 /wd4101 /wd4477" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /permissive-") endif(MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-switch -Wno-sign-compare -Wno-deprecated-copy -Wno-missing-field-initializers") +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare -Wno-missing-field-initializers -Wno-deprecated-copy") +endif() + project (custom-opm-common) find_package(Boost) @@ -111,12 +115,12 @@ if(RESINSIGHT_ENABLE_UNITY_BUILD) endforeach(fileToExclude) endif() - find_path(BOOST_SPIRIT_INCLUDE_DIRS "boost/spirit.hpp" HINTS ${Boost_INCLUDE_DIRS}) target_link_libraries(custom-opm-common ${ADDITIONAL_LINK_LIBRARIES} ) + target_include_directories(custom-opm-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/opm-common diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index a3cfcd3d34..a44c68d824 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -6,6 +6,10 @@ if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations") endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations -Wno-delete-abstract-non-virtual-dtor -Wno-deprecated-copy") +endif() + include_directories( ../custom-opm-flowdiagnostics/opm-flowdiagnostics opm-flowdiagnostics-applications