From cb7dc873c095c63d6bd2713b5ee9a7769bd79fac Mon Sep 17 00:00:00 2001
From: Joseph Walton-Rivers <joseph@walton-rivers.uk>
Date: Mon, 27 Jun 2022 09:35:23 +0100
Subject: [PATCH] move bullet integration out of tree to ensure the includes
 can be ignored

---
 CMakeLists.txt                                |  3 ++
 demo/demo/main.cpp                            |  2 +-
 fggl/CMakeLists.txt                           |  1 -
 fggl/gfx/ogl/renderer.cpp                     | 11 ++---
 fggl/scenes/game.cpp                          |  2 +-
 include/fggl/debug/pragmas.hpp                | 44 +++++++++++++++++++
 .../bullet/CMakeLists.txt                     | 11 +++--
 .../include}/fggl/phys/bullet/bullet.hpp      | 16 ++++++-
 .../include}/fggl/phys/bullet/motion.hpp      | 16 ++++++-
 .../include}/fggl/phys/bullet/phys_draw.hpp   |  0
 .../include}/fggl/phys/bullet/types.hpp       | 16 ++++++-
 .../bullet/src}/phys_draw.cpp                 | 16 ++++++-
 .../bullet/src}/simulation.cpp                | 18 +++++++-
 13 files changed, 137 insertions(+), 19 deletions(-)
 create mode 100644 include/fggl/debug/pragmas.hpp
 rename {fggl/phys => integrations}/bullet/CMakeLists.txt (84%)
 rename {include => integrations/bullet/include}/fggl/phys/bullet/bullet.hpp (73%)
 rename {include => integrations/bullet/include}/fggl/phys/bullet/motion.hpp (72%)
 rename {include => integrations/bullet/include}/fggl/phys/bullet/phys_draw.hpp (100%)
 rename {include => integrations/bullet/include}/fggl/phys/bullet/types.hpp (80%)
 rename {fggl/phys/bullet => integrations/bullet/src}/phys_draw.cpp (73%)
 rename {fggl/phys/bullet => integrations/bullet/src}/simulation.cpp (93%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e513287..49718b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,9 @@ add_subdirectory( vendor/imgui )
 add_subdirectory( fggl )
 add_subdirectory( vendor/header_only )
 
+# 3rd party integrations
+add_subdirectory( integrations/bullet )
+
 
 ## G++ enable insane checks
 target_compile_options( ${PROJECT_NAME} PRIVATE -Wall -fno-strict-aliasing -fno-strict-overflow )
diff --git a/demo/demo/main.cpp b/demo/demo/main.cpp
index 6e36d92..a5d78bd 100644
--- a/demo/demo/main.cpp
+++ b/demo/demo/main.cpp
@@ -34,7 +34,7 @@
 #include "fggl/platform/paths.hpp"
 
 #include "fggl/ecs3/types.hpp"
-#include "fggl/phys/bullet/bullet.hpp"
+#include "../../integrations/bullet/include/fggl/phys/bullet/bullet.hpp"
 
 #include "fggl/scenes/menu.hpp"
 
diff --git a/fggl/CMakeLists.txt b/fggl/CMakeLists.txt
index baa8948..5794754 100644
--- a/fggl/CMakeLists.txt
+++ b/fggl/CMakeLists.txt
@@ -80,7 +80,6 @@ add_subdirectory(gfx)
 add_subdirectory(audio)
 
 # physics integration
-add_subdirectory(phys/bullet)
 
 # Debug backend
 add_subdirectory(debug)
diff --git a/fggl/gfx/ogl/renderer.cpp b/fggl/gfx/ogl/renderer.cpp
index 602cb37..2ded83f 100644
--- a/fggl/gfx/ogl/renderer.cpp
+++ b/fggl/gfx/ogl/renderer.cpp
@@ -14,6 +14,7 @@
 
 #include <fggl/util/service.hpp>
 #include "fggl/debug/logging.hpp"
+#include "fggl/debug/pragmas.hpp"
 
 #include "fggl/gfx/ogl/common.hpp"
 #include "fggl/gfx/window.hpp"
@@ -87,10 +88,8 @@ constexpr auto static fggl_ogl_type(GLenum type) -> const char * {
 	return "unknown";
 }
 
-#ifndef _MSC_VER
-	#pragma clang diagnostic push
-	#pragma ide diagnostic ignored "bugprone-easily-swappable-parameters"
-#endif
+PRAGMA_DIAGNOSTIC_PUSH
+#pragma ide diagnostic ignored "bugprone-easily-swappable-parameters"
 
 constexpr const char* OGL_LOG_FMT {"[GL] {}, {}: [{}]: {}"};
 
@@ -114,9 +113,7 @@ void static GLAPIENTRY fggl_ogl_to_spdlog(GLenum source, GLenum type, unsigned i
 	}
 }
 
