diff --git a/common/dialogs/git/panel_git_repos.cpp b/common/dialogs/git/panel_git_repos.cpp
index d7a60544b8..ba310072d5 100644
--- a/common/dialogs/git/panel_git_repos.cpp
+++ b/common/dialogs/git/panel_git_repos.cpp
@@ -31,6 +31,7 @@
 #include <wx/bmpbuttn.h>
 #include <wx/button.h>
 #include <wx/checkbox.h>
+#include <wx/log.h>
 
 
 PANEL_GIT_REPOS::PANEL_GIT_REPOS( wxWindow* aParent ) : PANEL_GIT_REPOS_BASE( aParent)
diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp
index 02b902f5b1..91c2a09934 100644
--- a/common/tool/conditional_menu.cpp
+++ b/common/tool/conditional_menu.cpp
@@ -26,6 +26,7 @@
 #include <bitmaps.h>
 #include <tool/conditional_menu.h>
 #include <tool/action_menu.h>
+#include <tool/selection.h>
 #include <kiface_base.h>
 #include <widgets/ui_common.h>
 
diff --git a/eeschema/netlist_exporters/netlist_exporter_base.h b/eeschema/netlist_exporters/netlist_exporter_base.h
index a3c777cb65..b1f722e68c 100644
--- a/eeschema/netlist_exporters/netlist_exporter_base.h
+++ b/eeschema/netlist_exporters/netlist_exporter_base.h
@@ -26,11 +26,12 @@
 #ifndef NETLIST_EXPORTER_H
 #define NETLIST_EXPORTER_H
 
-#include <sch_symbol.h>
-#include <sch_label.h>
-#include <sch_sheet.h>
 #include <schematic.h>
 
+class SCH_SYMBOL;
+class LIB_SYMBOL;
+class REPORTER;
+
 /**
  * Track unique wxStrings and is useful in telling if a string has been seen before.
  */
diff --git a/eeschema/netlist_exporters/netlist_exporter_spice_model.h b/eeschema/netlist_exporters/netlist_exporter_spice_model.h
index e730960c4e..80492cc295 100644
--- a/eeschema/netlist_exporters/netlist_exporter_spice_model.h
+++ b/eeschema/netlist_exporters/netlist_exporter_spice_model.h
@@ -26,6 +26,8 @@
 
 #include "netlist_exporter_spice.h"
 
