option(ZZIPFSEEKO "Build libzzipfseeko (based on posix.1 api)" ON)
option(ZZIPWRAP "Build libzzipwrap (non-installed example)" ON)
option(ZZIPSDL "Build zzcatsdl (includable example code)" ON)
+option(ZZIPBINS "Build bins/unzzip (unzip-like executables)" ON)
check_include_files ( byteswap.h ZZIP_HAVE_BYTESWAP_H )
check_include_files ( direct.h ZZIP_HAVE_DIRECT_H )
zzip/fetch.h
${CMAKE_CURRENT_BINARY_DIR}/zzip/_config.h)
-add_library(zzip ${ZZIPLIB_SRCS} )
-target_link_libraries(zzip ZLIB::ZLIB )
-target_include_directories (zzip PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+add_library(libzzip ${ZZIPLIB_SRCS} )
+target_link_libraries(libzzip ZLIB::ZLIB )
+target_include_directories (libzzip PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if(ZZIPFSEEKO)
-add_library(zzipfseeko zzip/fseeko.c zzip/fetch.c )
-target_link_libraries(zzipfseeko ZLIB::ZLIB )
-target_include_directories (zzipfseeko PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+add_library(libzzipfseeko zzip/fseeko.c zzip/fetch.c )
+target_link_libraries(libzzipfseeko ZLIB::ZLIB )
+target_include_directories (libzzipfseeko PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(ZZIPMMAPPED)
-add_library(zzipmmapped zzip/mmapped.c zzip/memdisk.c zzip/fetch.c )
-target_link_libraries(zzipmmapped ZLIB::ZLIB )
-target_include_directories (zzipmmapped PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+add_library(libzzipmmapped zzip/mmapped.c zzip/memdisk.c zzip/fetch.c )
+target_link_libraries(libzzipmmapped ZLIB::ZLIB )
+target_include_directories (libzzipmmapped PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
endif()
-set_target_properties(zzip PROPERTIES OUTPUT_NAME "zzip-${RELNUM}")
-SET_TARGET_PROPERTIES(zzip PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
+set_target_properties(libzzip PROPERTIES OUTPUT_NAME "zzip-${RELNUM}")
+SET_TARGET_PROPERTIES(libzzip PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
if(ZZIPFSEEKO)
-set_target_properties(zzipfseeko PROPERTIES OUTPUT_NAME "zzipfseeko-${RELNUM}")
-SET_TARGET_PROPERTIES(zzipfseeko PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
+set_target_properties(libzzipfseeko PROPERTIES OUTPUT_NAME "zzipfseeko-${RELNUM}")
+SET_TARGET_PROPERTIES(libzzipfseeko PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
endif()
if(ZZIPMMAPPED)
-set_target_properties(zzipmmapped PROPERTIES OUTPUT_NAME "zzipmmapped-${RELNUM}")
-SET_TARGET_PROPERTIES(zzipmmapped PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
+set_target_properties(libzzipmmapped PROPERTIES OUTPUT_NAME "zzipmmapped-${RELNUM}")
+SET_TARGET_PROPERTIES(libzzipmmapped PROPERTIES VERSION ${VERNUM}.${FIXNUM} SOVERSION ${VERNUM})
endif()
if(ZZIPWRAP)
if(ZZIPSDL)
add_subdirectory(SDL)
endif()
+if(ZZIPBINS)
+add_subdirectory(bins)
+endif()
# install ########################################################
install(FILES ${ZZIPLIB_HDRS} DESTINATION include/zzip )
-install(TARGETS zzip
+install(TARGETS libzzip
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(ZZIPFSEEKO)
-install(TARGETS zzipfseeko
+install(TARGETS libzzipfseeko
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(ZZIPMMAPPED)
-install(TARGETS zzipmmapped
+install(TARGETS libzzipmmapped
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)
- get_target_property(libname zzip OUTPUT_NAME)
- get_target_property(libversion zzip VERSION)
+ get_target_property(libname libzzip OUTPUT_NAME)
+ get_target_property(libversion libzzip VERSION)
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX})
set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX})
if(${libversion} MATCHES "^[0-9].*")
# use the uninstalled zzip here (don't know to to tell pkg_search_module)
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX})
set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX})
-get_target_property(libname zzip OUTPUT_NAME)
+get_target_property(libname libzzip OUTPUT_NAME)
set(ZZIP_INCLUDE_DIR ${CMAKE_SOURCE_DIR})
set(ZZIP_LIBRARY ${CMAKE_BINARY_DIR}/${lib}${libname}${dll})
--- /dev/null
+cmake_minimum_required (VERSION 3.1)
+project(zzipbins C)
+set(VERSION "0.13.69")
+
+string(REGEX REPLACE "([^.]+)[.]([^.]+)[.]([^.]+)" "\\1" RELNUM ${VERSION})
+string(REGEX REPLACE "([^.]+)[.]([^.]+)[.]([^.]+)" "\\2" VERNUM ${VERSION})
+string(REGEX REPLACE "([^.]+)[.]([^.]+)[.]([^.]+)" "\\3" FIXNUM ${VERSION})
+MESSAGE(STATUS "VERSION ${VERSION} -> RELNUM ${RELNUM}")
+MESSAGE(STATUS "VERSION ${VERSION} -> VERNUM ${VERNUM}")
+MESSAGE(STATUS "VERSION ${VERSION} -> FIXNUM ${FIXNUM}")
+
+include ( GNUInstallDirs )
+include ( FindPkgConfig )
+
+option(BUILD_SHARED_LIBS "Build a shared library" ON)
+option(BUILD_STATIC_LIBS "Build the static library" OFF)
+option(BUILD_TESTS "Build test programs" OFF)
+option(MSVC_STATIC_RUNTIME "Build with static runtime libs (/MT)" ON)
+
+# Zlib library needed
+find_package ( ZLIB REQUIRED )
+pkg_search_module ( ZZIP zzip )
+pkg_search_module ( ZZIPMAPPED zzipmmapped )
+pkg_search_module ( ZZIPFSEEKO zzipfseeko )
+
+# use the uninstalled zzip here (don't know to to tell pkg_search_module)
+set(lib ${CMAKE_SHARED_LIBRARY_PREFIX})
+set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX})
+get_target_property(libzzip libzzip OUTPUT_NAME)
+get_target_property(libzzipmapped libzzipmmapped OUTPUT_NAME)
+get_target_property(libzzipfseeko libzzipfseeko OUTPUT_NAME)
+set(ZZIP_INCLUDE_DIR ${CMAKE_SOURCE_DIR})
+set(ZZIP_LIBRARY ${CMAKE_BINARY_DIR}/${lib}${libzzip}${dll})
+set(ZZIPMAPPED_LIBRARY ${CMAKE_BINARY_DIR}/${lib}${libzzipmapped}${dll})
+set(ZZIPFSEEKO_LIBRARY ${CMAKE_BINARY_DIR}/${lib}${libzzipfseeko}${dll})
+
+# targets ########################################################
+add_executable(zzcat zzcat.c)
+add_executable(zzdir zzdir.c)
+add_executable(zzxorcat zzxorcat.c)
+add_executable(zzxordir zzxordir.c)
+add_executable(zzobfuscated zzobfuscated.c)
+add_executable(zziptest zziptest.c)
+add_executable(zzip zzip.c zzipmake-zip.c)
+add_executable(unzzip unzzip.c unzzipcat-zip.c unzzipdir-zip.c)
+add_executable(unzzip-mix unzzip.c unzzipcat-mix.c unzzipdir-mix.c)
+add_executable(unzzip-mem unzzip.c unzzipcat-mem.c unzzipdir-mem.c)
+add_executable(unzzip-big unzzip.c unzzipcat-big.c unzzipdir-big.c)
+
+target_link_libraries(zzcat "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(zzdir "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(zzxorcat "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(zzxordir "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(zzobfuscated "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(zziptest "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(zzip "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(unzzip "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(unzzip-mix "${ZZIP_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(unzzip-mem "${ZZIPMAPPED_LIBRARY}" ZLIB::ZLIB)
+target_link_libraries(unzzip-big "${ZZIPFSEEKO_LIBRARY}" ZLIB::ZLIB)
+
+target_include_directories(zzcat PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(zzdir PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(zzxorcat PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(zzxordir PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(zzobfuscated PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(zzip PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(unzzip PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(unzzip-mix PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(unzzip-mem PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+target_include_directories(unzzip-big PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
+
+# install ########################################################
+install(TARGETS zzcat zzdir zzxorcat zzxordir
+ unzzip unzzip-mix unzzip-mem unzzip-big
+ DESTINATION bin)
# use the uninstalled zzip here (don't know to to tell pkg_search_module)
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX})
set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX})
-get_target_property(libname zzip OUTPUT_NAME)
+get_target_property(libname libzzip OUTPUT_NAME)
set(ZZIP_INCLUDE_DIR ${CMAKE_SOURCE_DIR})
set(ZZIP_LIBRARY ${CMAKE_BINARY_DIR}/${lib}${libname}${dll})
+# targets ########################################################
set(ZZIPWRAP_SRCS
zzipwrap.c)