Bow out of C++17 for now; switch to Boost.

This commit is contained in:
Pär Winzell 2019-04-14 11:06:20 -07:00
parent d040ccec32
commit 9dce3ca8dc
5 changed files with 35 additions and 46 deletions

View File

@ -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=<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)
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}
)

View File

@ -20,12 +20,14 @@
#define FBX2GLTF_VERSION std::string("0.9.6")
#include <fbxsdk.h>
#include <fmt/printf.h>
#include <fbxsdk.h>
#if defined(_WIN32)
// this is defined in fbxmath.h
#undef isnan
#undef snprintf
#endif
#include "mathfu.hpp"

View File

@ -9,6 +9,8 @@
#pragma once
#include <vector>
#include <fbxsdk.h>
#include <mathfu/matrix.h>

View File

@ -29,8 +29,8 @@ std::vector<std::string> 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<std::string> 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) {

View File

@ -9,13 +9,13 @@
#pragma once
#include <filesystem>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
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<std::string> GetFileSuffix(const std::string& path) {
const auto& extension = std::filesystem::path(path).extension();
inline boost::optional<std::string> 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);
}