Skip to content

Commit

Permalink
Inline Comments & Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Jul 26, 2023
1 parent a67dfca commit 654342e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 48 deletions.
18 changes: 12 additions & 6 deletions Blosc2Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
# locate the installed FindABC.cmake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# dependencies
# this section stores which configuration options were set
set(HAVE_THREADS @Threads_FOUND@)
set(HAVE_IPP @HAVE_IPP@)
set(HAVE_ZLIB_NG @HAVE_ZLIB_NG@)
Expand All @@ -22,23 +22,27 @@ set(PREFER_EXTERNAL_LZ4 @PREFER_EXTERNAL_LZ4@)
set(PREFER_EXTERNAL_ZLIB @PREFER_EXTERNAL_ZLIB@)
set(PREFER_EXTERNAL_ZSTD @PREFER_EXTERNAL_ZSTD@)

# find dependencies and their targets, which are used in our Blosc2Targets.cmake
# additionally, the Blosc2_..._FOUND variables are used to support
# find_package(Blosc2 ... COMPONENTS ... ...)
# this enables downstream projects to express the need for specific features.
if(WIN32)
if(HAVE_THREADS)
find_dependency(Threads)
set(Blosc2_THREADS TRUE)
set(Blosc2_THREADS_FOUND TRUE)
else()
set(Blosc2_THREADS FALSE)
set(Blosc2_THREADS_FOUND FALSE)
endif()
else()
find_dependency(Threads)
set(Blosc2_THREADS TRUE)
set(Blosc2_THREADS_FOUND TRUE)
endif()

if(NOT DEACTIVATE_IPP AND HAVE_IPP)
find_dependency(IPP)
set(Blosc2_IPP FALSE)
set(Blosc2_IPP_FOUND FALSE)
else()
set(Blosc2_IPP TRUE)
set(Blosc2_IPP_FOUND TRUE)
endif()

if(PREFER_EXTERNAL_LZ4)
Expand Down Expand Up @@ -68,6 +72,8 @@ endif()
include("${CMAKE_CURRENT_LIST_DIR}/Blosc2Targets.cmake")

# check if components are fulfilled and set Blosc2_<COMPONENT>_FOUND vars
# Blosc2_FIND_COMPONENTS is a list set by find_package(... COMPONENTS ... ...)
# likewise Blosc2_FIND_REQUIRED_... per component specified
foreach(comp ${Blosc2_FIND_COMPONENTS})
if(NOT Blosc2_${comp}_FOUND)
if(Blosc2_FIND_REQUIRED_${comp})
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ if(BLOSC_INSTALL)
# config files
include(CMakePackageConfigHelpers)

# we need a general location for Unix and Windows to install our
# Blosc2Config.cmake files to. This is defined in CMake:
# https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure
if(NOT Blosc2_INSTALL_CMAKEDIR)
if(CMAKE_INSTALL_CMAKEDIR)
set(Blosc2_INSTALL_CMAKEDIR "${CMAKE_INSTALL_CMAKEDIR}/Blosc2")
Expand All @@ -480,6 +483,8 @@ if(BLOSC_INSTALL)
endif()

