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.
This commit is contained in:
Magne Sjaastad 2022-01-26 10:08:28 +01:00 committed by GitHub
parent d5b17976ed
commit 2d2bf0bbc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 190 additions and 64 deletions

View File

@ -339,30 +339,42 @@ if(RESINSIGHT_ENABLE_PRECOMPILED_HEADERS)
) )
endif() endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_target_properties( target_compile_options(
${PROJECT_NAME} ApplicationLibCode PRIVATE -Wall -Wno-unused-parameter -Wno-reorder
PROPERTIES -Wno-parentheses -Wno-switch
COMPILE_FLAGS
"-Wall -Wno-unused-parameter -Wno-reorder -Wno-parentheses -Wno-switch"
) )
# Treat warnings as errors if asked to do so endif()
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()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set_target_properties(
${PROJECT_NAME} target_compile_options(
PROPERTIES ApplicationLibCode
COMPILE_FLAGS PRIVATE -Wall
"-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-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()
endif() endif()
@ -376,7 +388,7 @@ if(MSVC)
# set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190 # set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190
# /wd4100 /wd4127") # /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) if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10)
# Disable warning for deprecated functions in newer versions of Qt # Disable warning for deprecated functions in newer versions of Qt

View File

@ -67,6 +67,37 @@ target_include_directories(
${CMAKE_SOURCE_DIR}/ThirdParty/custom-opm-common/opm-common ${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) if(MSVC)
# The following warnings are supposed to be used in ResInsight, but # The following warnings are supposed to be used in ResInsight, but
# temporarily disabled to avoid too much noise warning C4245: 'return': # 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 # set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4190
# /wd4100 /wd4127") # /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) if(Qt5Core_VERSION_STRING GREATER_EQUAL 5.10)
# Disable warning for deprecated functions in newer versions of Qt # Disable warning for deprecated functions in newer versions of Qt

View File

@ -253,7 +253,7 @@ std::vector<RimSummaryCase*> 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 // 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 // numerical issues the first time step can be slightly different

View File

@ -252,7 +252,7 @@ void RimWellPathGroup::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
std::vector<const RigWellPath*> RimWellPathGroup::wellPathGeometries() const std::vector<const RigWellPath*> RimWellPathGroup::wellPathGeometries() const
{ {
std::vector<const RigWellPath*> allGeometries; std::vector<const RigWellPath*> allGeometries;
for ( const auto child : m_childWellPaths() ) for ( const auto& child : m_childWellPaths() )
{ {
if ( child->wellPathGeometry() ) if ( child->wellPathGeometry() )
{ {

View File

@ -16,9 +16,9 @@ TEST( RigSlice2DTest, GetAndSet )
for ( size_t y = 0; y < ny; y++ ) for ( size_t y = 0; y < ny; y++ )
for ( size_t x = 0; x < nx; x++ ) for ( size_t x = 0; x < nx; x++ )
slice.setValue( x, y, x * y ); slice.setValue( x, y, static_cast<double>( x * y ) );
for ( size_t y = 0; y < ny; y++ ) for ( size_t y = 0; y < ny; y++ )
for ( size_t x = 0; x < nx; x++ ) for ( size_t x = 0; x < nx; x++ )
EXPECT_EQ( x * y, slice.getValue( x, y ) ); EXPECT_EQ( static_cast<double>( x * y ), slice.getValue( x, y ) );
} }

View File

@ -57,7 +57,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent )
int translatedMousePosX, translatedMousePosY; int translatedMousePosX, translatedMousePosY;
cvfEventPos( me->x(), me->y(), &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() ); this->pickAndSetPointOfInterest( me->x(), me->y() );
@ -67,7 +67,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent )
isEventHandled = true; isEventHandled = true;
} }
else if ( me->button() == Qt::LeftButton || 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_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY );
m_isNavigating = true; m_isNavigating = true;
@ -82,7 +82,7 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent )
if ( m_isNavigating ) if ( m_isNavigating )
{ {
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent ); QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
if ( me->button() == Qt::MidButton || me->button() == Qt::LeftButton ) if ( me->button() == Qt::MiddleButton || me->button() == Qt::LeftButton )
{ {
m_trackball->endNavigation(); m_trackball->endNavigation();

View File

@ -66,7 +66,7 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent )
m_hasMovedMouseDuringNavigation = false; m_hasMovedMouseDuringNavigation = false;
isEventHandled = true; isEventHandled = true;
} }
else if ( me->button() == Qt::MidButton ) else if ( me->button() == Qt::MiddleButton )
{ {
if ( me->modifiers() == Qt::NoModifier ) if ( me->modifiers() == Qt::NoModifier )
{ {
@ -84,7 +84,7 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent )
if ( m_isNavigating ) if ( m_isNavigating )
{ {
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent ); QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
if ( me->button() == Qt::LeftButton || me->button() == Qt::MidButton ) if ( me->button() == Qt::LeftButton || me->button() == Qt::MiddleButton )
{ {
m_trackball->endNavigation(); m_trackball->endNavigation();

View File

@ -76,7 +76,7 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimGridCrossPlot* plot, QWidget* paren
// MidButton for the panning // MidButton for the panning
QwtPlotPanner* panner = new QwtPlotPanner( qwtPlot()->canvas() ); QwtPlotPanner* panner = new QwtPlotPanner( qwtPlot()->canvas() );
panner->setMouseButton( Qt::MidButton ); panner->setMouseButton( Qt::MiddleButton );
auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot() ); auto wheelZoomer = new RiuQwtPlotWheelZoomer( qwtPlot() );

View File

@ -381,7 +381,7 @@ void RiuQwtPlotCurve::clearErrorBars()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RiuQwtPlotCurve::numSamples() const int RiuQwtPlotCurve::numSamples() const
{ {
return dataSize(); return static_cast<int>( dataSize() );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent )
int translatedMousePosX, translatedMousePosY; int translatedMousePosX, translatedMousePosY;
cvfEventPos( me->x(), me->y(), &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() ); this->pickAndSetPointOfInterest( me->x(), me->y() );
@ -100,7 +100,7 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent )
if ( m_isNavigating ) if ( m_isNavigating )
{ {
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent ); QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
if ( me->button() == Qt::RightButton || me->button() == Qt::MidButton ) if ( me->button() == Qt::RightButton || me->button() == Qt::MiddleButton )
{ {
m_trackball->endNavigation(); m_trackball->endNavigation();

View File

@ -113,7 +113,7 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*=
// MidButton for the panning // MidButton for the panning
QwtPlotPanner* panner = new QwtPlotPanner( m_plotWidget->qwtPlot()->canvas() ); QwtPlotPanner* panner = new QwtPlotPanner( m_plotWidget->qwtPlot()->canvas() );
panner->setMouseButton( Qt::MidButton ); panner->setMouseButton( Qt::MiddleButton );
m_wheelZoomer = new RiuQwtPlotWheelZoomer( m_plotWidget->qwtPlot() ); m_wheelZoomer = new RiuQwtPlotWheelZoomer( m_plotWidget->qwtPlot() );

View File

@ -226,12 +226,25 @@ else()
COMPILE_FLAGS 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" "/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() else()
set_target_properties( set_target_properties(
ecl ecl
PROPERTIES COMPILE_FLAGS PROPERTIES
"-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered" COMPILE_FLAGS
"-Wno-deprecated -Wno-deprecated-declarations -Wno-clobbered -Wno-int-in-bool-context"
) )
target_compile_options(
ecl PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>
)
endif() endif()
list(APPEND THIRD_PARTY_LIBRARIES ecl) list(APPEND THIRD_PARTY_LIBRARIES ecl)
@ -421,6 +434,12 @@ endif()
add_subdirectory(ThirdParty/qwt) 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) if(RESINSIGHT_ENABLE_UNITY_BUILD)
message("Cmake Unity build is enabled on : qwt") message("Cmake Unity build is enabled on : qwt")
set_property(TARGET qwt PROPERTY UNITY_BUILD true) set_property(TARGET qwt PROPERTY UNITY_BUILD true)
@ -437,6 +456,9 @@ list(APPEND THIRD_PARTY_LIBRARIES qwt)
# ############################################################################## # ##############################################################################
add_subdirectory(ThirdParty/nightcharts) add_subdirectory(ThirdParty/nightcharts)
if(MSVC)
target_compile_options(nightcharts PRIVATE /wd4996)
endif()
list(APPEND THIRD_PARTY_LIBRARIES nightcharts) list(APPEND THIRD_PARTY_LIBRARIES nightcharts)
@ -446,6 +468,10 @@ list(APPEND THIRD_PARTY_LIBRARIES nightcharts)
add_subdirectory(ThirdParty/expressionparser) 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) list(APPEND THIRD_PARTY_LIBRARIES expressionparser)
# ############################################################################## # ##############################################################################
@ -454,6 +480,10 @@ list(APPEND THIRD_PARTY_LIBRARIES expressionparser)
add_subdirectory(ThirdParty/clipper) 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) list(APPEND THIRD_PARTY_LIBRARIES clipper)
# ############################################################################## # ##############################################################################
@ -509,6 +539,17 @@ list(
LibCore 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") 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/cafCommand)
add_subdirectory(Fwk/AppFwk/cafUserInterface) add_subdirectory(Fwk/AppFwk/cafUserInterface)
add_subdirectory(Fwk/AppFwk/cafPdmCvf) add_subdirectory(Fwk/AppFwk/cafPdmCvf)
add_subdirectory(Fwk/AppFwk/CommonCode) add_subdirectory(Fwk/AppFwk/CommonCode)
add_subdirectory(Fwk/AppFwk/cafVizExtensions) add_subdirectory(Fwk/AppFwk/cafVizExtensions)
option(CAF_CVF_SCRIPTING "" ON) option(CAF_CVF_SCRIPTING "" ON)
add_subdirectory(Fwk/AppFwk/cafPdmScripting) add_subdirectory(Fwk/AppFwk/cafPdmScripting)
set_property(TARGET cafPdmScripting PROPERTY FOLDER "AppFwk") 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/cafTensor)
add_subdirectory(Fwk/AppFwk/cafHexInterpolator) 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( list(
APPEND APPEND
APP_FWK_LIBRARIES APP_FWK_LIBRARIES

View File

@ -237,7 +237,7 @@ int QtMouseState::numMouseButtonsInState( Qt::MouseButtons buttonState )
if ( buttonState & Qt::LeftButton ) iNum++; if ( buttonState & Qt::LeftButton ) iNum++;
if ( buttonState & Qt::RightButton ) iNum++; if ( buttonState & Qt::RightButton ) iNum++;
if ( buttonState & Qt::MidButton ) iNum++; if ( buttonState & Qt::MiddleButton ) iNum++;
return iNum; return iNum;
} }

View File

@ -164,7 +164,8 @@ std::vector<PdmFieldHandle*> PdmUiCommandSystemProxy::fieldsFromSelection( PdmFi
if ( items.size() < 2 ) return {}; if ( items.size() < 2 ) return {};
const auto fieldKeyword = editorField->keyword(); const auto fieldKeyword = editorField->keyword();
const auto& fieldOwnerTypeId = typeid( *editorField->ownerObject() ); auto ownerObject = editorField->ownerObject();
const auto& fieldOwnerTypeId = typeid( *ownerObject );
std::vector<PdmFieldHandle*> additionalFieldsToUpdate; std::vector<PdmFieldHandle*> additionalFieldsToUpdate;
for ( auto& item : items ) for ( auto& item : items )

View File

@ -60,7 +60,8 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::createFieldEditorForFi
else else
{ {
// Find the default field editor // Find the default field editor
QString fieldTypeName = qStringTypeName( *( field->fieldHandle() ) ); auto fieldHandle = field->fieldHandle();
QString fieldTypeName = qStringTypeName( *fieldHandle );
if ( fieldTypeName.indexOf( "PdmPtrField" ) != -1 ) if ( fieldTypeName.indexOf( "PdmPtrField" ) != -1 )
{ {

View File

@ -129,8 +129,7 @@ public:
static std::unique_ptr<Tag> create() { return std::unique_ptr<Tag>( new Tag ); } static std::unique_ptr<Tag> create() { return std::unique_ptr<Tag>( new Tag ); }
private: private:
Tag( const Tag& rhs ) = default; Tag& operator=( const Tag& rhs ) { return *this; }
Tag& operator =( const Tag& rhs ) { return *this; }
}; };
std::vector<std::unique_ptr<Tag>> tags; std::vector<std::unique_ptr<Tag>> tags;

View File

@ -74,7 +74,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent )
int translatedMousePosX, translatedMousePosY; int translatedMousePosX, translatedMousePosY;
cvfEventPos( me->x(), me->y(), &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() ); this->pickAndSetPointOfInterest( me->x(), me->y() );
@ -85,7 +85,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent )
m_hasMovedMouseDuringNavigation = false; m_hasMovedMouseDuringNavigation = false;
isEventHandled = true; 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_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY );
m_isNavigating = true; m_isNavigating = true;
@ -100,7 +100,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent )
if ( m_isNavigating ) if ( m_isNavigating )
{ {
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent ); QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
if ( me->button() == Qt::MidButton ) if ( me->button() == Qt::MiddleButton )
{ {
m_trackball->endNavigation(); m_trackball->endNavigation();

View File

@ -229,7 +229,7 @@ ManipulatorTrackball::NavigationType caf::CeetronNavigation::getNavigationTypeFr
{ {
return ManipulatorTrackball::ROTATE; 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; return ManipulatorTrackball::WALK;
} }

View File

@ -98,7 +98,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent )
isEventHandled = true; isEventHandled = true;
} }
} }
else if ( me->button() == Qt::MidButton ) else if ( me->button() == Qt::MiddleButton )
{ {
if ( me->modifiers() == Qt::NoModifier ) if ( me->modifiers() == Qt::NoModifier )
{ {
@ -130,7 +130,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent )
if ( m_hasMovedMouseDuringNavigation ) isEventHandled = true; if ( m_hasMovedMouseDuringNavigation ) isEventHandled = true;
m_hasMovedMouseDuringNavigation = false; m_hasMovedMouseDuringNavigation = false;
} }
else if ( me->button() == Qt::MidButton ) else if ( me->button() == Qt::MiddleButton )
{ {
m_isZooming = false; m_isZooming = false;

View File

@ -246,7 +246,7 @@ int MouseState::numMouseButtonsInState(Qt::MouseButtons buttonState)
if (buttonState & Qt::LeftButton) iNum++; if (buttonState & Qt::LeftButton) iNum++;
if (buttonState & Qt::RightButton) iNum++; if (buttonState & Qt::RightButton) iNum++;
if (buttonState & Qt::MidButton) iNum++; if (buttonState & Qt::MiddleButton) iNum++;
return iNum; return iNum;
} }

View File

@ -231,13 +231,14 @@ target_include_directories(${PROJECT_NAME} PUBLIC
target_link_libraries(${PROJECT_NAME} PRIVATE ${_LINK_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${_LINK_LIBRARIES})
if(MSVC) if(MSVC)
# GRPC generates a lot of harmless warnings on MSVC target_compile_options(
set_target_properties( GrpcInterface
${PROJECT_NAME} PRIVATE /wd4251 /wd4244 /wd4267)
PROPERTIES COMPILE_FLAGS "/wd4251 /wd4702 /wd4005 /wd4244 /wd4125 /wd4267")
else() else()
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS target_compile_options(
"-Wno-overloaded-virtual") GrpcInterface
PRIVATE -Wno-switch -Wno-overloaded-virtual
)
endif() endif()
# install gRPC Python files # install gRPC Python files

View File

@ -1,5 +1,9 @@
cmake_minimum_required (VERSION 2.8.12) 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) project (clipper)
set(project_source_files set(project_source_files

View File

@ -1,8 +1,5 @@
cmake_minimum_required (VERSION 2.8) 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 # Languages and global compiler settings
if(CMAKE_VERSION VERSION_LESS 3.8) if(CMAKE_VERSION VERSION_LESS 3.8)
message(WARNING "CMake version does not support c++17, guessing -std=c++17") message(WARNING "CMake version does not support c++17, guessing -std=c++17")
@ -13,12 +10,19 @@ else()
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
endif() endif()
if(MSVC) if(MSVC)
add_definitions( "/wd4996 /wd4244 /wd4267" ) add_definitions( "/wd4996 /wd4244 /wd4267 /wd4101 /wd4477" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /permissive-") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /permissive-")
endif(MSVC) 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) project (custom-opm-common)
find_package(Boost) find_package(Boost)
@ -111,12 +115,12 @@ if(RESINSIGHT_ENABLE_UNITY_BUILD)
endforeach(fileToExclude) endforeach(fileToExclude)
endif() endif()
find_path(BOOST_SPIRIT_INCLUDE_DIRS "boost/spirit.hpp" HINTS ${Boost_INCLUDE_DIRS}) find_path(BOOST_SPIRIT_INCLUDE_DIRS "boost/spirit.hpp" HINTS ${Boost_INCLUDE_DIRS})
target_link_libraries(custom-opm-common target_link_libraries(custom-opm-common
${ADDITIONAL_LINK_LIBRARIES} ${ADDITIONAL_LINK_LIBRARIES}
) )
target_include_directories(custom-opm-common target_include_directories(custom-opm-common
PUBLIC PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/opm-common ${CMAKE_CURRENT_SOURCE_DIR}/opm-common

View File

@ -6,6 +6,10 @@ if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations")
endif() 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( include_directories(
../custom-opm-flowdiagnostics/opm-flowdiagnostics ../custom-opm-flowdiagnostics/opm-flowdiagnostics
opm-flowdiagnostics-applications opm-flowdiagnostics-applications