From 9dce3ca8dc17617d305bf387d99723a9054c4606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Winzell?= Date: Sun, 14 Apr 2019 11:06:20 -0700 Subject: [PATCH] Bow out of C++17 for now; switch to Boost. --- CMakeLists.txt | 35 ++++++++++------------------------- src/FBX2glTF.h | 4 +++- src/mathfu.hpp | 2 ++ src/utils/File_Utils.cpp | 14 +++++++------- src/utils/File_Utils.hpp | 26 +++++++++++++------------- 5 files changed, 35 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 428ee3f..3bcd493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,14 @@ if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") "Hint: mkdir -p build; cmake -H. -Bbuild; make -Cbuild\n") endif () -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 11) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") include(ExternalProject) +include(${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake) +conan_basic_setup(TARGETS) + # FBX foreach (FBXSDK_VERSION "2019.2") find_package(FBX) @@ -124,22 +127,6 @@ ExternalProject_Add(CPPCodec ) set(CPPCODEC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cppcodec/src/CPPCodec") -# FMT -ExternalProject_Add(Fmt - PREFIX fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG 4.0.0 - CMAKE_CACHE_ARGS "-DFMT_DOC:BOOL=OFF" "-DFMT_INSTALL:BOOL=ON" "-DFMT_TEST:BOOL=OFF" - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX= -) -set(FMT_INCLUDE_DIR "${CMAKE_BINARY_DIR}/fmt/include") -if (WIN32) - set(FMT_LIB "${CMAKE_BINARY_DIR}/fmt/lib/fmt.lib") -else() - set(FMT_LIB "${CMAKE_BINARY_DIR}/fmt/lib/libfmt.a") -endif() - if (APPLE) find_library(CF_FRAMEWORK CoreFoundation) message("CoreFoundation Framework: ${CF_FRAMEWORK}") @@ -218,7 +205,6 @@ add_dependencies(libFBX2glTF MathFu FiFoMap CPPCodec - Fmt ) if (NOT MSVC) @@ -235,8 +221,10 @@ endif() target_link_libraries(libFBX2glTF ${FRAMEWORKS} + CONAN_PKG::boost_filesystem + CONAN_PKG::boost_optional + CONAN_PKG::fmt ${DRACO_LIB} - ${FMT_LIB} optimized ${FBXSDK_LIBRARY} debug ${FBXSDK_LIBRARY_DEBUG} ${CMAKE_DL_LIBS} @@ -260,7 +248,6 @@ else() target_link_libraries(libFBX2glTF ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} - "stdc++fs" ) endif() @@ -268,16 +255,14 @@ target_include_directories(libFBX2glTF SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src "third_party/stb" "third_party/json" -) - -target_include_directories(libFBX2glTF SYSTEM PUBLIC - Iconv::Iconv + CONAN_PKG::boost_filesystem + CONAN_PKG::boost_optional + CONAN_PKG::fmt ${FBXSDK_INCLUDE_DIR} ${DRACO_INCLUDE_DIR} ${MATHFU_INCLUDE_DIRS} ${FIFO_MAP_INCLUDE_DIR} ${CPPCODEC_INCLUDE_DIR} - ${FMT_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ) diff --git a/src/FBX2glTF.h b/src/FBX2glTF.h index 9205651..5a0bb0a 100644 --- a/src/FBX2glTF.h +++ b/src/FBX2glTF.h @@ -20,12 +20,14 @@ #define FBX2GLTF_VERSION std::string("0.9.6") -#include #include +#include + #if defined(_WIN32) // this is defined in fbxmath.h #undef isnan +#undef snprintf #endif #include "mathfu.hpp" diff --git a/src/mathfu.hpp b/src/mathfu.hpp index aaed7dd..2dd8301 100644 --- a/src/mathfu.hpp +++ b/src/mathfu.hpp @@ -9,6 +9,8 @@ #pragma once +#include + #include #include diff --git a/src/utils/File_Utils.cpp b/src/utils/File_Utils.cpp index d4c22ab..4f9885d 100644 --- a/src/utils/File_Utils.cpp +++ b/src/utils/File_Utils.cpp @@ -29,8 +29,8 @@ std::vector ListFolderFiles( if (folder.empty()) { folder = "."; } - for (const auto& entry : std::filesystem::directory_iterator(folder)) { - const auto& suffix = FileUtils::GetFileSuffix(entry.path()); + for (const auto& entry : boost::filesystem::directory_iterator(folder)) { + const auto& suffix = FileUtils::GetFileSuffix(entry.path().string()); if (suffix.has_value()) { const auto& suffix_str = StringUtils::ToLower(suffix.value()); if (matchExtensions.find(suffix_str) != matchExtensions.end()) { @@ -42,15 +42,15 @@ std::vector ListFolderFiles( } bool CreatePath(const std::string path) { - const auto& parent = std::filesystem::path(path).parent_path(); + const auto& parent = boost::filesystem::path(path).parent_path(); if (parent.empty()) { - // this is either CWD or std::filesystem root; either way it exists + // this is either CWD or boost::filesystem root; either way it exists return true; } - if (std::filesystem::exists(parent)) { - return std::filesystem::is_directory(parent); + if (boost::filesystem::exists(parent)) { + return boost::filesystem::is_directory(parent); } - return std::filesystem::create_directory(parent); + return boost::filesystem::create_directory(parent); } bool CopyFile(const std::string& srcFilename, const std::string& dstFilename, bool createPath) { diff --git a/src/utils/File_Utils.hpp b/src/utils/File_Utils.hpp index d418d9a..92827de 100644 --- a/src/utils/File_Utils.hpp +++ b/src/utils/File_Utils.hpp @@ -9,13 +9,13 @@ #pragma once -#include - -#include #include #include #include +#include +#include + namespace FileUtils { std::string GetCurrentFolder(); @@ -35,37 +35,37 @@ bool CopyFile( bool createPath = false); inline std::string GetAbsolutePath(const std::string& filePath) { - return std::filesystem::absolute(filePath).string(); + return boost::filesystem::absolute(filePath).string(); } inline std::string GetCurrentFolder() { - return std::filesystem::current_path().string(); + return boost::filesystem::current_path().string(); } inline bool FileExists(const std::string& filePath) { - return std::filesystem::exists(filePath) && std::filesystem::is_regular_file(filePath); + return boost::filesystem::exists(filePath) && boost::filesystem::is_regular_file(filePath); } inline bool FolderExists(const std::string& folderPath) { - return std::filesystem::exists(folderPath) && std::filesystem::is_directory(folderPath); + return boost::filesystem::exists(folderPath) && boost::filesystem::is_directory(folderPath); } inline std::string getFolder(const std::string& path) { - return std::filesystem::path(path).parent_path().string(); + return boost::filesystem::path(path).parent_path().string(); } inline std::string GetFileName(const std::string& path) { - return std::filesystem::path(path).filename().string(); + return boost::filesystem::path(path).filename().string(); } inline std::string GetFileBase(const std::string& path) { - return std::filesystem::path(path).stem().string(); + return boost::filesystem::path(path).stem().string(); } -inline std::optional GetFileSuffix(const std::string& path) { - const auto& extension = std::filesystem::path(path).extension(); +inline boost::optional GetFileSuffix(const std::string& path) { + const auto& extension = boost::filesystem::path(path).extension(); if (extension.empty()) { - return std::nullopt; + return boost::none; } return extension.string().substr(1); }