-#ifndef _MSC_VER
-	#pragma clang diagnostic pop
-#endif
+PRAGMA_DIAGNOSTIC_POP
 }
 
 /**
diff --git a/fggl/scenes/game.cpp b/fggl/scenes/game.cpp
index 2dea4c4..dfd22b7 100644
--- a/fggl/scenes/game.cpp
+++ b/fggl/scenes/game.cpp
@@ -18,7 +18,7 @@
 
 #include "fggl/scenes/game.hpp"
 #include "fggl/util/service.hpp"
-#include "fggl/phys/bullet/types.hpp"
+#include "../../integrations/bullet/include/fggl/phys/bullet/types.hpp"
 
 namespace fggl::scenes {
 
diff --git a/include/fggl/debug/pragmas.hpp b/include/fggl/debug/pragmas.hpp
new file mode 100644
index 0000000..9274125
--- /dev/null
+++ b/include/fggl/debug/pragmas.hpp
@@ -0,0 +1,44 @@
+/*
+ * This file is part of FGGL.
+ *
+ * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with FGGL.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
+//
+// Created by webpigeon on 27/06/22.
+//
+
+#ifndef FGGL_DEBUG_PRAGMAS_HPP
+#define FGGL_DEBUG_PRAGMAS_HPP
+
+#if defined(__clang__)
+#define PRAGMA_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
+#elif defined(__GNUC__)
+#define PRAGMA_DIAGNOSTIC_PUSH _Pragma("gcc diagnostic push")
+#else
+#define PRAGMA_DIAGNOSTIC_PUSH
+#endif
+
+#if defined(__clang__)
+#define PRAGMA_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
+#elif defined(__GNUC__)
+#define PRAGMA_DIAGNOSTIC_POP _Pragma("gcc diagnostic pop")
+#else
+#define PRAGMA_DIAGNOSTIC_POP
+#endif
+
+#if defined(__JETBRAINS_IDE__)
+#define PRAGMA_CLION_IGNORED(x) _Pragma("ide diagnostic ignored \"" x "\"")
+#else
+#define PRAGMA_CLION_IGNORED
+#endif
+
+#endif //FGGL_DEBUG_PRAGMAS_HPP
diff --git a/fggl/phys/bullet/CMakeLists.txt b/integrations/bullet/CMakeLists.txt
similarity index 84%
rename from fggl/phys/bullet/CMakeLists.txt
rename to integrations/bullet/CMakeLists.txt
index da6eb58..30b2f8f 100644
--- a/fggl/phys/bullet/CMakeLists.txt
+++ b/integrations/bullet/CMakeLists.txt
@@ -23,11 +23,16 @@ else()
         target_link_libraries(fggl PUBLIC ${BULLET_LIBRARIES})
     endif()
 
+    target_include_directories( fggl
+        PUBLIC
+            $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
+            $<INSTALL_INTERFACE:include>
+    )
 
     # bullet cpp files
-    target_sources(fggl
+    target_sources( fggl
         PRIVATE
-            simulation.cpp
-            phys_draw.cpp
+            src/simulation.cpp
+            src/phys_draw.cpp
     )
 endif()
diff --git a/include/fggl/phys/bullet/bullet.hpp b/integrations/bullet/include/fggl/phys/bullet/bullet.hpp
similarity index 73%
rename from include/fggl/phys/bullet/bullet.hpp
rename to integrations/bullet/include/fggl/phys/bullet/bullet.hpp
index af04029..73db6fd 100644
--- a/include/fggl/phys/bullet/bullet.hpp
+++ b/integrations/bullet/include/fggl/phys/bullet/bullet.hpp
@@ -12,6 +12,20 @@
  * If not, see <https://www.gnu.org/licenses/>.
  */
 
