From: Pavel Rojtberg Date: Sat, 21 Jul 2018 13:48:23 +0000 (+0200) Subject: add basic CMake based build X-Git-Tag: v0.13.72~129^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3ef285eb923793af06bb179c1d5cc1c235da0b7;p=zziplib add basic CMake based build --- diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3b2b29d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,104 @@ +cmake_minimum_required (VERSION 3.1) +project(zziplib C) + +# generate _config.h +include ( CheckIncludeFiles ) +include ( CheckFunctionExists ) +include ( CheckSymbolExists ) +include ( CheckTypeSize ) +include ( TestBigEndian ) + +check_include_files ( byteswap.h ZZIP_HAVE_BYTESWAP_H ) +check_include_files ( direct.h ZZIP_HAVE_DIRECT_H ) + +if(NOT ANDROID) + check_include_files ( dirent.h ZZIP_HAVE_DIRENT_H ) +endif() + +check_include_files ( dlfcn.h ZZIP_HAVE_DLFCN_H ) +check_include_files ( fnmatch.h ZZIP_HAVE_FNMATCH_H ) +check_include_files ( inttypes.h ZZIP_HAVE_INTTYPES_H ) +check_include_files ( io.h ZZIP_HAVE_IO_H ) +check_include_files ( memory.h ZZIP_HAVE_MEMORY_H ) +check_include_files ( ndir.h ZZIP_HAVE_NDIR_H ) +check_include_files ( stdint.h ZZIP_HAVE_STDINT_H ) +check_include_files ( stdlib.h ZZIP_HAVE_STDLIB_H ) +check_function_exists ( strcasecmp ZZIP_HAVE_STRCASECMP ) +check_include_files ( strings.h ZZIP_HAVE_STRINGS_H ) +check_include_files ( string.h ZZIP_HAVE_STRING_H ) +check_function_exists ( strndup ZZIP_HAVE_STRNDUP ) +check_include_files ( "sys/dir.h" ZZIP_HAVE_SYS_DIR_H ) +check_include_files ( "sys/int_types.h" ZZIP_HAVE_SYS_INT_TYPES_H ) +check_include_files ( "sys/mman.h" ZZIP_HAVE_SYS_MMAN_H ) +check_include_files ( "sys/ndir.h" ZZIP_HAVE_SYS_NDIR_H ) +check_include_files ( "sys/param.h" ZZIP_HAVE_SYS_PARAM_H ) +check_include_files ( "sys/stat.h" ZZIP_HAVE_SYS_STAT_H ) +check_include_files ( "sys/types.h" ZZIP_HAVE_SYS_TYPES_H ) +check_include_files ( unistd.h ZZIP_HAVE_UNISTD_H ) +check_include_files ( winbase.h ZZIP_HAVE_WINBASE_H ) +check_include_files ( windows.h ZZIP_HAVE_WINDOWS_H ) +check_include_files ( winnt.h ZZIP_HAVE_WINNT_H ) +set ( ZZIP_HAVE_ZLIB_H 1 ) + +check_type_size ( int ZZIP_SIZEOF_INT ) +check_type_size ( long ZZIP_SIZEOF_LONG ) +check_type_size ( short ZZIP_SIZEOF_SHORT ) +check_include_files ( "stdlib.h;stdarg.h;string.h;float.h" ZZIP_STDC_HEADERS ) +test_big_endian ( ZZIP_WORDS_BIGENDIAN ) + +configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/zzip/_config.h ) + +# Zlib library needed +find_package ( ZLIB REQUIRED ) + +if(UNIX) + add_definitions( + -Wpointer-arith + -Wsign-compare + -Wmissing-declarations + -Wdeclaration-after-statement + -Werror-implicit-function-declaration + -Wstrict-aliasing + -Warray-bounds + ) +endif() + +# libzlib library +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +add_definitions ( -DHAVE_CONFIG_H ) +include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +set(ZZIPLIB_SRCS + zzip/dir.c + zzip/err.c + zzip/file.c + zzip/info.c + zzip/plugin.c + zzip/stat.c + zzip/write.c + zzip/zip.c + zzip/fetch.c) + +set(ZZIPLIB_HDRS + zzip/zzip.h + zzip/types.h + zzip/conf.h + zzip/_msvc.h + zzip/plugin.h + zzip/fetch.h + ${CMAKE_CURRENT_BINARY_DIR}/zzip/_config.h) +add_library(zzip ${ZZIPLIB_SRCS} ) +target_link_libraries(zzip ZLIB::ZLIB ) + +if(NOT MSVC) # FIXME: syntax error + add_library(zzipmmapped zzip/mmapped.c zzip/memdisk.c zzip/fetch.c ) + target_link_libraries(zzipmmapped ZLIB::ZLIB ) +endif() + +add_library(zzipfseeko zzip/fseeko.c zzip/fetch.c ) +target_link_libraries(zzipfseeko ZLIB::ZLIB ) + +# install +install(FILES ${ZZIPLIB_HDRS} DESTINATION include/zzip ) +install(TARGETS zzip + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) diff --git a/_config.h.cmake b/_config.h.cmake new file mode 100644 index 0000000..b48b39a --- /dev/null +++ b/_config.h.cmake @@ -0,0 +1,165 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if pointers to integers require aligned access */ +#cmakedefine ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED ${ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_BYTESWAP_H ${ZZIP_HAVE_BYTESWAP_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_DIRECT_H ${ZZIP_HAVE_DIRECT_H} + +/* Define to 1 if you have the header file, and it defines `DIR'.*/ +#cmakedefine ZZIP_HAVE_DIRENT_H ${ZZIP_HAVE_DIRENT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_DLFCN_H ${ZZIP_HAVE_DLFCN_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_FNMATCH_H ${ZZIP_HAVE_FNMATCH_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_INTTYPES_H ${ZZIP_HAVE_INTTYPES_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_IO_H ${ZZIP_HAVE_IO_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_MEMORY_H ${ZZIP_HAVE_MEMORY_H} + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#cmakedefine ZZIP_HAVE_NDIR_H ${ZZIP_HAVE_NDIR_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_STDINT_H ${ZZIP_HAVE_STDINT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_STDLIB_H ${ZZIP_HAVE_STDLIB_H} + +/* Define to 1 if you have the `strcasecmp' function. */ +#cmakedefine ZZIP_HAVE_STRCASECMP ${ZZIP_HAVE_STRCASECMP} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_STRINGS_H ${ZZIP_HAVE_STRINGS_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_STRING_H ${ZZIP_HAVE_STRING_H} + +/* Define to 1 if you have the `strndup' function. */ +#cmakedefine ZZIP_HAVE_STRNDUP ${ZZIP_HAVE_STRNDUP} + +/* Define to 1 if you have the header file, and it defines `DIR'.*/ +#cmakedefine ZZIP_HAVE_SYS_DIR_H ${ZZIP_HAVE_SYS_DIR_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_SYS_INT_TYPES_H ${ZZIP_HAVE_SYS_INT_TYPES_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_SYS_MMAN_H ${ZZIP_HAVE_SYS_MMAN_H} + +/* Define to 1 if you have the header file, and it defines `DIR'.*/ +#cmakedefine ZZIP_HAVE_SYS_NDIR_H ${ZZIP_HAVE_SYS_NDIR_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_SYS_PARAM_H ${ZZIP_HAVE_SYS_PARAM_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_SYS_STAT_H ${ZZIP_HAVE_SYS_STAT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_SYS_TYPES_H ${ZZIP_HAVE_SYS_TYPES_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_UNISTD_H ${ZZIP_HAVE_UNISTD_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_WINBASE_H ${ZZIP_HAVE_WINBASE_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_WINDOWS_H ${ZZIP_HAVE_WINDOWS_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_WINNT_H ${ZZIP_HAVE_WINNT_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine ZZIP_HAVE_ZLIB_H ${ZZIP_HAVE_ZLIB_H} + +/* whether the system defaults to 32bit off_t but can do 64bit when requested */ +#cmakedefine ZZIP_LARGEFILE_SENSITIVE ${ZZIP_LARGEFILE_SENSITIVE} + +/* Name of package */ +#cmakedefine ZZIP_PACKAGE "${ZZIP_PACKAGE}" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine ZZIP_PACKAGE_BUGREPORT "${ZZIP_PACKAGE_BUGREPORT}" + +/* Define to the full name of this package. */ +#cmakedefine ZZIP_PACKAGE_NAME "${ZZIP_PACKAGE_NAME}" + +/* Define to the full name and version of this package. */ +#cmakedefine ZZIP_PACKAGE_STRING "${ZZIP_PACKAGE_STRING}" + +/* Define to the one symbol short name of this package. */ +#cmakedefine ZZIP_PACKAGE_TARNAME "${ZZIP_PACKAGE_TARNAME}" + +/* Define to the version of this package. */ +#cmakedefine ZZIP_PACKAGE_VERSION "${ZZIP_PACKAGE_VERSION}" + +/* The number of bytes in type int */ +#cmakedefine ZZIP_SIZEOF_INT ${ZZIP_SIZEOF_INT} + +/* The number of bytes in type long */ +#cmakedefine ZZIP_SIZEOF_LONG ${ZZIP_SIZEOF_LONG} + +/* The number of bytes in type short */ +#cmakedefine ZZIP_SIZEOF_SHORT ${ZZIP_SIZEOF_SHORT} + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine ZZIP_STDC_HEADERS ${ZZIP_STDC_HEADERS} + +/* Version number of package */ +#cmakedefine ZZIP_VERSION ${ZZIP_VERSION} + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#cmakedefine ZZIP_WORDS_BIGENDIAN ${ZZIP_WORDS_BIGENDIAN} + +/* Number of bits in a file offset, on hosts where this is settable. */ +#cmakedefine _FILE_OFFSET_BITS ${_FILE_OFFSET_BITS} + +/* Define for large files, on AIX-style hosts. */ +#cmakedefine _LARGE_FILES ${_LARGE_FILES} + +/* Define to `long long' if does not define. */ +#cmakedefine __int64 ${__INT64} + +/* Define to empty if `const' does not conform to ANSI C. */ +#cmakedefine const ${const} + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#ifndef _zzip_inline +#define _zzip_inline __inline +#endif +#endif + + +/* Define to `_zzip_off_t' if does not define. */ +#define _zzip_off64_t _zzip_off_t + +/* Define to `long int' if does not define. */ +#cmakedefine _zzip_off_t ${OFF_T} + +/* Define to equivalent of C99 restrict keyword, or to nothing if this is not + supported. Do not define if restrict is supported directly. */ +#ifndef _zzip_restrict +#define _zzip_restrict +#endif + + +/* Define to `unsigned int' if does not define. */ +#cmakedefine _zzip_size_t ${SIZE_T} + +/* Define to `int' if does not define. */ +#cmakedefine _zzip_ssize_t ${SSIZE_T}