# CMake config file
# This stores our targets and find and populates the targets we depend on,
# including third party interface libraries that we added.
set(Blosc2_INSTALL_TARGET_NAMES)
if(BUILD_SHARED)
list(APPEND Blosc2_INSTALL_TARGET_NAMES blosc2_shared)
Expand Down
96 changes: 54 additions & 42 deletions blosc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ set(version_string ${BLOSC2_VERSION_MAJOR}.${BLOSC2_VERSION_MINOR}.${BLOSC2_VERS
# targets
if(BUILD_SHARED)
add_library(blosc2_shared SHARED)
# ALIAS for superbuilds that use Blosc2 as sub-project
# must be the same as the NAMESPACE in Blosc2Targets
add_library(Blosc2::blosc2_shared ALIAS blosc2_shared)
set_target_properties(blosc2_shared PROPERTIES
OUTPUT_NAME blosc2
Expand All @@ -36,6 +38,8 @@ if(BUILD_SHARED)
endif()
if(BUILD_STATIC)
add_library(blosc2_static STATIC)
# ALIAS for superbuilds that use Blosc2 as sub-project
# must be the same as the NAMESPACE in Blosc2Targets
add_library(Blosc2::blosc2_static ALIAS blosc2_static)
set_target_properties(blosc2_static PROPERTIES
OUTPUT_NAME blosc2
Expand Down Expand Up @@ -72,9 +76,10 @@ endif()

set(INTERNAL_LIBS ${PROJECT_SOURCE_DIR}/internal-complibs)

# includes
# link dependencies
# "link" dependent targets via target_link_libraries (preferred) and
# manually add includes / libs for others
if(LZ4_FOUND)
set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_INCLUDE_DIR})
if(BUILD_SHARED)
target_include_directories(blosc2_shared PUBLIC ${LZ4_INCLUDE_DIR})
endif()
Expand All @@ -86,7 +91,6 @@ if(LZ4_FOUND)
endif()
else()
set(LZ4_LOCAL_DIR ${INTERNAL_LIBS}/lz4-1.9.4)
#set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_LOCAL_DIR})
if(BUILD_SHARED)
target_include_directories(blosc2_shared PRIVATE ${LZ4_LOCAL_DIR})
endif()
Expand Down Expand Up @@ -121,7 +125,6 @@ if(NOT DEACTIVATE_ZLIB)
endif()
else()
set(ZLIB_LOCAL_DIR ${INTERNAL_LIBS}/${ZLIB_NG_DIR})
#set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_LOCAL_DIR})
if(BUILD_SHARED)
target_include_directories(blosc2_shared PRIVATE ${ZLIB_LOCAL_DIR})
endif()
Expand Down Expand Up @@ -162,44 +165,6 @@ if(NOT DEACTIVATE_ZSTD)
endif()
endif()

# targets
if(BUILD_SHARED)
target_link_libraries(blosc2_shared PUBLIC ${LIBS})
endif()
if(BUILD_STATIC)
target_link_libraries(blosc2_static PUBLIC ${LIBS})
endif()
if(BUILD_TESTS)
target_link_libraries(blosc_testing PUBLIC ${LIBS})
endif()


# library sources
list(APPEND SOURCES
blosc/blosc2.c blosc/blosclz.c blosc/fastcopy.c blosc/fastcopy.h blosc/schunk.c blosc/frame.c blosc/stune.c blosc/stune.h
blosc/context.h blosc/delta.c blosc/delta.h blosc/shuffle-generic.c blosc/bitshuffle-generic.c blosc/trunc-prec.c blosc/trunc-prec.h
blosc/timestamp.c blosc/sframe.c blosc/directories.c blosc/blosc2-stdio.c
blosc/b2nd.c blosc/b2nd_utils.c)
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
if(COMPILER_SUPPORT_SSE2)
message(STATUS "Adding run-time support for SSE2")
list(APPEND SOURCES blosc/shuffle-sse2.c blosc/bitshuffle-sse2.c)
endif()
if(COMPILER_SUPPORT_AVX2)
message(STATUS "Adding run-time support for AVX2")
list(APPEND SOURCES blosc/shuffle-avx2.c blosc/bitshuffle-avx2.c)
endif()
endif()
if(COMPILER_SUPPORT_NEON)
message(STATUS "Adding run-time support for NEON")
list(APPEND SOURCES blosc/shuffle-neon.c blosc/bitshuffle-neon.c)
endif()
if(COMPILER_SUPPORT_ALTIVEC)
message(STATUS "Adding run-time support for ALTIVEC")
list(APPEND SOURCES blosc/shuffle-altivec.c blosc/bitshuffle-altivec.c)
endif()
list(APPEND SOURCES blosc/shuffle.c)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE) # pre 3.1
set(THREADS_PREFER_PTHREAD_FLAG TRUE) # CMake 3.1+
if(WIN32)
Expand Down Expand Up @@ -280,6 +245,51 @@ if(UNIX AND NOT APPLE)
# set(LIBS ${LIBS} "profiler")
endif()


# Blosc2 library source files
list(APPEND SOURCES
blosc/blosc2.c
blosc/blosclz.c
blosc/fastcopy.c
blosc/fastcopy.h
blosc/schunk.c
blosc/frame.c
blosc/stune.c
blosc/stune.h
blosc/context.h
blosc/delta.c
blosc/delta.h
blosc/shuffle-generic.c
blosc/bitshuffle-generic.c
blosc/trunc-prec.c
blosc/trunc-prec.h
blosc/timestamp.c
blosc/sframe.c
blosc/directories.c
blosc/blosc2-stdio.c
blosc/b2nd.c
blosc/b2nd_utils.c
)
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
if(COMPILER_SUPPORT_SSE2)
message(STATUS "Adding run-time support for SSE2")
list(APPEND SOURCES blosc/shuffle-sse2.c blosc/bitshuffle-sse2.c)
endif()
if(COMPILER_SUPPORT_AVX2)
message(STATUS "Adding run-time support for AVX2")
list(APPEND SOURCES blosc/shuffle-avx2.c blosc/bitshuffle-avx2.c)
endif()
endif()
if(COMPILER_SUPPORT_NEON)
message(STATUS "Adding run-time support for NEON")
list(APPEND SOURCES blosc/shuffle-neon.c blosc/bitshuffle-neon.c)
endif()
if(COMPILER_SUPPORT_ALTIVEC)
message(STATUS "Adding run-time support for ALTIVEC")
list(APPEND SOURCES blosc/shuffle-altivec.c blosc/bitshuffle-altivec.c)
endif()
list(APPEND SOURCES blosc/shuffle.c)

# Based on the target architecture and hardware features supported
# by the C compiler, set hardware architecture optimization flags
# for specific shuffle implementations.
Expand Down Expand Up @@ -378,6 +388,7 @@ if(COMPILER_SUPPORT_ALTIVEC)
APPEND PROPERTY COMPILE_DEFINITIONS SHUFFLE_ALTIVEC_ENABLED)
endif()

# add libraries for dependencies that are not CMake targets
if(BUILD_SHARED)
target_link_libraries(blosc2_shared PUBLIC ${LIBS})
target_include_directories(blosc2_shared PUBLIC ${BLOSC_INCLUDE_DIRS})
Expand All @@ -393,4 +404,5 @@ if(BUILD_TESTS)
target_include_directories(blosc_testing PUBLIC ${BLOSC_INCLUDE_DIRS})
endif()

# we use this variable in the CMake file one directory above ours
set(SOURCES ${SOURCES} PARENT_SCOPE)

0 comments on commit 654342e

Please sign in to comment.