-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e7628b3
Showing
50 changed files
with
3,552 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.a | ||
*.o | ||
bin | ||
build | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
if(WIN32) | ||
cmake_minimum_required(VERSION 3.4) | ||
else() | ||
cmake_minimum_required(VERSION 3.1) | ||
endif() | ||
|
||
# Fail immediately if not using an out-of-source build | ||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) | ||
message(FATAL_ERROR | ||
"In-source builds are not supported. Please create a build directory " | ||
"separate from the source directory") | ||
endif() | ||
|
||
#------------------------------------------------------------------------------# | ||
# Parse version number from fpzip.h | ||
#------------------------------------------------------------------------------# | ||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/fpzip.h _fpzip_h_contents) | ||
string(REGEX REPLACE ".*#define[ \t]+FPZIP_VERSION_MAJOR[ \t]+([0-9]+).*" | ||
"\\1" FPZIP_VERSION_MAJOR ${_fpzip_h_contents}) | ||
string(REGEX REPLACE ".*#define[ \t]+FPZIP_VERSION_MINOR[ \t]+([0-9]+).*" | ||
"\\1" FPZIP_VERSION_MINOR ${_fpzip_h_contents}) | ||
string(REGEX REPLACE ".*#define[ \t]+FPZIP_VERSION_PATCH[ \t]+([0-9]+).*" | ||
"\\1" FPZIP_VERSION_PATCH ${_fpzip_h_contents}) | ||
set(FPZIP_VERSION | ||
"${FPZIP_VERSION_MAJOR}.${FPZIP_VERSION_MINOR}.${FPZIP_VERSION_PATCH}") | ||
|
||
project(FPZIP VERSION ${FPZIP_VERSION}) | ||
|
||
#------------------------------------------------------------------------------# | ||
# Some boilerplate to setup nice output directories | ||
#------------------------------------------------------------------------------# | ||
include(GNUInstallDirs) | ||
set(CMAKE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/fpzip | ||
CACHE STRING "Installation CMake subdirectory") | ||
|
||
list(INSERT CMAKE_MODULE_PATH 0 "${FPZIP_SOURCE_DIR}/cmake") | ||
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${FPZIP_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) | ||
endif() | ||
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${FPZIP_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) | ||
endif() | ||
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${FPZIP_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------# | ||
# Top level options | ||
#------------------------------------------------------------------------------# | ||
|
||
# Windows (Visual Studio) specific options | ||
if(MSVC) | ||
# Use this to get a usable export library when building a DLL on Windows | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
||
# Silence extraneous Visual Studio specific warnings | ||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4146 /wd4305) | ||
endif() | ||
|
||
# Suggest C99 | ||
if(NOT CMAKE_C_STANDARD) | ||
set(CMAKE_C_STANDARD 99) | ||
endif() | ||
|
||
if(MSVC OR MINGW) | ||
set(CMAKE_C_STANDARD 90) | ||
endif() | ||
|
||
message(STATUS "Compiling with C standard: ${CMAKE_C_STANDARD}") | ||
|
||
# Suggest C++98 | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 98) | ||
endif() | ||
message(STATUS "Compiling with C++ standard: ${CMAKE_CXX_STANDARD}") | ||
|
||
include(CMakeDependentOption) | ||
|
||
# Typically you'd always be able to enable shared libraries but default | ||
# configurations with the Cray toolchain will explicitly disable shared lib | ||
# support and only allow static libs. Making this a cmake_dependent_option | ||
# will ensure that shared library support will be disabled if the system does | ||
# not support it. | ||
|
||
# Setup shared library / -fPIC stuff | ||
get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) | ||
cmake_dependent_option(BUILD_SHARED_LIBS | ||
"Whether or not to build shared libraries" ON | ||
"SHARED_LIBS_SUPPORTED" OFF) | ||
|
||
# PIC is always on for shared libs. This allows it to be selectable for | ||
# static libs. | ||
if(DEFINED FPZIP_ENABLE_PIC) | ||
set(FPZIP_ENABLE_PIC_DEFAULT ${FPZIP_ENABLE_PIC}) | ||
elseif(DEFINED CMAKE_POSITION_INDEPENDENT_CODE) | ||
set(FPZIP_ENABLE_PIC_DEFAULT ${CMAKE_POSITION_INDEPENDENT_CODE}) | ||
else() | ||
set(FPZIP_ENABLE_PIC_DEFAULT ${SHARED_LIBS_SUPPORTED}) | ||
endif() | ||
cmake_dependent_option(FPZIP_ENABLE_PIC | ||
"Build with Position Independent Code" ${FPZIP_ENABLE_PIC_DEFAULT} | ||
"SHARED_LIBS_SUPPORTED" OFF) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ${FPZIP_ENABLE_PIC}) | ||
|
||
# Compile-time options | ||
|
||
set(FPZIP_BLOCK_SIZE 4096 CACHE STRING "I/O unit in bytes") | ||
set_property(CACHE FPZIP_BLOCK_SIZE PROPERTY STRINGS "4096") | ||
|
||
set(FPZIP_FP FPZIP_FP_FAST CACHE STRING "Floating-point arithmetic") | ||
set_property(CACHE FPZIP_FP PROPERTY STRINGS "FPZIP_FP_FAST;FPZIP_FP_SAFE;FPZIP_FP_EMUL;FPZIP_FP_INT") | ||
|
||
option(FPZIP_WITH_REINTERPRET_CAST "Convert to int via reinterpret_cast" OFF) | ||
|
||
option(FPZIP_WITH_UNION "Convert to int via union" OFF) | ||
|
||
# Handle compile-time macros | ||
|
||
list(APPEND fpzip_public_defs FPZIP_FP=${FPZIP_FP}) | ||
list(APPEND fpzip_private_defs FPZIP_BLOCK_SIZE=${FPZIP_BLOCK_SIZE}) | ||
|
||
if((DEFINED FPZIP_INT64) AND (DEFINED FPZIP_INT64_SUFFIX)) | ||
list(APPEND fpzip_public_defs FPZIP_INT64=${FPZIP_INT64}) | ||
list(APPEND fpzip_public_defs FPZIP_INT64_SUFFIX=${FPZIP_INT64_SUFFIX}) | ||
endif() | ||
|
||
if((DEFINED FPZIP_UINT64) AND (DEFINED FPZIP_UINT64_SUFFIX)) | ||
list(APPEND fpzip_public_defs FPZIP_UINT64=${FPZIP_UINT64}) | ||
list(APPEND fpzip_public_defs FPZIP_UINT64_SUFFIX=${FPZIP_UINT64_SUFFIX}) | ||
endif() | ||
|
||
# Link libm only if necessary | ||
include(CheckCSourceCompiles) | ||
check_c_source_compiles("#include<math.h>\nfloat f; int main(){sqrt(f);return 0;}" HAVE_MATH) | ||
if(NOT HAVE_MATH) | ||
set(CMAKE_REQUIRED_LIBRARIES m) | ||
check_c_source_compiles("#include<math.h>\nfloat f; int main(){sqrt(f);return 0;}" HAVE_LIBM_MATH) | ||
unset(CMAKE_REQUIRED_LIBRARIES) | ||
if(NOT HAVE_LIBM_MATH) | ||
message(FATAL_ERROR "Unable to use C math library functions (with or without -lm)") | ||
endif() | ||
endif() | ||
|
||
#------------------------------------------------------------------------------# | ||
# Add source code | ||
#------------------------------------------------------------------------------# | ||
include(CTest) | ||
if(BUILD_TESTING) | ||
enable_testing() | ||
endif() | ||
|
||
set(FPZIP_LIBRARY_PREFIX "" CACHE STRING | ||
"Prefix to prepend to the output library name") | ||
mark_as_advanced(FPZIP_LIBRARY_PREFIX) | ||
|
||
add_subdirectory(src) | ||
|
||
option(BUILD_ALL "Build all subdirectories" OFF) | ||
if(BUILD_ALL) | ||
set(BUILD_UTILITIES ON CACHE BOOL "Build command line utilities for fpzip" FORCE) | ||
set(BUILD_EXAMPLES ON CACHE BOOL "Build examples" FORCE) | ||
endif() | ||
|
||
option(BUILD_UTILITIES "Build command line utilities for fpzip" ON) | ||
if(BUILD_UTILITIES) | ||
add_subdirectory(utils) | ||
endif() | ||
|
||
#option(BUILD_EXAMPLES "Build examples" OFF) | ||
#if(BUILD_EXAMPLES) | ||
# add_subdirectory(examples) | ||
#endif() | ||
|
||
#if(BUILD_TESTING) | ||
# add_subdirectory(tests) | ||
#endif() | ||
|
||
#------------------------------------------------------------------------------# | ||
# Header install | ||
#------------------------------------------------------------------------------# | ||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
#------------------------------------------------------------------------------# | ||
# Build type: one of None, Debug, Release, RelWithDebInfo, MinSizeRel | ||
#------------------------------------------------------------------------------# | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release) | ||
endif() | ||
|
||
#------------------------------------------------------------------------------# | ||
# Packaging | ||
#------------------------------------------------------------------------------# | ||
|
||
# Add all targets to the build-tree export set | ||
export(TARGETS fpzip NAMESPACE fpzip:: | ||
FILE "${PROJECT_BINARY_DIR}/fpzip-targets.cmake") | ||
|
||
configure_file(fpzip-config.cmake.in | ||
"${PROJECT_BINARY_DIR}/fpzip-config.cmake" @ONLY) | ||
configure_file(fpzip-config-version.cmake.in | ||
"${PROJECT_BINARY_DIR}/fpzip-config-version.cmake" @ONLY) | ||
|
||
# Install the fpzip-config.cmake and fpzip-config-version.cmake | ||
install(FILES | ||
"${PROJECT_BINARY_DIR}/fpzip-config.cmake" | ||
"${PROJECT_BINARY_DIR}/fpzip-config-version.cmake" | ||
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") | ||
|
||
# Install the export set for use with the install-tree | ||
install(EXPORT fpzip-targets NAMESPACE fpzip:: | ||
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# compiler executables -------------------------------------------------------- | ||
|
||
CC = gcc | ||
CXX = g++ | ||
|
||
# language standard ----------------------------------------------------------- | ||
|
||
# CSTD = -std=c89 -Wno-unused-function | ||
CSTD = -std=c99 | ||
CXXSTD = -std=c++98 | ||
# CXXSTD = -std=c++11 | ||
|
||
# common compiler options ----------------------------------------------------- | ||
|
||
FLAGS = -O3 -fPIC -Wall -Wextra -pedantic -I../include | ||
SOFLAGS = | ||
|
||
# macOS compiler options (uncomment on macOS) --------------------------------- | ||
|
||
# SOFLAGS += -undefined dynamic_lookup | ||
|
||
# required compiler macros ---------------------------------------------------- | ||
|
||
# floating-point arithmetic implementation; choose one | ||
# FAST: optimize for speed; may impact correctness and portability | ||
# SAFE: use volatile accumulator | ||
# EMUL: emulate floating-point arithmetic | ||
# INT: reinterpret floating-point numbers as integers; most portable | ||
|
||
FPZIP_FP = FPZIP_FP_FAST | ||
# FPZIP_FP = FPZIP_FP_SAFE | ||
# FPZIP_FP = FPZIP_FP_EMUL | ||
# FPZIP_FP = FPZIP_FP_INT | ||
|
||
# output buffer size in bytes (ideally the disk block size) | ||
FPZIP_BLOCK_SIZE = 0x1000 | ||
# FPZIP_BLOCK_SIZE = 1 | ||
|
||
# optional compiler macros ---------------------------------------------------- | ||
|
||
# use long long for 64-bit types | ||
# DEFS += -DFPZIP_INT64='long long' -DFPZIP_INT64_SUFFIX='ll' | ||
# DEFS += -DFPZIP_UINT64='unsigned long long' -DFPZIP_UINT64_SUFFIX='ull' | ||
|
||
# bitwise type conversion mechanisms (defaults to memcpy) | ||
# FPZIP_CONV = -DFPZIP_WITH_REINTERPRET_CAST | ||
# FPZIP_CONV = -DFPZIP_WITH_UNION | ||
|
||
DEFS += -DFPZIP_BLOCK_SIZE=$(FPZIP_BLOCK_SIZE) -DFPZIP_FP=$(FPZIP_FP) $(FPZIP_CONV) | ||
|
||
# build targets --------------------------------------------------------------- | ||
|
||
# default targets | ||
BUILD_UTILITIES = 1 | ||
BUILD_TESTING = 0 | ||
BUILD_SHARED_LIBS = 0 | ||
|
||
# build all targets? | ||
ifdef BUILD_ALL | ||
ifneq ($(BUILD_ALL),0) | ||
BUILD_UTILITIES = 1 | ||
BUILD_TESTING = 1 | ||
endif | ||
endif | ||
|
||
# build shared libraries? | ||
ifneq ($(BUILD_SHARED_LIBS),0) | ||
LIBRARY = shared | ||
LIBFPZIP = libfpzip.so | ||
else | ||
LIBRARY = static | ||
LIBFPZIP = libfpzip.a | ||
endif | ||
|
||
# conditionals ---------------------------------------------------------------- | ||
|
||
# compiler options ------------------------------------------------------------ | ||
|
||
CFLAGS = $(CSTD) $(FLAGS) $(DEFS) | ||
CXXFLAGS = $(CXXSTD) $(FLAGS) $(DEFS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2018-2019, Lawrence Livermore National Security, LLC | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# see Config file for compile-time settings | ||
include Config | ||
|
||
MAKEFLAGS += --no-print-directory | ||
|
||
|
||
# default: build all targets enabled in Config | ||
all: | ||
@echo $(LIBRARY) | ||
@cd src; $(MAKE) clean $(LIBRARY) | ||
ifneq ($(BUILD_UTILITIES),0) | ||
@cd utils; $(MAKE) clean all | ||
endif | ||
ifneq ($(BUILD_TESTING),0) | ||
@cd tests; $(MAKE) clean all | ||
endif | ||
|
||
|
||
# run basic regression tests | ||
test: | ||
@cd tests; $(MAKE) test | ||
|
||
|
||
# clean all | ||
clean: | ||
@cd src; $(MAKE) clean | ||
@cd utils; $(MAKE) clean | ||
@cd tests; $(MAKE) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
This work was produced under the auspices of the U.S. Department of | ||
Energy by Lawrence Livermore National Laboratory under Contract | ||
DE-AC52-07NA27344. | ||
|
||
This work was prepared as an account of work sponsored by an agency of | ||
the United States Government. Neither the United States Government nor | ||
Lawrence Livermore National Security, LLC, nor any of their employees | ||
makes any warranty, expressed or implied, or assumes any legal liability | ||
or responsibility for the accuracy, completeness, or usefulness of any | ||
information, apparatus, product, or process disclosed, or represents that | ||
its use would not infringe privately owned rights. | ||
|
||
Reference herein to any specific commercial product, process, or service | ||
by trade name, trademark, manufacturer, or otherwise does not necessarily | ||
constitute or imply its endorsement, recommendation, or favoring by the | ||
United States Government or Lawrence Livermore National Security, LLC. | ||
|
||
The views and opinions of authors expressed herein do not necessarily | ||
state or reflect those of the United States Government or Lawrence | ||
Livermore National Security, LLC, and shall not be used for advertising | ||
or product endorsement purposes. |
Oops, something went wrong.