From 81df7c6fb6a724b32f76f47a06ab30f8b104cf7c Mon Sep 17 00:00:00 2001
From: Rhys Mainwaring <rhys.mainwaring@me.com>
Date: Sat, 25 May 2024 23:02:33 +0100
Subject: [PATCH] Fix compiler warnings

- Fix various compiler warnings.
- Remove using namespace

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
---
 gz-waves/include/gz/waves/MeshTools.hh        |  1 -
 gz-waves/include/gz/waves/OceanTile.hh        |  2 --
 gz-waves/include/gz/waves/Wavefield.hh        |  2 --
 gz-waves/src/CGAL_TEST.cc                     |  2 +-
 gz-waves/src/Grid.cc                          |  2 +-
 gz-waves/src/LinearRandomFFTWaveSimulation.cc |  2 +-
 .../src/LinearRandomFFTWaveSimulationRef.cc   |  2 +-
 gz-waves/src/LinearRandomWaveSimulation.cc    |  4 +--
 gz-waves/src/LinearRegularWaveSimulation.cc   |  2 +-
 gz-waves/src/MeshTools.cc                     |  3 +-
 gz-waves/src/MeshTools_TEST.cc                |  2 +-
 gz-waves/src/OceanTile.cc                     |  2 +-
 gz-waves/src/Physics.cc                       |  2 +-
 gz-waves/src/Physics_TEST.cc                  |  2 +-
 .../src/TrochoidIrregularWaveSimulation.cc    | 28 +++++++++----------
 gz-waves/src/Utilities.cc                     |  2 +-
 gz-waves/src/WaveParameters.cc                |  2 +-
 gz-waves/src/Wavefield.cc                     |  4 +--
 gz-waves/src/WavefieldSampler.cc              |  2 +-
 gz-waves/src/systems/dynamic/CMakeLists.txt   |  2 ++
 gz-waves/src/systems/waves/CMakeLists.txt     |  7 +++++
 .../src/systems/waves/Ogre2OceanGeometry.cc   |  2 +-
 .../src/systems/waves/Ogre2OceanVisual.cc     |  2 +-
 .../waves/RenderEngineExtensionManager.cc     |  3 +-
 gz-waves/test/plots/CMakeLists.txt            | 19 ++++++++++---
 25 files changed, 59 insertions(+), 44 deletions(-)

diff --git a/gz-waves/include/gz/waves/MeshTools.hh b/gz-waves/include/gz/waves/MeshTools.hh
index 4a5ab429..b124a8c4 100644
--- a/gz-waves/include/gz/waves/MeshTools.hh
+++ b/gz-waves/include/gz/waves/MeshTools.hh
@@ -25,7 +25,6 @@
 
 #include "gz/waves/CGALTypes.hh"
 
-#include <gz/common.hh>
 #include <gz/common/Mesh.hh>
 
 namespace gz
diff --git a/gz-waves/include/gz/waves/OceanTile.hh b/gz-waves/include/gz/waves/OceanTile.hh
index d9dead57..b61ab210 100644
--- a/gz-waves/include/gz/waves/OceanTile.hh
+++ b/gz-waves/include/gz/waves/OceanTile.hh
@@ -20,8 +20,6 @@
 #include <memory>
 #include <vector>
 
-#include <gz/math.hh>
-#include <gz/common.hh>
 #include <gz/common/Mesh.hh>
 
 #include "gz/waves/CGALTypes.hh"
diff --git a/gz-waves/include/gz/waves/Wavefield.hh b/gz-waves/include/gz/waves/Wavefield.hh
index 117220df..05df8d64 100644
--- a/gz-waves/include/gz/waves/Wavefield.hh
+++ b/gz-waves/include/gz/waves/Wavefield.hh
@@ -24,8 +24,6 @@
 #include <memory>
 #include <string>
 
