Bow out of C++17 for now; switch to Boost.
This commit is contained in:
parent
d040ccec32
commit
9dce3ca8dc
|
@ -7,11 +7,14 @@ if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||||
"Hint: mkdir -p build; cmake -H. -Bbuild; make -Cbuild\n")
|
"Hint: mkdir -p build; cmake -H. -Bbuild; make -Cbuild\n")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake)
|
||||||
|
conan_basic_setup(TARGETS)
|
||||||
|
|
||||||
# FBX
|
# FBX
|
||||||
foreach (FBXSDK_VERSION "2019.2")
|
foreach (FBXSDK_VERSION "2019.2")
|
||||||
find_package(FBX)
|
find_package(FBX)
|
||||||
|
@ -124,22 +127,6 @@ ExternalProject_Add(CPPCodec
|
||||||
)
|
)
|
||||||
set(CPPCODEC_INCLUDE_DIR "${CMAKE_BINARY_DIR}/cppcodec/src/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=<INSTALL_DIR>
|
|
||||||
)
|
|
||||||
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)
|
if (APPLE)
|
||||||
find_library(CF_FRAMEWORK CoreFoundation)
|
find_library(CF_FRAMEWORK CoreFoundation)
|
||||||
message("CoreFoundation Framework: ${CF_FRAMEWORK}")
|
message("CoreFoundation Framework: ${CF_FRAMEWORK}")
|
||||||
|
@ -218,7 +205,6 @@ add_dependencies(libFBX2glTF
|
||||||
MathFu
|
MathFu
|
||||||
FiFoMap
|
FiFoMap
|
||||||
CPPCodec
|
CPPCodec
|
||||||
Fmt
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
|
@ -235,8 +221,10 @@ endif()
|
||||||
|
|
||||||
target_link_libraries(libFBX2glTF
|
target_link_libraries(libFBX2glTF
|
||||||
${FRAMEWORKS}
|
${FRAMEWORKS}
|
||||||
|
CONAN_PKG::boost_filesystem
|
||||||
|
CONAN_PKG::boost_optional
|
||||||
|
CONAN_PKG::fmt
|
||||||
${DRACO_LIB}
|
${DRACO_LIB}
|
||||||
${FMT_LIB}
|
|
||||||
optimized ${FBXSDK_LIBRARY}
|
optimized ${FBXSDK_LIBRARY}
|
||||||
debug ${FBXSDK_LIBRARY_DEBUG}
|
debug ${FBXSDK_LIBRARY_DEBUG}
|
||||||
${CMAKE_DL_LIBS}
|
${CMAKE_DL_LIBS}
|
||||||
|
@ -260,7 +248,6 @@ else()
|
||||||
target_link_libraries(libFBX2glTF
|
target_link_libraries(libFBX2glTF
|
||||||
${LIBXML2_LIBRARIES}
|
${LIBXML2_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
"stdc++fs"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -268,16 +255,14 @@ target_include_directories(libFBX2glTF SYSTEM PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
"third_party/stb"
|
"third_party/stb"
|
||||||
"third_party/json"
|
"third_party/json"
|
||||||
)
|
CONAN_PKG::boost_filesystem
|
||||||
|
CONAN_PKG::boost_optional
|
||||||
target_include_directories(libFBX2glTF SYSTEM PUBLIC
|
CONAN_PKG::fmt
|
||||||
Iconv::Iconv
|
|
||||||
${FBXSDK_INCLUDE_DIR}
|
${FBXSDK_INCLUDE_DIR}
|
||||||
${DRACO_INCLUDE_DIR}
|
${DRACO_INCLUDE_DIR}
|
||||||
${MATHFU_INCLUDE_DIRS}
|
${MATHFU_INCLUDE_DIRS}
|
||||||
${FIFO_MAP_INCLUDE_DIR}
|
${FIFO_MAP_INCLUDE_DIR}
|
||||||
${CPPCODEC_INCLUDE_DIR}
|
${CPPCODEC_INCLUDE_DIR}
|
||||||
${FMT_INCLUDE_DIR}
|
|
||||||
${LIBXML2_INCLUDE_DIR}
|
${LIBXML2_INCLUDE_DIR}
|
||||||
${ZLIB_INCLUDE_DIRS}
|
${ZLIB_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,12 +20,14 @@
|
||||||
|
|
||||||
#define FBX2GLTF_VERSION std::string("0.9.6")
|
#define FBX2GLTF_VERSION std::string("0.9.6")
|
||||||
|
|
||||||
#include <fbxsdk.h>
|
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
|
|
||||||
|
#include <fbxsdk.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// this is defined in fbxmath.h
|
// this is defined in fbxmath.h
|
||||||
#undef isnan
|
#undef isnan
|
||||||
|
#undef snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mathfu.hpp"
|
#include "mathfu.hpp"
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <fbxsdk.h>
|
#include <fbxsdk.h>
|
||||||
|
|
||||||
#include <mathfu/matrix.h>
|
#include <mathfu/matrix.h>
|
||||||
|
|
|
@ -29,8 +29,8 @@ std::vector<std::string> ListFolderFiles(
|
||||||
if (folder.empty()) {
|
if (folder.empty()) {
|
||||||
folder = ".";
|
folder = ".";
|
||||||
}
|
}
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(folder)) {
|
for (const auto& entry : boost::filesystem::directory_iterator(folder)) {
|
||||||
const auto& suffix = FileUtils::GetFileSuffix(entry.path());
|
const auto& suffix = FileUtils::GetFileSuffix(entry.path().string());
|
||||||
if (suffix.has_value()) {
|
if (suffix.has_value()) {
|
||||||
const auto& suffix_str = StringUtils::ToLower(suffix.value());
|
const auto& suffix_str = StringUtils::ToLower(suffix.value());
|
||||||
if (matchExtensions.find(suffix_str) != matchExtensions.end()) {
|
if (matchExtensions.find(suffix_str) != matchExtensions.end()) {
|
||||||
|
@ -42,15 +42,15 @@ std::vector<std::string> ListFolderFiles(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreatePath(const std::string path) {
|
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()) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (std::filesystem::exists(parent)) {
|
if (boost::filesystem::exists(parent)) {
|
||||||
return std::filesystem::is_directory(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) {
|
bool CopyFile(const std::string& srcFilename, const std::string& dstFilename, bool createPath) {
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
namespace FileUtils {
|
namespace FileUtils {
|
||||||
|
|
||||||
std::string GetCurrentFolder();
|
std::string GetCurrentFolder();
|
||||||
|
@ -35,37 +35,37 @@ bool CopyFile(
|
||||||
bool createPath = false);
|
bool createPath = false);
|
||||||
|
|
||||||
inline std::string GetAbsolutePath(const std::string& filePath) {
|
inline std::string GetAbsolutePath(const std::string& filePath) {
|
||||||
return std::filesystem::absolute(filePath).string();
|
return boost::filesystem::absolute(filePath).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string GetCurrentFolder() {
|
inline std::string GetCurrentFolder() {
|
||||||
return std::filesystem::current_path().string();
|
return boost::filesystem::current_path().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool FileExists(const std::string& filePath) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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<std::string> GetFileSuffix(const std::string& path) {
|
inline boost::optional<std::string> GetFileSuffix(const std::string& path) {
|
||||||
const auto& extension = std::filesystem::path(path).extension();
|
const auto& extension = boost::filesystem::path(path).extension();
|
||||||
if (extension.empty()) {
|
if (extension.empty()) {
|
||||||
return std::nullopt;
|
return boost::none;
|
||||||
}
|
}
|
||||||
return extension.string().substr(1);
|
return extension.string().substr(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue