From 5ee825b5f6ad57acbdff02c556252b3ecd3af483 Mon Sep 17 00:00:00 2001 From: Project579 Date: Mon, 11 Jul 2022 22:17:12 +0200 Subject: [PATCH 1/4] Enable warnings as errors in MSVC builds. --- .gitlab-ci.yml | 4 ++-- CI/before_script.msvc.sh | 34 +++++++++++++++++++++++++++------- CMakeLists.txt | 8 ++++++-- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ece19cd71..86fac636b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -84,7 +84,7 @@ Coverity: CXX: clang++ CXXFLAGS: -O0 artifacts: - paths: + paths: - /builds/OpenMW/openmw/cov-int/build-log.txt Ubuntu_GCC: @@ -478,7 +478,7 @@ macOS12_Xcode13: - $env:CCACHE_BASEDIR = Get-Location - $env:CCACHE_DIR = "$(Get-Location)\ccache" - New-Item -Type Directory -Force -Path $env:CCACHE_DIR - - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -b -t -C $multiview + - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -b -t -C $multiview -E - cd MSVC2019_64 - cmake --build . --config $config - ccache --show-stats diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index e4c4c5620d..146f0c4679 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -76,6 +76,8 @@ GOOGLE_INSTALL_ROOT="" INSTALL_PREFIX="." BUILD_BENCHMARKS="" OSG_MULTIVIEW_BUILD="" +USE_WERROR="" +USE_CLANG_TIDY="" ACTIVATE_MSVC="" SINGLE_CONFIG="" @@ -116,7 +118,7 @@ while [ $# -gt 0 ]; do n ) NMAKE=true ;; - + N ) NINJA=true ;; @@ -140,10 +142,16 @@ while [ $# -gt 0 ]; do b ) BUILD_BENCHMARKS=true ;; - - M ) - OSG_MULTIVIEW_BUILD=true ;; - + + M ) + OSG_MULTIVIEW_BUILD=true ;; + + E ) + USE_WERROR=true ;; + + T ) + USE_CLANG_TIDY=true ;; + h ) cat < Date: Mon, 11 Jul 2022 22:36:45 +0200 Subject: [PATCH 2/4] Re-enable Windows tests. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86fac636b8..488d3b3148 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -539,7 +539,7 @@ Windows_MSBuild_RelWithDebInfo: variables: config: "RelWithDebInfo" # Gitlab can't successfully execute following binaries due to unknown reason - # executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" + executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" # temporarily enabled while we're linking these on the downloads page rules: # run this for both pushes and schedules so 'latest successful pipeline for branch' always includes it From 02ef9c953ecaffa6fc1cebbe8b4cdc24b0823b66 Mon Sep 17 00:00:00 2001 From: Project579 Date: Sat, 16 Jul 2022 09:30:21 +0200 Subject: [PATCH 3/4] MSVC: Fix all warnings at level 4, upgrade Qt5 to 5.15.2 to also reduce warnings, disabled 5054 warnings due to Qt5's use of deprecated operators in C++20 . --- .gitlab-ci.yml | 8 +- CI/before_script.msvc.sh | 135 +++++++++--------------- CMakeLists.txt | 9 +- components/nifosg/controller.hpp | 11 ++ components/sceneutil/osgacontroller.hpp | 11 ++ 5 files changed, 82 insertions(+), 92 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 488d3b3148..43fe22e8ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -376,7 +376,7 @@ macOS12_Xcode13: - $env:CCACHE_BASEDIR = Get-Location - $env:CCACHE_DIR = "$(Get-Location)\ccache" - New-Item -Type Directory -Force -Path $env:CCACHE_DIR - - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -N -b -t -C $multiview + - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -N -b -t -C $multiview -E - cd MSVC2019_64_Ninja - .\ActivateMSVC.ps1 - cmake --build . --config $config @@ -439,8 +439,7 @@ macOS12_Xcode13: - .Windows_Ninja_Base variables: config: "RelWithDebInfo" - # Gitlab can't successfully execute following binaries due to unknown reason - # executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" + executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" .Windows_MSBuild_Base: tags: @@ -478,7 +477,7 @@ macOS12_Xcode13: - $env:CCACHE_BASEDIR = Get-Location - $env:CCACHE_DIR = "$(Get-Location)\ccache" - New-Item -Type Directory -Force -Path $env:CCACHE_DIR - - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -b -t -C $multiview -E + - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -b -t -C $multiview -E - cd MSVC2019_64 - cmake --build . --config $config - ccache --show-stats @@ -538,7 +537,6 @@ Windows_MSBuild_RelWithDebInfo: - .Windows_MSBuild_Base variables: config: "RelWithDebInfo" - # Gitlab can't successfully execute following binaries due to unknown reason executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" # temporarily enabled while we're linking these on the downloads page rules: diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index 146f0c4679..ff8ec1a11c 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -855,108 +855,77 @@ printf "${OSG_ARCHIVE_NAME}... " cd $DEPS echo # Qt -if [ -z $APPVEYOR ]; then - printf "Qt 5.15.0... " -else - printf "Qt 5.13 AppVeyor... " -fi +printf "Qt 5.15.2... " { if [ $BITS -eq 64 ]; then SUFFIX="_64" else SUFFIX="" fi - if [ -z $APPVEYOR ]; then - cd $DEPS_INSTALL - qt_version="5.15.0" - if [ "win${BITS}_msvc${MSVC_REAL_YEAR}${SUFFIX}" == "win64_msvc2017_64" ]; then - echo "This combination of options is known not to work. Falling back to Qt 5.14.2." - qt_version="5.14.2" - fi + cd $DEPS_INSTALL - QT_SDK="$(real_pwd)/Qt/${qt_version}/msvc${MSVC_REAL_YEAR}${SUFFIX}" + qt_version="5.15.2" - if [ -d "Qt/${qt_version}" ]; then - printf "Exists. " - elif [ -z $SKIP_EXTRACT ]; then - if [ $MISSINGPYTHON -ne 0 ]; then - echo "Can't be automatically installed without Python." - wrappedExit 1 - fi + QT_SDK="$(real_pwd)/Qt/${qt_version}/msvc${MSVC_REAL_YEAR}${SUFFIX}" - pushd "$DEPS" > /dev/null - if ! [ -d 'aqt-venv' ]; then - echo " Creating Virtualenv for aqt..." - run_cmd python -m venv aqt-venv - fi - if [ -d 'aqt-venv/bin' ]; then - VENV_BIN_DIR='bin' - elif [ -d 'aqt-venv/Scripts' ]; then - VENV_BIN_DIR='Scripts' - else - echo "Error: Failed to create virtualenv in expected location." - wrappedExit 1 - fi + if [ -d "Qt/${qt_version}" ]; then + printf "Exists. " + elif [ -z $SKIP_EXTRACT ]; then + if [ $MISSINGPYTHON -ne 0 ]; then + echo "Can't be automatically installed without Python." + wrappedExit 1 + fi - # check version - aqt-venv/${VENV_BIN_DIR}/pip list | grep 'aqtinstall\s*1.1.3' || [ $? -ne 0 ] - if [ $? -eq 0 ]; then - echo " Installing aqt wheel into virtualenv..." - run_cmd "aqt-venv/${VENV_BIN_DIR}/pip" install aqtinstall==1.1.3 - fi - popd > /dev/null + pushd "$DEPS" > /dev/null + if ! [ -d 'aqt-venv' ]; then + echo " Creating Virtualenv for aqt..." + run_cmd python -m venv aqt-venv + fi + if [ -d 'aqt-venv/bin' ]; then + VENV_BIN_DIR='bin' + elif [ -d 'aqt-venv/Scripts' ]; then + VENV_BIN_DIR='Scripts' + else + echo "Error: Failed to create virtualenv in expected location." + wrappedExit 1 + fi - rm -rf Qt + # check version + aqt-venv/${VENV_BIN_DIR}/pip list | grep 'aqtinstall\s*1.1.3' || [ $? -ne 0 ] + if [ $? -eq 0 ]; then + echo " Installing aqt wheel into virtualenv..." + run_cmd "aqt-venv/${VENV_BIN_DIR}/pip" install aqtinstall==1.1.3 + fi + popd > /dev/null - mkdir Qt - cd Qt + rm -rf Qt - run_cmd "${DEPS}/aqt-venv/${VENV_BIN_DIR}/aqt" install $qt_version windows desktop "win${BITS}_msvc${MSVC_REAL_YEAR}${SUFFIX}" + mkdir Qt + cd Qt - printf " Cleaning up extraneous data... " - rm -rf Qt/{aqtinstall.log,Tools} + run_cmd "${DEPS}/aqt-venv/${VENV_BIN_DIR}/aqt" install $qt_version windows desktop "win${BITS}_msvc${MSVC_REAL_YEAR}${SUFFIX}" - echo Done. - fi + printf " Cleaning up extraneous data... " + rm -rf Qt/{aqtinstall.log,Tools} - cd $QT_SDK - add_cmake_opts -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ - -DCMAKE_PREFIX_PATH="$QT_SDK" - for CONFIGURATION in ${CONFIGURATIONS[@]}; do - if [ $CONFIGURATION == "Debug" ]; then - DLLSUFFIX="d" - else - DLLSUFFIX="" - fi - add_runtime_dlls $CONFIGURATION "$(pwd)/bin/Qt5"{Core,Gui,Network,OpenGL,Widgets}${DLLSUFFIX}.dll - add_qt_platform_dlls $CONFIGURATION "$(pwd)/plugins/platforms/qwindows${DLLSUFFIX}.dll" - add_qt_style_dlls $CONFIGURATION "$(pwd)/plugins/styles/qwindowsvistastyle${DLLSUFFIX}.dll" - done - echo Done. - else - # default to msvc2019 which pre-loads Qt 5.15.2 - qt_version="5.15.2" - if [ "msvc${MSVC_REAL_YEAR}" == "msvc2017" ]; then - qt_version="5.13" - fi - QT_SDK="C:/Qt/${qt_version}/msvc${MSVC_REAL_YEAR}${SUFFIX}" - - add_cmake_opts -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ - -DCMAKE_PREFIX_PATH="$QT_SDK" - for CONFIGURATION in ${CONFIGURATIONS[@]}; do - if [ $CONFIGURATION == "Debug" ]; then - DLLSUFFIX="d" - else - DLLSUFFIX="" - fi - DIR=$(windowsPathAsUnix "${QT_SDK}") - add_runtime_dlls $CONFIGURATION "${DIR}/bin/Qt5"{Core,Gui,Network,OpenGL,Widgets}${DLLSUFFIX}.dll - add_qt_platform_dlls $CONFIGURATION "${DIR}/plugins/platforms/qwindows${DLLSUFFIX}.dll" - add_qt_style_dlls $CONFIGURATION "${DIR}/plugins/styles/qwindowsvistastyle${DLLSUFFIX}.dll" - done echo Done. fi + + cd $QT_SDK + add_cmake_opts -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ + -DCMAKE_PREFIX_PATH="$QT_SDK" + for CONFIGURATION in ${CONFIGURATIONS[@]}; do + if [ $CONFIGURATION == "Debug" ]; then + DLLSUFFIX="d" + else + DLLSUFFIX="" + fi + add_runtime_dlls $CONFIGURATION "$(pwd)/bin/Qt5"{Core,Gui,Network,OpenGL,Widgets}${DLLSUFFIX}.dll + add_qt_platform_dlls $CONFIGURATION "$(pwd)/plugins/platforms/qwindows${DLLSUFFIX}.dll" + add_qt_style_dlls $CONFIGURATION "$(pwd)/plugins/styles/qwindowsvistastyle${DLLSUFFIX}.dll" + done + echo Done. } cd $DEPS echo diff --git a/CMakeLists.txt b/CMakeLists.txt index c9e69f1d11..d1bcfa832e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -690,7 +690,7 @@ if (WIN32) # Play a bit with the warning levels - set(WARNINGS /W4) + set(WARNINGS "/W4") set(WARNINGS_DISABLE 4100 # Unreferenced formal parameter (-Wunused-parameter) @@ -712,11 +712,11 @@ if (WIN32) endif() foreach(d ${WARNINGS_DISABLE}) - list(APPEND WARNINGS /wd${d}) + set(WARNINGS "${WARNINGS} /wd${d}") endforeach(d) if(OPENMW_MSVC_WERROR) - list(APPEND WARNINGS /WX) + set(WARNINGS "${WARNINGS} /WX") endif() set_target_properties(components PROPERTIES COMPILE_FLAGS "${WARNINGS}") @@ -771,7 +771,8 @@ if (WIN32) endif() if (BUILD_BULLETOBJECTTOOL) - set_target_properties(openmw-bulletobjecttool PROPERTIES COMPILE_FLAGS "${WARNINGS} ${MT_BUILD}") + set(WARNINGS "${WARNINGS} ${MT_BUILD}") + set_target_properties(openmw-bulletobjecttool PROPERTIES COMPILE_FLAGS "${WARNINGS}") endif() endif(MSVC) diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index 14ad0b9ed0..c79c6a70d1 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -225,6 +225,14 @@ namespace NifOsg std::vector mKeyFrames; }; +#ifdef _MSC_VER +#pragma warning( push ) + /* + * Warning C4250: 'NifOsg::KeyframeController': inherits 'osg::Callback::osg::Callback::asCallback' via dominance, + * there is no way to solved this if an object must inherit from both osg::Object and osg::Callback + */ +#pragma warning( disable : 4250 ) +#endif class KeyframeController : public SceneUtil::KeyframeController, public SceneUtil::NodeCallback { public: @@ -253,6 +261,9 @@ namespace NifOsg osg::Quat getXYZRotation(float time) const; }; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif class UVController : public SceneUtil::StateSetUpdater, public SceneUtil::Controller { diff --git a/components/sceneutil/osgacontroller.hpp b/components/sceneutil/osgacontroller.hpp index 893b8b1ebe..e9ffe2676f 100644 --- a/components/sceneutil/osgacontroller.hpp +++ b/components/sceneutil/osgacontroller.hpp @@ -35,6 +35,14 @@ namespace SceneUtil Resource::Animation* mAnimation; }; +#ifdef _MSC_VER +#pragma warning( push ) +/* + * Warning C4250: 'SceneUtil::OsgAnimationController': inherits 'osg::Callback::osg::Callback::asCallback' via dominance, + * there is no way to solved this if an object must inherit from both osg::Object and osg::Callback + */ +#pragma warning( disable : 4250 ) +#endif class OsgAnimationController : public SceneUtil::KeyframeController, public SceneUtil::NodeCallback { public: @@ -68,6 +76,9 @@ namespace SceneUtil std::vector> mMergedAnimationTracks; // Used only by osgAnimation-based formats (e.g. dae) std::vector mEmulatedAnimations; }; +#ifdef _MSC_VER +#pragma warning( pop ) +#endif } #endif From 7a715a7d73b287e94e198c9228c9e9973ca1e5b0 Mon Sep 17 00:00:00 2001 From: Project579 Date: Sun, 17 Jul 2022 09:30:07 +0200 Subject: [PATCH 4/4] Revert "Re-enable Windows tests." This reverts commit f8cec04ce74949bf2a86fec3e1bf2c0665419b26. --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 43fe22e8ea..9d816970ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -439,7 +439,8 @@ macOS12_Xcode13: - .Windows_Ninja_Base variables: config: "RelWithDebInfo" - executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" + # Gitlab can't successfully execute following binaries due to unknown reason + # executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" .Windows_MSBuild_Base: tags: @@ -477,7 +478,7 @@ macOS12_Xcode13: - $env:CCACHE_BASEDIR = Get-Location - $env:CCACHE_DIR = "$(Get-Location)\ccache" - New-Item -Type Directory -Force -Path $env:CCACHE_DIR - - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -b -t -C $multiview -E + - sh CI/before_script.msvc.sh -c $config -p Win64 -v 2019 -k -V -b -t -C $multiview -E - cd MSVC2019_64 - cmake --build . --config $config - ccache --show-stats @@ -537,7 +538,8 @@ Windows_MSBuild_RelWithDebInfo: - .Windows_MSBuild_Base variables: config: "RelWithDebInfo" - executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" + # Gitlab can't successfully execute following binaries due to unknown reason + # executables: "openmw_test_suite.exe,openmw_detournavigator_navmeshtilescache_benchmark.exe" # temporarily enabled while we're linking these on the downloads page rules: # run this for both pushes and schedules so 'latest successful pipeline for branch' always includes it