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:
parent
e9c7223048
commit
29d3a1aabf
5 changed files with 62 additions and 6 deletions
|
@ -1,6 +1,51 @@
|
||||||
project(libxiv)
|
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
|
add_library(libxiv STATIC
|
||||||
src/fiinparser.cpp
|
src/fiinparser.cpp
|
||||||
|
@ -14,6 +59,4 @@ add_library(libxiv STATIC
|
||||||
src/patch.cpp)
|
src/patch.cpp)
|
||||||
target_include_directories(libxiv PUBLIC include PRIVATE src)
|
target_include_directories(libxiv PUBLIC include PRIVATE src)
|
||||||
target_link_libraries(libxiv PUBLIC
|
target_link_libraries(libxiv PUBLIC
|
||||||
unshield
|
${LIBRARIES})
|
||||||
fmt::fmt
|
|
||||||
z)
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <stdexcept>
|
#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) {
|
void zlib::no_header_decompress(uint8_t* in, uint32_t in_size, uint8_t* out, uint32_t out_size) {
|
||||||
z_stream strm = {};
|
z_stream strm = {};
|
||||||
strm.avail_in = in_size;
|
strm.avail_in = in_size;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <unordered_map>
|
||||||
#include <fmt/printf.h>
|
#include <fmt/printf.h>
|
||||||
|
|
||||||
// TODO: should be enum?
|
// TODO: should be enum?
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "installextract.h"
|
#include "installextract.h"
|
||||||
|
|
||||||
|
#ifdef UNSHIELD_SUPPORTED
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <libunshield.h>
|
#include <libunshield.h>
|
||||||
|
@ -135,3 +136,11 @@ void extractBootstrapFiles(const std::string_view installer, const std::string_v
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void extractBootstrapFiles(const std::string_view installer, const std::string_view directory) {
|
||||||
|
// no op
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "compression.h"
|
#include "compression.h"
|
||||||
|
|
Reference in a new issue