-#include <gz/math.hh>
-
 namespace gz
 {
 namespace waves
diff --git a/gz-waves/src/CGAL_TEST.cc b/gz-waves/src/CGAL_TEST.cc
index ac728edc..d14e3756 100644
--- a/gz-waves/src/CGAL_TEST.cc
+++ b/gz-waves/src/CGAL_TEST.cc
@@ -50,7 +50,7 @@
 #include "gz/waves/Wavefield.hh"
 #include "gz/waves/WaveParameters.hh"
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/common/Util.hh>
 #include <gz/common/MeshManager.hh>
 #include <gz/math/Vector3.hh>
diff --git a/gz-waves/src/Grid.cc b/gz-waves/src/Grid.cc
index 81f23c62..9670d2eb 100644
--- a/gz-waves/src/Grid.cc
+++ b/gz-waves/src/Grid.cc
@@ -25,7 +25,7 @@
 #include <string>
 #include <vector>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 
 #include "gz/waves/CGALTypes.hh"
 #include "gz/waves/Geometry.hh"
diff --git a/gz-waves/src/LinearRandomFFTWaveSimulation.cc b/gz-waves/src/LinearRandomFFTWaveSimulation.cc
index f9695133..84ff3c4d 100644
--- a/gz-waves/src/LinearRandomFFTWaveSimulation.cc
+++ b/gz-waves/src/LinearRandomFFTWaveSimulation.cc
@@ -25,7 +25,7 @@
 #include <unordered_map>
 #include <vector>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 
 #include "gz/waves/Algorithm.hh"
 #include "gz/waves/Types.hh"
diff --git a/gz-waves/src/LinearRandomFFTWaveSimulationRef.cc b/gz-waves/src/LinearRandomFFTWaveSimulationRef.cc
index e9e80eef..82a0f95f 100644
--- a/gz-waves/src/LinearRandomFFTWaveSimulationRef.cc
+++ b/gz-waves/src/LinearRandomFFTWaveSimulationRef.cc
@@ -37,7 +37,7 @@
 #include <complex>
 #include <random>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 
 #include "gz/waves/Types.hh"
 #include "LinearRandomFFTWaveSimulationRefImpl.hh"
diff --git a/gz-waves/src/LinearRandomWaveSimulation.cc b/gz-waves/src/LinearRandomWaveSimulation.cc
index a47828ba..5ff7936d 100644
--- a/gz-waves/src/LinearRandomWaveSimulation.cc
+++ b/gz-waves/src/LinearRandomWaveSimulation.cc
@@ -21,7 +21,7 @@
 #include <random>
 #include <vector>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 
 #include "gz/waves/WaveSpectrum.hh"
 
@@ -491,7 +491,7 @@ void LinearRandomWaveSimulation::SetWindVelocity(double ux, double uy)
 }
 
 //////////////////////////////////////////////////
-void LinearRandomWaveSimulation::SetSteepness(double value)
+void LinearRandomWaveSimulation::SetSteepness(double)
 {
   /// \todo(srmainwaring) IMPLEMENT
 }
diff --git a/gz-waves/src/LinearRegularWaveSimulation.cc b/gz-waves/src/LinearRegularWaveSimulation.cc
index 5319bffe..7726dbf9 100644
--- a/gz-waves/src/LinearRegularWaveSimulation.cc
+++ b/gz-waves/src/LinearRegularWaveSimulation.cc
@@ -578,7 +578,7 @@ void LinearRegularWaveSimulation::SetWindVelocity(double /*ux*/, double /*uy*/)
 }
 
 //////////////////////////////////////////////////
-void LinearRegularWaveSimulation::SetSteepness(double value)
+void LinearRegularWaveSimulation::SetSteepness(double)
 {
   /// \todo(srmainwaring) IMPLEMENT
 }
diff --git a/gz-waves/src/MeshTools.cc b/gz-waves/src/MeshTools.cc
index 8dd080c8..d61786a0 100644
--- a/gz-waves/src/MeshTools.cc
+++ b/gz-waves/src/MeshTools.cc
@@ -20,8 +20,7 @@
 #include <iterator>
 #include <string>
 
-#include <gz/common.hh>
-#include <gz/math.hh>
+#include <gz/common/Console.hh>
 
 #include "gz/waves/CGALTypes.hh"
 
diff --git a/gz-waves/src/MeshTools_TEST.cc b/gz-waves/src/MeshTools_TEST.cc
index 4938d163..3d7a499a 100644
--- a/gz-waves/src/MeshTools_TEST.cc
+++ b/gz-waves/src/MeshTools_TEST.cc
@@ -18,7 +18,7 @@
 #include <iostream>
 #include <string>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/common/Util.hh>
 #include <gz/common/MeshManager.hh>
 #include <gz/common/Mesh.hh>
diff --git a/gz-waves/src/OceanTile.cc b/gz-waves/src/OceanTile.cc
index 930c4c09..b117c76e 100644
--- a/gz-waves/src/OceanTile.cc
+++ b/gz-waves/src/OceanTile.cc
@@ -22,7 +22,7 @@
 #include <iostream>
 #include <vector>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/common/Mesh.hh>
 #include <gz/common/SubMesh.hh>
 
diff --git a/gz-waves/src/Physics.cc b/gz-waves/src/Physics.cc
index f5290bf6..8b9aa5d1 100644
--- a/gz-waves/src/Physics.cc
+++ b/gz-waves/src/Physics.cc
@@ -26,9 +26,9 @@
 #include <limits>
 #include <string>
 
