Skip to content

Commit

Permalink
update cmake file, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Oct 13, 2023
1 parent bc760d5 commit e6bbda1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 21 deletions.
28 changes: 18 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ ZMAT: A portable C-library and MATLAB/Octave toolbox for zlib/gzip/lzma/lz4/zstd

* Copyright (C) 2019-2023 Qianqian Fang <q.fang at neu.edu>
* License: GNU General Public License version 3 (GPL v3), see License*.txt
* Version: 0.9.9 (Archie-the-goat - RC1)
* Version: 0.9.9 (Foxy the Fantastic Mr. Fox - RC1)
* URL: https://github.com/NeuroJSON/zmat
* Acknowledgement: This project is part of the `NeuroJSON project <https://neurojson.org>`_
supported by US National Institute of Health (NIH)
grant `U24-NS124027 <https://reporter.nih.gov/project-details/10308329>`_

.. image:: https://travis-ci.com/fangq/zmat.svg?branch=master
:target: https://travis-ci.com/fangq/zmat
.. image:: https://github.com/NeuroJSON/zmat/actions/workflows/run_test.yml/badge.svg
:target: https://github.com/NeuroJSON/zmat/actions/workflows/run_test.yml

#################
Table of Contents
Expand Down Expand Up @@ -253,7 +253,7 @@ zmat.m
'blosc2blosclz': blosc2 meta-compressor with blosclz compression
'blosc2lz4': blosc2 meta-compressor with lz4 compression
'blosc2lz4hc': blosc2 meta-compressor with lz4hc compression
'blosc2zlib: blosc2 meta-compressor with zlib/zip compression
'blosc2zlib': blosc2 meta-compressor with zlib/zip compression
'blosc2zstd': blosc2 meta-compressor with zstd compression
'base64': encode or decode use base64 format
options: a series of ('name', value) pairs, supported options include
Expand Down Expand Up @@ -401,7 +401,8 @@ be done by
.. code-block:: shell
cd zmat/src
make clean mex
make clean
make mex
to create the mex file for MATLAB, and run ``make clean oct`` to compile
the mex file for Octave.
Expand All @@ -416,9 +417,9 @@ Contribution and feedback
==========================

ZMat is an open-source project. This means you can not only use it and modify
it as you wish, but also you can contribute your changes back to JSONLab so
it as you wish, but also you can contribute your changes back to ZMat so
that everyone else can enjoy the improvement. For anyone who want to contribute,
please download JSONLab source code from its source code repositories by using the
please download ZMat source code from its source code repositories by using the
following command:


Expand All @@ -438,10 +439,10 @@ changes, and ready to share it with others, please submit your changes as a
"pull request" on github. The project maintainer, Dr. Qianqian Fang will
review the changes and choose to accept the patch.

We appreciate any suggestions and feedbacks from you. Please use the iso2mesh
mailing list to report any questions you may have regarding ZMat:
We appreciate any suggestions and feedbacks from you. Please use the NeuroJSON
forum to report any questions you may have regarding ZMat:

`iso2mesh-users <https://groups.google.com/forum/#!forum/iso2mesh-users>`_
`NeuroJSON forum <https://github.com/orgs/NeuroJSON/discussions>`_

(Subscription to the mailing list is needed in order to post messages).

Expand All @@ -464,3 +465,10 @@ ZMat is linked against 4 open-source data compression libraries
4. LZ4 library: https://lz4.github.io/lz4/
* Copyright (C) 2011-2019, Yann Collet.
* License: BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
5. C-blosc2: https://blosc.org/
* Copyright (c) 2009-2018 Francesc Alted <[email protected]>
* Copyright (c) 2019-present The Blosc Development Team <[email protected]>
* License: BSD 3-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6. ZStd: https://facebook.github.io/zstd/
* Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
* License: BSD 3-Clause License (http://www.opensource.org/licenses/bsd-license.php)
63 changes: 53 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ cmake_minimum_required(VERSION 3.3)

project(zmat)

find_package(ZLIB REQUIRED)
option(USE_ZLIB "Use zlib instead of miniz" OFF)
option(USE_LZ4 "Use lz4" ON)
option(USE_BLOSC2 "Use blosc2" ON)
option(USE_ZSTD "Use ZStd" OFF)
option(USE_LZMA "Use lzma" ON)

find_package(Matlab)

option(STATIC_LIB "Build static library" ON)
Expand All @@ -17,17 +22,46 @@ option(STATIC_LIB "Build static library" ON)
set(CMAKE_C_FLAGS "-g -Wall -O3 -fPIC")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../)

if(USE_ZLIB)
find_package(ZLIB REQUIRED)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_ZLIB -D_LARGEFILE64_SOURCE=1")
include_directories(miniz)
endif()

# Add include directories
include_directories(../include)
include_directories(lz4)
include_directories(easylzma)
include_directories(easylzma/pavlov)

if(USE_LZ4)
include_directories(lz4)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_LZ4")
endif()

if(USE_LZMA)
include_directories(easylzma)
include_directories(easylzma/pavlov)
endif()

if(USE_BLOSC2)
include_directories(blosc2/include)
add_subdirectory(blosc2/blosc)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_BLOSC2")
endif()

if(USE_ZSTD)
include_directories(blosc2/internal-complibs/zstd)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_ZSTD")
endif()

# Add all project units

if(STATIC_LIB)
add_library(zmat STATIC
zmatlib.c
miniz/miniz.c
lz4/lz4.c
lz4/lz4hc.c
easylzma/compress.c
Expand All @@ -48,6 +82,7 @@ else()
# Add all project units
add_library(zmat SHARED
zmatlib.c
miniz/miniz.c
lz4/lz4.c
lz4/lz4hc.c
easylzma/compress.c
Expand All @@ -69,14 +104,22 @@ endif()
# Link options
target_link_libraries(
zmat
ZLIB::ZLIB
)

if(Matlab_FOUND)
matlab_add_mex(
NAME zipmat
SRC zmat.cpp
LINK_TO mex mx zmat
)
if(${CMAKE_VERSION} VERSION_LESS "3.24.0")
matlab_add_mex(
NAME zipmat
SRC zmat.cpp
LINK_TO zmat
)
else()
matlab_add_mex(
NAME zipmat
SRC zmat.cpp
NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES
LINK_TO ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} zmat
)
endif()
endif()

6 changes: 5 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ else
INCLUDEDIRS+=-Iblosc2/internal-complibs/zstd
LIBZLIB+=-Lblosc2/internal-complibs/zstd -lzstd
endif
LIBZLIB+=-Lblosc2/lib -lblosc2 -pthread -ldl
ifeq ($(findstring _NT-,$(PLATFORM)), _NT-)
LIBZLIB+=-Lblosc2/lib -lblosc2 -pthread
else
LIBZLIB+=-Lblosc2/lib -lblosc2 -pthread -ldl
endif
ifeq ($(HAVE_ZLIB),yes)
LIBZLIB+=-lz
endif
Expand Down

0 comments on commit e6bbda1

Please sign in to comment.