project(libxiv)
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)
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})
find_package(ZLIB QUIET)
if(TARGET ZLIB::ZLIB)
message("Using system library for zlib")
set(LIBRARIES ZLIB::ZLIB ${LIBRARIES})
message("Using built-in zlib")
zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
FetchContent_MakeAvailable(zlib)
set(LIBRARIES zlib ${LIBRARIES})
add_library(libxiv STATIC
src/fiinparser.cpp
src/indexparser.cpp
src/crc32.cpp
src/gamedata.cpp
src/compression.cpp
src/exhparser.cpp
src/exdparser.cpp
src/installextract.cpp
src/patch.cpp)
target_include_directories(libxiv PUBLIC include PRIVATE src)
target_link_libraries(libxiv PUBLIC
${LIBRARIES})