Fix compilation on MSVC
Pugixml is now downloaded if not found, and the CMake messages are now clearer that the dependency is downloaded from the internet. The POSIX getline function is now replaced with std::getline, which works on MSVC.
This commit is contained in:
parent
ba13bab4b7
commit
79c482ac97
3 changed files with 28 additions and 11 deletions
|
@ -9,7 +9,7 @@ if(TARGET fmt::fmt)
|
||||||
|
|
||||||
set(LIBRARIES fmt::fmt ${LIBRARIES})
|
set(LIBRARIES fmt::fmt ${LIBRARIES})
|
||||||
else()
|
else()
|
||||||
message("Using built-in fmt")
|
message("Using downloaded fmt")
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
fmt
|
fmt
|
||||||
|
@ -41,7 +41,7 @@ if(TARGET ZLIB::ZLIB)
|
||||||
|
|
||||||
set(LIBRARIES ZLIB::ZLIB ${LIBRARIES})
|
set(LIBRARIES ZLIB::ZLIB ${LIBRARIES})
|
||||||
else()
|
else()
|
||||||
message("Using built-in zlib")
|
message("Using downloaded zlib")
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
zlib
|
zlib
|
||||||
|
@ -61,7 +61,21 @@ else()
|
||||||
set(LIBRARIES zlibstatic ${LIBRARIES})
|
set(LIBRARIES zlibstatic ${LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(pugixml REQUIRED)
|
find_package(pugixml QUIET)
|
||||||
|
|
||||||
|
if(TARGET pugixml::pugixml)
|
||||||
|
message("Using system library for zlib")
|
||||||
|
else()
|
||||||
|
message("Using downloaded pugixml")
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
pugixml
|
||||||
|
GIT_REPOSITORY https://github.com/zeux/pugixml.git
|
||||||
|
GIT_TAG master
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(pugixml)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(libxiv STATIC
|
add_library(libxiv STATIC
|
||||||
src/fiinparser.cpp
|
src/fiinparser.cpp
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
#include "exlparser.h"
|
#include "exlparser.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
EXL readEXL(std::string_view path) {
|
EXL readEXL(std::string_view path) {
|
||||||
FILE* file = fopen(path.data(), "rb");
|
std::fstream file;
|
||||||
if(!file) {
|
file.open(path.data(), std::iostream::in);
|
||||||
|
|
||||||
|
if(!file.is_open()) {
|
||||||
throw std::runtime_error("Failed to read exl file from " + std::string(path.data()));
|
throw std::runtime_error("Failed to read exl file from " + std::string(path.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXL exl;
|
EXL exl;
|
||||||
|
|
||||||
char* data = nullptr;
|
std::string line;
|
||||||
size_t len = 0;
|
while (std::getline(file, line)) {
|
||||||
|
|
||||||
while ((getline(&data, &len, file)) != -1) {
|
|
||||||
std::string line = data;
|
|
||||||
|
|
||||||
const size_t comma = line.find_first_of(',');
|
const size_t comma = line.find_first_of(',');
|
||||||
|
|
||||||
std::string name = line.substr(0, comma);
|
std::string name = line.substr(0, comma);
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
using ushort = unsigned short;
|
||||||
|
using uint = unsigned int;
|
||||||
|
|
||||||
// from lumina.halfextensions
|
// from lumina.halfextensions
|
||||||
static float Unpack(ushort value) {
|
static float Unpack(ushort value) {
|
||||||
uint num3;
|
uint num3;
|
||||||
|
|
Reference in a new issue