+/*
+ * This file is part of FGGL.
+ *
+ * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with FGGL.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
 //
 // Created by webpigeon on 24/04/22.
 //
@@ -22,7 +36,7 @@
 #include "fggl/ecs3/module/module.hpp"
 
 #include "fggl/phys/types.hpp"
-#include "fggl/phys/bullet/types.hpp"
+#include "types.hpp"
 
 namespace fggl::phys::bullet {
 
diff --git a/include/fggl/phys/bullet/motion.hpp b/integrations/bullet/include/fggl/phys/bullet/motion.hpp
similarity index 72%
rename from include/fggl/phys/bullet/motion.hpp
rename to integrations/bullet/include/fggl/phys/bullet/motion.hpp
index 0b21e8a..5b0540a 100644
--- a/include/fggl/phys/bullet/motion.hpp
+++ b/integrations/bullet/include/fggl/phys/bullet/motion.hpp
@@ -12,6 +12,20 @@
  * If not, see <https://www.gnu.org/licenses/>.
  */
 
+/*
+ * This file is part of FGGL.
+ *
+ * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with FGGL.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
 //
 // Created by webpigeon on 11/06/22.
 //
@@ -19,7 +33,7 @@
 #ifndef FGGL_PHYS_BULLET_MOTION_HPP
 #define FGGL_PHYS_BULLET_MOTION_HPP
 
-#include "fggl/phys/bullet/types.hpp"
+#include "types.hpp"
 
 namespace fggl::phys::bullet {
 
diff --git a/include/fggl/phys/bullet/phys_draw.hpp b/integrations/bullet/include/fggl/phys/bullet/phys_draw.hpp
similarity index 100%
rename from include/fggl/phys/bullet/phys_draw.hpp
rename to integrations/bullet/include/fggl/phys/bullet/phys_draw.hpp
diff --git a/include/fggl/phys/bullet/types.hpp b/integrations/bullet/include/fggl/phys/bullet/types.hpp
similarity index 80%
rename from include/fggl/phys/bullet/types.hpp
rename to integrations/bullet/include/fggl/phys/bullet/types.hpp
index 222d5e1..0809053 100644
--- a/include/fggl/phys/bullet/types.hpp
+++ b/integrations/bullet/include/fggl/phys/bullet/types.hpp
@@ -12,6 +12,20 @@
  * If not, see <https://www.gnu.org/licenses/>.
  */
 
+/*
+ * This file is part of FGGL.
+ *
+ * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with FGGL.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
 //
 // Created by webpigeon on 24/04/22.
 //
@@ -21,7 +35,7 @@
 
 #include "fggl/ecs3/ecs.hpp"
 #include "fggl/phys/types.hpp"
-#include "fggl/phys/bullet/phys_draw.hpp"
+#include "phys_draw.hpp"
 
 #include <bullet/btBulletDynamicsCommon.h>
 #include <bullet/btBulletCollisionCommon.h>
diff --git a/fggl/phys/bullet/phys_draw.cpp b/integrations/bullet/src/phys_draw.cpp
similarity index 73%
rename from fggl/phys/bullet/phys_draw.cpp
rename to integrations/bullet/src/phys_draw.cpp
index 7dd9ef2..8a1d9f1 100644
--- a/fggl/phys/bullet/phys_draw.cpp
+++ b/integrations/bullet/src/phys_draw.cpp
@@ -12,11 +12,25 @@
  * If not, see <https://www.gnu.org/licenses/>.
  */
 
+/*
+ * This file is part of FGGL.
+ *
+ * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with FGGL.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
 //
 // Created by webpigeon on 30/05/22.
 //
 
-#include "fggl/phys/bullet/phys_draw.hpp"
+#include "../include/fggl/phys/bullet/phys_draw.hpp"
 #include "fggl/debug/draw.hpp"
 
 #include <iostream>
diff --git a/fggl/phys/bullet/simulation.cpp b/integrations/bullet/src/simulation.cpp
similarity index 93%
rename from fggl/phys/bullet/simulation.cpp
rename to integrations/bullet/src/simulation.cpp
index 9f31835..e4fbcbe 100644
--- a/fggl/phys/bullet/simulation.cpp
+++ b/integrations/bullet/src/simulation.cpp
@@ -12,8 +12,22 @@
  * If not, see <https://www.gnu.org/licenses/>.
  */
 
-#include "fggl/phys/bullet/types.hpp"
-#include "fggl/phys/bullet/motion.hpp"
+/*
+ * This file is part of FGGL.
+ *
+ * FGGL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * FGGL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with FGGL.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "../include/fggl/phys/bullet/types.hpp"
+#include "../include/fggl/phys/bullet/motion.hpp"
 
 namespace fggl::phys::bullet {
 
-- 
GitLab