+#include <gz/common/Console.hh>
 #include <gz/math/Pose3.hh>
 #include <gz/math/Vector3.hh>
-#include <gz/common.hh>
 
 #include <sdf/sdf.hh>
 
diff --git a/gz-waves/src/Physics_TEST.cc b/gz-waves/src/Physics_TEST.cc
index 7ab3d997..241817b8 100644
--- a/gz-waves/src/Physics_TEST.cc
+++ b/gz-waves/src/Physics_TEST.cc
@@ -20,7 +20,7 @@
 #include <string>
 #include <thread>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/common/Util.hh>
 #include <gz/common/MeshManager.hh>
 #include <gz/math/Vector3.hh>
diff --git a/gz-waves/src/TrochoidIrregularWaveSimulation.cc b/gz-waves/src/TrochoidIrregularWaveSimulation.cc
index a8e37dbc..b25da028 100644
--- a/gz-waves/src/TrochoidIrregularWaveSimulation.cc
+++ b/gz-waves/src/TrochoidIrregularWaveSimulation.cc
@@ -184,8 +184,8 @@ void TrochoidIrregularWaveSimulation::Impl::Elevation(
 
 //////////////////////////////////////////////////
 void TrochoidIrregularWaveSimulation::Impl::Pressure(
-    double x, double y, double z,
-    double &pressure)
+    double /*x*/, double /*y*/, double /*z*/,
+    double &/*pressure*/)
 {
   /// \todo(srmainwaring) IMPLEMENT
   gzerr << "Pressure: Not implemented!\n";
@@ -193,10 +193,10 @@ void TrochoidIrregularWaveSimulation::Impl::Pressure(
 
 //////////////////////////////////////////////////
 void TrochoidIrregularWaveSimulation::Impl::Pressure(
-    const Eigen::Ref<const Eigen::ArrayXd>& x,
-    const Eigen::Ref<const Eigen::ArrayXd>& y,
-    const Eigen::Ref<const Eigen::ArrayXd>& z,
-    Eigen::Ref<Eigen::ArrayXd> pressure)
+    const Eigen::Ref<const Eigen::ArrayXd>& /*x*/,
+    const Eigen::Ref<const Eigen::ArrayXd>& /*y*/,
+    const Eigen::Ref<const Eigen::ArrayXd>& /*z*/,
+    Eigen::Ref<Eigen::ArrayXd> /*pressure*/)
 {
   /// \todo(srmainwaring) IMPLEMENT
   gzerr << "Pressure: Not implemented!\n";
@@ -374,8 +374,8 @@ void TrochoidIrregularWaveSimulation::Impl::DisplacementDerivAt(
 
 //////////////////////////////////////////////////
 void TrochoidIrregularWaveSimulation::Impl::ElevationAt(
-    Index ix, Index iy,
-    double &h)
+    Index /*ix*/, Index /*iy*/,
+    double &/*h*/)
 {
   /// \todo(srmainwaring) IMPLEMENT
   gzerr << "ElevationAt: Not implemented!\n";
@@ -383,8 +383,8 @@ void TrochoidIrregularWaveSimulation::Impl::ElevationAt(
 
 //////////////////////////////////////////////////
 void TrochoidIrregularWaveSimulation::Impl::DisplacementAt(
-    Index ix, Index iy,
-    double& sx, double& sy)
+    Index /*ix*/, Index /*iy*/,
+    double& /*sx*/, double& /*sy*/)
 {
   /// \todo(srmainwaring) IMPLEMENT
   gzerr << "DisplacementAt: Not implemented!\n";
@@ -392,8 +392,8 @@ void TrochoidIrregularWaveSimulation::Impl::DisplacementAt(
 
 //////////////////////////////////////////////////
 void TrochoidIrregularWaveSimulation::Impl::PressureAt(
-    Index ix, Index iy, Index iz,
-    double &pressure)
+    Index /*ix*/, Index /*iy*/, Index /*iz*/,
+    double &/*pressure*/)
 {
   /// \todo(srmainwaring) IMPLEMENT
   gzerr << "PressureAt: Not implemented!\n";
@@ -401,8 +401,8 @@ void TrochoidIrregularWaveSimulation::Impl::PressureAt(
 
 //////////////////////////////////////////////////
 void TrochoidIrregularWaveSimulation::Impl::PressureAt(
-    Index iz,
-    Eigen::Ref<Eigen::ArrayXXd> pressure)
+    Index /*iz*/,
+    Eigen::Ref<Eigen::ArrayXXd> /*pressure*/)
 {
   /// \todo(srmainwaring) IMPLEMENT
   gzerr << "PressureAt: Not implemented!\n";
diff --git a/gz-waves/src/Utilities.cc b/gz-waves/src/Utilities.cc
index 68b6a41b..c032d468 100644
--- a/gz-waves/src/Utilities.cc
+++ b/gz-waves/src/Utilities.cc
@@ -19,7 +19,7 @@
 #include <iostream>
 #include <string>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/math.hh>
 #include <sdf/sdf.hh>
 
diff --git a/gz-waves/src/WaveParameters.cc b/gz-waves/src/WaveParameters.cc
index e22ee90a..2e84990b 100644
--- a/gz-waves/src/WaveParameters.cc
+++ b/gz-waves/src/WaveParameters.cc
@@ -20,7 +20,7 @@
 #include <iostream>
 #include <string>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/msgs.hh>
 #include <gz/math/Pose3.hh>
 #include <gz/math/Vector2.hh>
diff --git a/gz-waves/src/Wavefield.cc b/gz-waves/src/Wavefield.cc
index cd1d5d7b..72a30f97 100644
--- a/gz-waves/src/Wavefield.cc
+++ b/gz-waves/src/Wavefield.cc
@@ -21,7 +21,8 @@
 #include <string>
 #include <thread>
 
-#include <gz/transport.hh>
+#include <gz/common/Console.hh>
+#include <gz/transport/Node.hh>
 
 #include "gz/waves/CGALTypes.hh"
 #include "gz/waves/OceanTile.hh"
@@ -30,7 +31,6 @@
 #include "gz/waves/Utilities.hh"
 #include "gz/waves/WaveParameters.hh"
 
-
 namespace gz
 {
 namespace waves
diff --git a/gz-waves/src/WavefieldSampler.cc b/gz-waves/src/WavefieldSampler.cc
index 2a830bf4..6335b4e5 100644
--- a/gz-waves/src/WavefieldSampler.cc
+++ b/gz-waves/src/WavefieldSampler.cc
@@ -22,7 +22,7 @@
 #include <iostream>
 #include <string>
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/math/Pose3.hh>
 #include <gz/math/Vector2.hh>
 #include <gz/math/Vector3.hh>
diff --git a/gz-waves/src/systems/dynamic/CMakeLists.txt b/gz-waves/src/systems/dynamic/CMakeLists.txt
index fb4feddb..d0074f01 100644
--- a/gz-waves/src/systems/dynamic/CMakeLists.txt
+++ b/gz-waves/src/systems/dynamic/CMakeLists.txt
@@ -13,4 +13,6 @@ gz_add_system(dynamic-geometry
     gz-rendering${GZ_RENDERING_VER}-ogre2
     gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
     GzOGRE2::GzOGRE2
+  PRIVATE_COMPILE_DEFS
+    OGRE_IGNORE_UNKNOWN_DEBUG
 )
diff --git a/gz-waves/src/systems/waves/CMakeLists.txt b/gz-waves/src/systems/waves/CMakeLists.txt
index 6d8941ca..5735c673 100644
--- a/gz-waves/src/systems/waves/CMakeLists.txt
+++ b/gz-waves/src/systems/waves/CMakeLists.txt
@@ -65,6 +65,13 @@ target_link_libraries(${rendering_ogre2_target}
     gz-plugin${GZ_PLUGIN_VER}::register
 )
 
+# Suppress an Ogre warning about adding _DEBUG to precompiler definitions.
+# TODO: set conditional on the cmake build type. 
+target_compile_definitions(${rendering_ogre2_target}
+  PUBLIC
+    OGRE_IGNORE_UNKNOWN_DEBUG
+)
+
 #################################################
 gz_add_system(waves-visual
   SOURCES
diff --git a/gz-waves/src/systems/waves/Ogre2OceanGeometry.cc b/gz-waves/src/systems/waves/Ogre2OceanGeometry.cc
index 28b6965e..010d0492 100644
--- a/gz-waves/src/systems/waves/Ogre2OceanGeometry.cc
+++ b/gz-waves/src/systems/waves/Ogre2OceanGeometry.cc
@@ -15,7 +15,7 @@
 
 #include "Ogre2OceanGeometry.hh"
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/rendering/ogre2/Ogre2Material.hh>
 #include <gz/rendering/ogre2/Ogre2Scene.hh>
 
diff --git a/gz-waves/src/systems/waves/Ogre2OceanVisual.cc b/gz-waves/src/systems/waves/Ogre2OceanVisual.cc
index 44d4c15f..0ab4e28b 100644
--- a/gz-waves/src/systems/waves/Ogre2OceanVisual.cc
+++ b/gz-waves/src/systems/waves/Ogre2OceanVisual.cc
@@ -15,7 +15,7 @@
 
 #include "Ogre2OceanVisual.hh"
 
-#include <gz/common.hh>
+#include <gz/common/Console.hh>
 #include <gz/common/SubMesh.hh>
 #include <gz/rendering/ogre2/Ogre2Material.hh>
 #include <gz/rendering/ogre2/Ogre2Scene.hh>
diff --git a/gz-waves/src/systems/waves/RenderEngineExtensionManager.cc b/gz-waves/src/systems/waves/RenderEngineExtensionManager.cc
index 4e75539d..98d26934 100644
--- a/gz-waves/src/systems/waves/RenderEngineExtensionManager.cc
+++ b/gz-waves/src/systems/waves/RenderEngineExtensionManager.cc
@@ -39,6 +39,7 @@
 #include <gz/common/SystemPaths.hh>
 #include <gz/plugin/Loader.hh>
 #include <gz/rendering/config.hh>
+#include <gz/rendering/InstallationDirectories.hh>
 
 #include "RenderEngineExtensionManager.hh"
 #include "RenderEngineExtension.hh"
@@ -460,7 +461,7 @@ bool RenderEngineExtensionManagerPrivate::LoadExtensionPlugin(
 
   // Add default install folder.
   systemPaths.AddPluginPaths(std::string(GZ_RENDERING_PLUGIN_PATH));
-  systemPaths.AddPluginPaths({GZ_RENDERING_ENGINE_INSTALL_DIR});
+  systemPaths.AddPluginPaths(gz::rendering::getEngineInstallDir());
 
   // Add any preset plugin paths.
   for (const auto &path : this->pluginPaths)
diff --git a/gz-waves/test/plots/CMakeLists.txt b/gz-waves/test/plots/CMakeLists.txt
index 3d54d0b2..058a9576 100644
--- a/gz-waves/test/plots/CMakeLists.txt
+++ b/gz-waves/test/plots/CMakeLists.txt
@@ -17,7 +17,9 @@ target_link_libraries(PLOT_GnuPlotExample
 target_include_directories(PLOT_GnuPlotExample
   PUBLIC ${gnuplot-iostream_INCLUDE_DIRS}
 )
-
+target_compile_options(PLOT_GnuPlotExample
+  PRIVATE "-Wno-unused-result"
+)
 
 add_executable(PLOT_LinearRandomFFTWaves PLOT_LinearRandomFFTWaves.cc)
 target_link_libraries(PLOT_LinearRandomFFTWaves
@@ -27,7 +29,9 @@ target_link_libraries(PLOT_LinearRandomFFTWaves
 target_include_directories(PLOT_LinearRandomFFTWaves
   PUBLIC ${gnuplot-iostream_INCLUDE_DIRS}
 )
-
+target_compile_options(PLOT_LinearRandomFFTWaves
+  PRIVATE "-Wno-unused-result"
+)
 
 add_executable(PLOT_LinearRandomWaves PLOT_LinearRandomWaves.cc)
 target_link_libraries(PLOT_LinearRandomWaves
@@ -37,7 +41,9 @@ target_link_libraries(PLOT_LinearRandomWaves
 target_include_directories(PLOT_LinearRandomWaves
   PUBLIC ${gnuplot-iostream_INCLUDE_DIRS}
 )
-
+target_compile_options(PLOT_LinearRandomWaves
+  PRIVATE "-Wno-unused-result"
+)
 
 add_executable(PLOT_LinearRegularWaves PLOT_LinearRegularWaves.cc)
 target_link_libraries(PLOT_LinearRegularWaves
@@ -47,7 +53,9 @@ target_link_libraries(PLOT_LinearRegularWaves
 target_include_directories(PLOT_LinearRegularWaves
   PUBLIC ${gnuplot-iostream_INCLUDE_DIRS}
 )
-
+target_compile_options(PLOT_LinearRegularWaves
+  PRIVATE "-Wno-unused-result"
+)
 
 add_executable(PLOT_WaveSpectrum PLOT_WaveSpectrum.cc)
 target_link_libraries(PLOT_WaveSpectrum
@@ -57,6 +65,9 @@ target_link_libraries(PLOT_WaveSpectrum
 target_include_directories(PLOT_WaveSpectrum
   PUBLIC ${gnuplot-iostream_INCLUDE_DIRS}
 )
+target_compile_options(PLOT_WaveSpectrum
+  PRIVATE "-Wno-unused-result"
+)
 
 #============================================================================
 # Install targets