2023-02-26 10:53:39 +01:00
|
|
|
cmake_minimum_required (VERSION 3.0)
|
|
|
|
|
|
|
|
project (fstlib VERSION 1.0.0)
|
|
|
|
|
|
|
|
set(BUILD_SHARED_LIBS ON)
|
2023-02-27 18:34:27 +01:00
|
|
|
#find_package(ZLIB REQUIRED)
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
zlib
|
|
|
|
URL https://www.zlib.net/zlib-1.2.13.tar.gz
|
|
|
|
https://www.zlib.net/fossils/zlib-1.2.13.tar.gz
|
|
|
|
https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz
|
|
|
|
URL_HASH MD5=9b8aa094c4e5765dabf4da391f00d15c
|
|
|
|
)
|
|
|
|
FetchContent_Populate(zlib)
|
|
|
|
add_subdirectory(${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
|
|
add_library(ZLIB::ZLIB ALIAS zlibstatic)
|
|
|
|
target_include_directories(zlibstatic INTERFACE ${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
|
2023-02-26 10:53:39 +01:00
|
|
|
|
2023-02-27 18:34:27 +01:00
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
2023-02-27 13:09:38 +01:00
|
|
|
add_library(fstapi fstapi.c lz4.c fastlz.c fst_helper.c)
|
2023-02-27 18:34:27 +01:00
|
|
|
#target_include_directories(fstapi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(fstapi PRIVATE zlibstatic)
|
2023-02-26 10:53:39 +01:00
|
|
|
# hack to avoid creating dummy config.h
|
|
|
|
target_compile_definitions(fstapi PRIVATE -DFST_CONFIG_INCLUDE="fstapi.h")
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
# define __MINGW32__ to minimize changes to upstream
|
|
|
|
target_compile_definitions(fstapi PRIVATE __MINGW32__ _CRT_SECURE_NO_WARNINGS FST_DO_MISALIGNED_OPS)
|
|
|
|
target_compile_options(fstapi PRIVATE /wd4244 /wd4267 /wd4146 /wd4996)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(TARGETS fstapi
|
2023-02-27 18:34:27 +01:00
|
|
|
LIBRARY DESTINATION .
|
|
|
|
RUNTIME DESTINATION .)
|