+enum LABEL_FLAG_SHAPE : unsigned int;
+
 
 class NETLIST_EXPORTER_SPICE_MODEL : public NETLIST_EXPORTER_SPICE
 {
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index b8f2616dea..e81aacc003 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -49,6 +49,7 @@
 #include <tools/ee_selection_tool.h>
 #include <view/view_controls.h>
 #include <wx/choicdlg.h>
+#include <wx/fswatcher.h>
 #include <wx/log.h>
 #include <wx/msgdlg.h>
 
diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h
index 4df1e622c7..5fc4a3f6e0 100644
--- a/eeschema/sch_base_frame.h
+++ b/eeschema/sch_base_frame.h
@@ -35,7 +35,6 @@
 #include <utility>
 #include <vector>
 #include <wx/event.h>
-#include <wx/fswatcher.h>
 #include <wx/datetime.h>
 #include <wx/gdicmn.h>
 #include <wx/string.h>
@@ -59,6 +58,21 @@ class SYMBOL_EDITOR_SETTINGS;
 class NL_SCHEMATIC_PLUGIN;
 class PANEL_SCH_SELECTION_FILTER;
 
+#ifdef wxHAS_INOTIFY
+#define wxFileSystemWatcher wxInotifyFileSystemWatcher
+#elif defined( wxHAS_KQUEUE ) && defined( wxHAVE_FSEVENTS_FILE_NOTIFICATIONS )
+#define wxFileSystemWatcher wxFsEventsFileSystemWatcher
+#elif defined( wxHAS_KQUEUE )
+#define wxFileSystemWatcher wxKqueueFileSystemWatcher
+#elif defined( __WINDOWS__ )
+#define wxFileSystemWatcher wxMSWFileSystemWatcher
+#else
+#define wxFileSystemWatcher wxPollingFileSystemWatcher
+#endif
+
+class wxFileSystemWatcher;
+class wxFileSystemWatcherEvent;
+
 /**
  * Load symbol from symbol library table.
  *
diff --git a/eeschema/sch_commit.cpp b/eeschema/sch_commit.cpp
index 76aec856d5..e771fe19de 100644
--- a/eeschema/sch_commit.cpp
+++ b/eeschema/sch_commit.cpp
@@ -35,6 +35,7 @@
 #include <connection_graph.h>
 
 #include <functional>
+#include <wx/log.h>
 
 
 SCH_COMMIT::SCH_COMMIT( TOOL_MANAGER* aToolMgr ) :
diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp
index f4408f0439..b2dd863251 100644
--- a/eeschema/sch_io/altium/sch_io_altium.cpp
+++ b/eeschema/sch_io/altium/sch_io_altium.cpp
@@ -57,8 +57,9 @@
 #include <string_utils.h>
 #include <sch_edit_frame.h>
 #include <wildcards_and_files_ext.h>
-#include <wx/mstream.h>
 #include <wx/log.h>
+#include <wx/dir.h>
+#include <wx/mstream.h>
 #include <wx/zstream.h>
 #include <wx/wfstream.h>
 #include <magic_enum.hpp>
diff --git a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp
index 3ace61a172..21f5889182 100644
--- a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp
+++ b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp
@@ -40,6 +40,7 @@
 #include <string_utils.h>
 #include <bezier_curves.h>
 #include <wx/base64.h>
+#include <wx/log.h>
 #include <wx/url.h>
 #include <wx/mstream.h>
 #include <gfx_import_utils.h>
diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h
index b1f593532d..62f273b7a8 100644
--- a/eeschema/sch_label.h
+++ b/eeschema/sch_label.h
@@ -89,7 +89,7 @@ private:
 /*
  * Label and flag shapes used with text objects.
  */
-enum LABEL_FLAG_SHAPE
+enum LABEL_FLAG_SHAPE : unsigned int
 {
     L_INPUT,
     L_OUTPUT,
@@ -107,7 +107,7 @@ enum LABEL_FLAG_SHAPE
 /*
  * Specific enums for property manager (not used elsewhere)
  */
-enum LABEL_SHAPE
+enum LABEL_SHAPE : unsigned int
 {
     LABEL_INPUT    = L_INPUT,
     LABEL_OUTPUT   = L_OUTPUT,
@@ -116,7 +116,7 @@ enum LABEL_SHAPE
     LABEL_PASSIVE  = L_UNSPECIFIED
 };
 
-enum FLAG_SHAPE
+enum FLAG_SHAPE : unsigned int
 {
     FLAG_DOT       = F_DOT,
     FLAG_CIRCLE    = F_ROUND,
diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index bcd5b7e533..bff21bfc84 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -26,6 +26,7 @@
 
 #include <stack>
 #include <wx/filefn.h>
+#include <wx/log.h>
 
 #include <eda_item.h>
 #include <id.h>
diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h
index c84df1b194..cf5bf97257 100644
--- a/eeschema/sch_screen.h
+++ b/eeschema/sch_screen.h
@@ -45,12 +45,11 @@
 #include <title_block.h>
 
 #include <lib_id.h>
-#include <sch_symbol.h>         // SCH_SYMBOL_INSTANCE
 #include <sch_reference_list.h>
 #include <sch_rtree.h>
 #include <sch_sheet.h>
 #include <sch_label.h>
-#include <sch_sheet_path.h>
+#include <sch_sheet_path.h>     // SCH_SYMBOL_INSTANCE
 
 class BUS_ALIAS;
 class EDA_ITEM;
diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp
index 3688325d19..6531750bfe 100644
--- a/eeschema/schematic_undo_redo.cpp
+++ b/eeschema/schematic_undo_redo.cpp
@@ -36,6 +36,7 @@
 #include <tools/ee_selection_tool.h>
 #include <drawing_sheet/ds_proxy_undo_item.h>
 #include <tool/actions.h>
+#include <wx/log.h>
 
 
 /* Functions to undo and redo edit commands.
diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp
index 10204e1fcf..9fe39c4345 100644
--- a/eeschema/sim/simulator_frame_ui.cpp
+++ b/eeschema/sim/simulator_frame_ui.cpp
@@ -30,6 +30,8 @@
 #include <wx/wfstream.h>
 #include <wx/stdstream.h>
 #include <wx/debug.h>
+#include <wx/clipbrd.h>
+#include <wx/log.h>
 
 #include <project/project_file.h>
 #include <sch_edit_frame.h>
@@ -50,7 +52,6 @@
 #include <dialogs/dialog_sim_format_value.h>
 #include <eeschema_settings.h>
 #include "kiplatform/app.h"
-#include "wx/clipbrd.h"
 
 
 SIM_TRACE_TYPE operator|( SIM_TRACE_TYPE aFirst, SIM_TRACE_TYPE aSecond )
diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp
index 074027cdec..899975defa 100644
--- a/eeschema/symbol_editor/symbol_edit_frame.cpp
+++ b/eeschema/symbol_editor/symbol_edit_frame.cpp
@@ -79,6 +79,7 @@
 #include <panel_sym_lib_table.h>
 #include <string_utils.h>
 #include <wx/msgdlg.h>
+#include <wx/log.h>
 
 
 bool SYMBOL_EDIT_FRAME::m_showDeMorgan = false;
diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp
index a2c4cefdd6..b6f9ba0cc3 100644
--- a/eeschema/symbol_viewer_frame.cpp
+++ b/eeschema/symbol_viewer_frame.cpp
@@ -61,6 +61,7 @@
 #include <tools/ee_inspection_tool.h>
 #include <view/view_controls.h>
 #include <wx/srchctrl.h>
+#include <wx/log.h>
 
 #include <default_values.h>
 #include <string_utils.h>
diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp
index d0eb525fa1..99983d7ee8 100644
--- a/eeschema/tools/sch_editor_control.cpp
+++ b/eeschema/tools/sch_editor_control.cpp
@@ -78,6 +78,7 @@
 #include <wx_filename.h>
 #include <sch_sheet_path.h>
 #include <wx/filedlg.h>
+#include <wx/log.h>
 #include <wx/treectrl.h>
 #include <wx/msgdlg.h>
 #include "sch_edit_table_tool.h"
diff --git a/eeschema/widgets/panel_symbol_chooser.cpp b/eeschema/widgets/panel_symbol_chooser.cpp
index 7e264ecc61..92392954b6 100644
--- a/eeschema/widgets/panel_symbol_chooser.cpp
+++ b/eeschema/widgets/panel_symbol_chooser.cpp
@@ -43,6 +43,7 @@
 #include <wx/splitter.h>
 #include <wx/timer.h>
 #include <wx/wxhtml.h>
+#include <wx/log.h>
 
 
 wxString PANEL_SYMBOL_CHOOSER::g_symbolSearchString;
diff --git a/include/font/glyph.h b/include/font/glyph.h
index f1aa6d7744..7e756ecd13 100644
--- a/include/font/glyph.h
+++ b/include/font/glyph.h
@@ -29,8 +29,8 @@
 #include <memory>
 #include <math/box2.h>
 #include <geometry/shape_poly_set.h>
+#include <geometry/eda_angle.h>
 #include <wx/debug.h>
-#include "../../libs/kimath/include/geometry/eda_angle.h"
 
 #if defined( _MSC_VER )
 #pragma warning( push )
diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h
index 1b4168c823..e716e2eece 100644
--- a/include/pcb_base_frame.h
+++ b/include/pcb_base_frame.h
@@ -37,7 +37,6 @@
 #include <pcb_screen.h>
 #include <vector>
 
-#include <wx/fswatcher.h>
 #include <wx/datetime.h>
 #include <wx/timer.h>
 
@@ -63,6 +62,21 @@ struct MAGNETIC_SETTINGS;
 class NL_PCBNEW_PLUGIN;
 class PROGRESS_REPORTER;
 
+#ifdef wxHAS_INOTIFY
+#define wxFileSystemWatcher wxInotifyFileSystemWatcher
+#elif defined( wxHAS_KQUEUE ) && defined( wxHAVE_FSEVENTS_FILE_NOTIFICATIONS )
+#define wxFileSystemWatcher wxFsEventsFileSystemWatcher
+#elif defined( wxHAS_KQUEUE )
+#define wxFileSystemWatcher wxKqueueFileSystemWatcher
+#elif defined( __WINDOWS__ )
+#define wxFileSystemWatcher wxMSWFileSystemWatcher
+#else
+#define wxFileSystemWatcher wxPollingFileSystemWatcher
+#endif
+
+class wxFileSystemWatcher;
+class wxFileSystemWatcherEvent;
+
 wxDECLARE_EVENT( EDA_EVT_BOARD_CHANGED, wxCommandEvent );
 
 /**
diff --git a/include/pgm_base.h b/include/pgm_base.h
index ad8f6de62d..6bf13edabe 100644
--- a/include/pgm_base.h
+++ b/include/pgm_base.h
@@ -39,12 +39,12 @@
 #include <search_stack.h>
 #include <settings/environment.h>
 #include <wx/filename.h>
-#include <wx/snglinst.h>
 
 class wxApp;
 class wxMenu;
 class wxWindow;
 class wxSplashScreen;
+class wxSingleInstanceChecker;
 
 class BACKGROUND_JOBS_MONITOR;
 class NOTIFICATIONS_MANAGER;
diff --git a/include/tool/selection_conditions.h b/include/tool/selection_conditions.h
index 89f0cb18eb..e4287ae4f4 100644
--- a/include/tool/selection_conditions.h
+++ b/include/tool/selection_conditions.h
@@ -30,7 +30,8 @@
 #include <functional>
 #include <core/typeinfo.h>
 #include <vector>
-#include <tool/selection.h>
+
+class SELECTION;
 
 ///< Functor type that checks a specific condition for selected items.
 typedef std::function<bool (const SELECTION&)> SELECTION_CONDITION;
diff --git a/include/view/view_overlay.h b/include/view/view_overlay.h
index 55c09bacd9..cc8a48e359 100644
--- a/include/view/view_overlay.h
+++ b/include/view/view_overlay.h
@@ -33,9 +33,9 @@
 #include <vector>
 #include <deque>
 
-#include <geometry/shape_poly_set.h>
-
 class SEG;
+class SHAPE_LINE_CHAIN;
+class SHAPE_POLY_SET;
 
 namespace KIGFX
 {
diff --git a/kicad/cli/command_pcb_export_3d.cpp b/kicad/cli/command_pcb_export_3d.cpp
index e77639f829..8d9861b843 100644
--- a/kicad/cli/command_pcb_export_3d.cpp
+++ b/kicad/cli/command_pcb_export_3d.cpp
@@ -20,6 +20,7 @@
 
 #include "command_pcb_export_3d.h"
 #include <cli/exit_codes.h>
+#include <base_units.h>
 #include <kiface_base.h>
 #include <regex>
 #include <string_utils.h>
diff --git a/kicad/cli/command_sch_export_bom.cpp b/kicad/cli/command_sch_export_bom.cpp
index 314e1eea7f..b646a6a51c 100644
--- a/kicad/cli/command_sch_export_bom.cpp
+++ b/kicad/cli/command_sch_export_bom.cpp
@@ -25,6 +25,7 @@
 #include <layer_ids.h>
 #include <string_utils.h>
 #include <wx/crt.h>
+#include <wx/tokenzr.h>
 #include <schematic_settings.h>
 
 #include <macros.h>
diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp
index 2e9a2eb1a5..b2b68141c1 100644
--- a/pcbnew/dialogs/dialog_drc.cpp
+++ b/pcbnew/dialogs/dialog_drc.cpp
@@ -41,6 +41,7 @@
 #include <wildcards_and_files_ext.h>
 #include <pcb_marker.h>
 #include <pgm_base.h>
+#include <wx/app.h>
 #include <wx/filedlg.h>
 #include <wx/msgdlg.h>
 #include <wx/wupdlock.h>
diff --git a/pcbnew/exporters/export_hyperlynx.cpp b/pcbnew/exporters/export_hyperlynx.cpp
index f122129c5b..c7fa3a8597 100644
--- a/pcbnew/exporters/export_hyperlynx.cpp
+++ b/pcbnew/exporters/export_hyperlynx.cpp
@@ -38,6 +38,7 @@
 #include <locale_io.h>
 #include <reporter.h>
 #include <exporters/board_exporter_base.h>
+#include <wx/log.h>
 
 static double iu2hyp( double iu )
 {
diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp
index e623b076d2..d5fbfde55f 100644
--- a/pcbnew/pcb_base_frame.cpp
+++ b/pcbnew/pcb_base_frame.cpp
@@ -57,6 +57,7 @@
 #include <math/vector2d.h>
 #include <math/vector2wx.h>
 #include <widgets/msgpanel.h>
+#include <wx/fswatcher.h>
 
 #include <settings/settings_manager.h>
 #include <settings/cvpcb_settings.h>
diff --git a/pcbnew/python/scripting/pcbnew_action_plugins.cpp b/pcbnew/python/scripting/pcbnew_action_plugins.cpp
index 8486a6a888..e31e91d893 100644
--- a/pcbnew/python/scripting/pcbnew_action_plugins.cpp
+++ b/pcbnew/python/scripting/pcbnew_action_plugins.cpp
@@ -41,6 +41,7 @@
 #include <tools/pcb_selection_tool.h>
 #include <pcb_painter.h>
 #include <wx/msgdlg.h>
+#include <wx/app.h>
 #include <kiplatform/app.h>
 #include "../../scripting/python_scripting.h"
 
diff --git a/pcbnew/tools/pcb_grid_helper.h b/pcbnew/tools/pcb_grid_helper.h
index 65d248b01c..186c02869b 100644
--- a/pcbnew/tools/pcb_grid_helper.h
+++ b/pcbnew/tools/pcb_grid_helper.h
@@ -30,6 +30,7 @@
 #include <pcb_item_containers.h>
 #include <tool/grid_helper.h>
 
+class SHAPE_ARC;
 class TOOL_MANAGER;
 struct MAGNETIC_SETTINGS;
 struct PCB_SELECTION_FILTER_OPTIONS;
diff --git a/pcbnew/widgets/panel_footprint_chooser.cpp b/pcbnew/widgets/panel_footprint_chooser.cpp
index a021b8e5c0..c64fcdfd3d 100644
--- a/pcbnew/widgets/panel_footprint_chooser.cpp
+++ b/pcbnew/widgets/panel_footprint_chooser.cpp
@@ -26,6 +26,7 @@
 #include <widgets/panel_footprint_chooser.h>
 #include <wx/button.h>
 #include <wx/clipbrd.h>
+#include <wx/log.h>
 #include <wx/panel.h>
 #include <wx/sizer.h>
 #include <wx/splitter.h>