From 25a84d5f30ca7d3fcc257c21a1d7e5ddb39b5756 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Fri, 14 Sep 2018 17:25:01 +0200 Subject: [PATCH] add bins/CMakeLists.txt and adjust libzzip imports --- CMakeLists.txt | 44 +++++++++++++----------- SDL/CMakeLists.txt | 2 +- bins/CMakeLists.txt | 76 +++++++++++++++++++++++++++++++++++++++++ zzipwrap/CMakeLists.txt | 3 +- 4 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 bins/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ceacfdf..e70b426 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ option(ZZIPMMAPPED "Build libzzipmmapped (not fully portable)" ON) 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 ) @@ -110,33 +111,33 @@ set(ZZIPLIB_HDRS 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) @@ -146,26 +147,29 @@ endif() 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].*") diff --git a/SDL/CMakeLists.txt b/SDL/CMakeLists.txt index 9c048dc..132a4a1 100644 --- a/SDL/CMakeLists.txt +++ b/SDL/CMakeLists.txt @@ -25,7 +25,7 @@ pkg_search_module ( SDL sdl2) # 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}) diff --git a/bins/CMakeLists.txt b/bins/CMakeLists.txt new file mode 100644 index 0000000..2187fe4 --- /dev/null +++ b/bins/CMakeLists.txt @@ -0,0 +1,76 @@ +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) diff --git a/zzipwrap/CMakeLists.txt b/zzipwrap/CMakeLists.txt index d3f6342..bd19cdf 100644 --- a/zzipwrap/CMakeLists.txt +++ b/zzipwrap/CMakeLists.txt @@ -28,10 +28,11 @@ pkg_search_module ( ZZIP zzip ) # 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) -- 2.40.0