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})
|
||||
else()
|
||||
message("Using built-in fmt")
|
||||
message("Using downloaded fmt")
|
||||
|
||||
FetchContent_Declare(
|
||||
fmt
|
||||
|
@ -41,7 +41,7 @@ if(TARGET ZLIB::ZLIB)
|
|||
|
||||
set(LIBRARIES ZLIB::ZLIB ${LIBRARIES})
|
||||
else()
|
||||
message("Using built-in zlib")
|
||||
message("Using downloaded zlib")
|
||||
|
||||
FetchContent_Declare(
|
||||
zlib
|
||||
|
@ -61,7 +61,21 @@ else()
|
|||
set(LIBRARIES zlibstatic ${LIBRARIES})
|
||||
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
|
||||
src/fiinparser.cpp
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#include "exlparser.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <fstream>
|
||||
|
||||
EXL readEXL(std::string_view path) {
|
||||
FILE* file = fopen(path.data(), "rb");
|
||||
if(!file) {
|
||||
std::fstream 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()));
|
||||
}
|
||||
|
||||
EXL exl;
|
||||
|
||||
char* data = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
while ((getline(&data, &len, file)) != -1) {
|
||||
std::string line = data;
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
const size_t comma = line.find_first_of(',');
|
||||
|
||||
std::string name = line.substr(0, comma);
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
using ushort = unsigned short;
|
||||
using uint = unsigned int;
|
||||
|
||||
// from lumina.halfextensions
|
||||
static float Unpack(ushort value) {
|
||||
uint num3;
|
||||
|
|
Reference in a new issue