2016-10-21 20:45:44 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
project(zziplib C)
|
|
|
|
|
|
|
|
find_package(zlib)
|
|
|
|
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
if(MSVC)
|
2019-04-30 23:54:33 +00:00
|
|
|
set(CMAKE_DEBUG_POSTFIX "d")
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX)
|
2019-05-02 23:06:44 +00:00
|
|
|
# Find autotools output
|
|
|
|
set(ZZLIB_AUTOOLS_INCLUDE_DIRS)
|
|
|
|
file(GLOB CHILDREN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
|
|
|
foreach(CHILD ${CHILDREN})
|
|
|
|
string(REGEX MATCH "x86_64*" ZZLIB_AUTOOLS_OUTPUT_FOLDER "${CHILD}")
|
|
|
|
if (ZZLIB_AUTOOLS_OUTPUT_FOLDER)
|
|
|
|
set(ZZLIB_AUTOOLS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${CHILD})
|
|
|
|
include_directories(${ZZLIB_AUTOOLS_INCLUDE_DIRS})
|
|
|
|
include_directories(${ZZLIB_AUTOOLS_INCLUDE_DIRS}/zzip)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-10-21 20:45:44 +00:00
|
|
|
endif()
|
|
|
|
|
2019-05-17 20:08:11 +00:00
|
|
|
configure_file("${CMAKE_CURRENT_LIST_DIR}/config.h.in" "${CMAKE_CURRENT_LIST_DIR}/zzip/config.h")
|
2016-10-21 20:45:44 +00:00
|
|
|
# List the header files
|
|
|
|
set(HEADERS zzip/__debug.h
|
|
|
|
zzip/__dirent.h
|
|
|
|
zzip/__fnmatch.h
|
|
|
|
zzip/__hints.h
|
|
|
|
zzip/__mmap.h
|
2019-05-17 20:08:11 +00:00
|
|
|
zzip/config.h
|
2016-10-21 20:45:44 +00:00
|
|
|
zzip/_msvc.h
|
|
|
|
zzip/autoconf.h
|
|
|
|
zzip/conf.h
|
|
|
|
zzip/fetch.h
|
|
|
|
zzip/file.h
|
|
|
|
zzip/format.h
|
|
|
|
zzip/fseeko.h
|
|
|
|
zzip/info.h
|
|
|
|
zzip/lib.h
|
|
|
|
zzip/memdisk.h
|
|
|
|
zzip/mmapped.h
|
|
|
|
zzip/plugin.h
|
|
|
|
zzip/stdint.h
|
|
|
|
zzip/types.h
|
|
|
|
zzip/write.h
|
|
|
|
zzip/zzip.h
|
|
|
|
)
|
2019-04-30 23:54:33 +00:00
|
|
|
if(UNIX)
|
2019-05-02 23:06:44 +00:00
|
|
|
file(GLOB OTHER_HEADERS ${ZZLIB_AUTOOLS_INCLUDE_DIRS}/zzip/*.h)
|
2019-04-30 23:54:33 +00:00
|
|
|
list(APPEND HEADERS ${OTHER_HEADERS})
|
|
|
|
else()
|
|
|
|
list(APPEND HEADERS zzip/_msvc.h)
|
|
|
|
endif()
|
2016-10-21 20:45:44 +00:00
|
|
|
|
|
|
|
# List the source files
|
|
|
|
set(SRCS zzip/dir.c
|
|
|
|
zzip/err.c
|
|
|
|
zzip/fetch.c
|
|
|
|
zzip/file.c
|
|
|
|
zzip/info.c
|
|
|
|
zzip/plugin.c
|
|
|
|
zzip/stat.c
|
|
|
|
zzip/zip.c
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(zziplib ${SRCS} ${HEADERS})
|
|
|
|
|
2017-10-12 14:52:48 +00:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2019-04-30 23:54:33 +00:00
|
|
|
target_compile_definitions(zziplib PRIVATE -DZZIPLIB_EXPORTS)
|
2016-10-21 20:45:44 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(zziplib ${ZLIB_LIBRARIES})
|
|
|
|
|
|
|
|
install(TARGETS zziplib
|
|
|
|
COMPONENT runtime
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)
|
|
|
|
|
2019-04-30 23:54:33 +00:00
|
|
|
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/zzip)
|