From 17b8ab61b86cdd5a8e7a3d669f15a6d4c75baf33 Mon Sep 17 00:00:00 2001
From: Josh Morgenstern <josh@morgenstern.dev>
Date: Mon, 21 Jun 2021 19:51:08 +0200
Subject: [PATCH] [#83] remove boost, using std::filesystem

---
 config/Libraries.cmake           |  1 -
 config/lib/Boost.cmake           | 14 --------------
 include/vkcv/Utils.hpp           | 11 ++++++++++-
 projects/first_mesh/src/main.cpp |  2 ++
 src/vkcv/Utils.cpp               | 17 ++++++++++++-----
 5 files changed, 24 insertions(+), 21 deletions(-)
 delete mode 100644 config/lib/Boost.cmake

diff --git a/config/Libraries.cmake b/config/Libraries.cmake
index cebc1533..e04aa357 100644
--- a/config/Libraries.cmake
+++ b/config/Libraries.cmake
@@ -17,7 +17,6 @@ set(vkcv_config_msg " - Library: ")
 include(${vkcv_config_lib}/GLFW.cmake)    # glfw-x11 / glfw-wayland					# libglfw3-dev
 include(${vkcv_config_lib}/Vulkan.cmake)  # vulkan-intel / vulkan-radeon / nvidia	# libvulkan-dev
 include(${vkcv_config_lib}/SPIRV_Cross.cmake)  # SPIRV-Cross	                    # libspirv_cross_c_shared
-include(${vkcv_config_lib}/Boost.cmake)  # Boost
 
 # cleanup of compiler flags
 if (vkcv_flags)
diff --git a/config/lib/Boost.cmake b/config/lib/Boost.cmake
deleted file mode 100644
index ab7ef9a8..00000000
--- a/config/lib/Boost.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-set( BOOST_ROOT "C:/Tools/Boost/" CACHE PATH "Boost library path" )
-
-set(Boost_USE_STATIC_LIBS ON)
-set(Boost_USE_MULTITHREADED ON)
-set(Boost_USE_STATIC_RUNTIME OFF)
-
-find_package(Boost REQUIRED COMPONENTS filesystem)
-
-if (Boost_FOUND)
-    list(APPEND vkcv_includes ${Boost_INCLUDE_DIR})
-    list(APPEND vkcv_libraries ${Boost_LIBRARIES})
-
-    message(${vkcv_config_msg} " Boost  -   ")
-endif ()
diff --git a/include/vkcv/Utils.hpp b/include/vkcv/Utils.hpp
index 4158a70a..6a323bcc 100644
--- a/include/vkcv/Utils.hpp
+++ b/include/vkcv/Utils.hpp
@@ -2,12 +2,21 @@
 #include <string>
 
 namespace utils {
+
+    extern std::string g_binaryDir;
     
     /**
-     * @brief Given a relative path to the executable, the absolute path is returned
+     * @brief 
      * 
      * @param path The relative path
      * @return std::string The absolute path
      */
     std::string absolutePath(std::string path);
+
+    /**
+     * @brief Set the Binary Dir object
+     * 
+     * @param argv0 
+     */
+    void setBinaryDir(const char* argv0);
 }
diff --git a/projects/first_mesh/src/main.cpp b/projects/first_mesh/src/main.cpp
index 3d7d8209..7f4d6b69 100644
--- a/projects/first_mesh/src/main.cpp
+++ b/projects/first_mesh/src/main.cpp
@@ -10,6 +10,8 @@
 int main(int argc, const char** argv) {
 	const char* applicationName = "First Mesh";
 
+	utils::setBinaryDir(argv[0]);
+
 	uint32_t windowWidth = 800;
 	uint32_t windowHeight = 600;
 
diff --git a/src/vkcv/Utils.cpp b/src/vkcv/Utils.cpp
index 301cd1f0..5a41bff0 100644
--- a/src/vkcv/Utils.cpp
+++ b/src/vkcv/Utils.cpp
@@ -1,12 +1,19 @@
 #include <vkcv/Utils.hpp>
-#include <boost/dll.hpp>
+#include <filesystem>
 
 namespace utils {
-    
+
+    std::string g_binaryDir;
+
     std::string absolutePath(std::string path) {
-        boost::filesystem::path root = boost::dll::program_location().parent_path();
-        boost::filesystem::path relative(path);
-        boost::filesystem::path fullpath = root / relative;
+        std::filesystem::path relative(path);
+        std::filesystem::path fullpath = g_binaryDir / relative;
         return fullpath.string();
     }
+
+    void setBinaryDir(const char* argv0) {
+        std::filesystem::path binaryPath(argv0);
+        std::filesystem::path binaryDir = binaryPath.parent_path();
+        utils::g_binaryDir = binaryDir.string();
+    }
 }
\ No newline at end of file
-- 
GitLab