Archived
1
Fork 0

Improve Windows support

Will now compile out of the box on Windows MSVC.
Right now, out of the box game installation is not supported
as per unshield being non-functional on Windows, will be porting
to Windows or finding a workaround in the near future.
This commit is contained in:
Joshua Goins 2022-03-27 21:06:14 -04:00
parent e9c7223048
commit 29d3a1aabf
5 changed files with 62 additions and 6 deletions

View file

@ -1,6 +1,51 @@
project(libxiv)
find_package(fmt)
find_package(fmt QUIET)
if(TARGET fmt::fmt)
message("Using system library for fmt")
set(LIBRARIES fmt::fmt ${LIBRARIES})
else()
message("Using built-in fmt")
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG master
)
FetchContent_MakeAvailable(fmt)
set(LIBRARIES fmt::fmt ${LIBRARIES})
endif()
# note: unshield does not work on windows per maintainer notice in README, so we might as well not even attempt to look
# for it.
if(NOT WIN32)
set(LIBRARIES unshield ${LIBRARIES})
endif()
find_package(ZLIB QUIET)
if(TARGET ZLIB::ZLIB)
message("Using system library for zlib")
set(LIBRARIES ZLIB::ZLIB ${LIBRARIES})
else()
message("Using built-in zlib")
FetchContent_Declare(
zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG master
)
FetchContent_MakeAvailable(zlib)
set(LIBRARIES zlib ${LIBRARIES})
endif()
add_library(libxiv STATIC
src/fiinparser.cpp
@ -14,6 +59,4 @@ add_library(libxiv STATIC
src/patch.cpp)
target_include_directories(libxiv PUBLIC include PRIVATE src)
target_link_libraries(libxiv PUBLIC
unshield
fmt::fmt
z)
${LIBRARIES})

View file

@ -2,8 +2,10 @@
#include <zlib.h>
#include <stdexcept>
#include <string>
// adopted from https://github.com/ahom/ffxiv_reverse/blob/312a0af8b58929fab48438aceae8da587be9407f/xiv/utils/src/zlib.cpp#L31
// adopted from
// https://github.com/ahom/ffxiv_reverse/blob/312a0af8b58929fab48438aceae8da587be9407f/xiv/utils/src/zlib.cpp#L31
void zlib::no_header_decompress(uint8_t* in, uint32_t in_size, uint8_t* out, uint32_t out_size) {
z_stream strm = {};
strm.avail_in = in_size;

View file

@ -6,6 +6,7 @@
#include <string>
#include <algorithm>
#include <unordered_map>
#include <fmt/printf.h>
// TODO: should be enum?

View file

@ -1,5 +1,6 @@
#include "installextract.h"
#ifdef UNSHIELD_SUPPORTED
#include <cstdio>
#include <stdexcept>
#include <libunshield.h>
@ -134,4 +135,12 @@ void extractBootstrapFiles(const std::string_view installer, const std::string_v
}
fclose(file);
}
}
#else
void extractBootstrapFiles(const std::string_view installer, const std::string_view directory) {
// no op
}
#endif

View file

@ -3,6 +3,7 @@
#include <stdexcept>
#include <cstdio>
#include <fmt/core.h>
#include <vector>
#include "utility.h"
#include "compression.h"