Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add c-blosc/1.17.1 #933

Merged
merged 2 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/c-blosc/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1.2)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
uilianries marked this conversation as resolved.
Show resolved Hide resolved

add_subdirectory("source_subfolder")
8 changes: 8 additions & 0 deletions recipes/c-blosc/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"1.17.1":
url: "https://github.com/Blosc/c-blosc/archive/v1.17.1.tar.gz"
sha256: "19a6948b579c27e8ac440b4f077f99fc90e7292b1d9cb896bec0fd781d68fba2"
patches:
"1.17.1":
- patch_file: "patches/cmake-dependencies_and_install.patch"
base_path: "source_subfolder"
108 changes: 108 additions & 0 deletions recipes/c-blosc/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import os

from conans import ConanFile, CMake, tools

class CbloscConan(ConanFile):
name = "c-blosc"
description = "An extremely fast, multi-threaded, meta-compressor library."
license = "BSD-3-Clause"
topics = ("conan", "c-blosc", "blosc", "compression")
homepage = "https://github.com/Blosc/c-blosc"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt", "patches/**"]
uilianries marked this conversation as resolved.
Show resolved Hide resolved
generators = "cmake"
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_lz4": [True, False],
"with_snappy": [True, False],
"with_zlib": [True, False],
"with_zstd": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"with_lz4": True,
"with_snappy": True,
"with_zlib": True,
"with_zstd": True
}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
del self.settings.compiler.cppstd
# Snappy is a C++ library with C API. C-Blosc only uses the C API of
# Snappy, but if C-Blosc is shared (and snappy static), we have to use
# C++ linker.
if not (self.options.with_snappy and self.options.shared):
del self.settings.compiler.libcxx

def requirements(self):
if self.options.with_lz4:
self.requires.add("lz4/1.9.2")
if self.options.with_snappy:
self.requires.add("snappy/1.1.7")
if self.options.with_zlib:
self.requires.add("zlib/1.2.11")
if self.options.with_zstd:
self.requires.add("zstd/1.4.4")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self.name + "-" + self.version, self._source_subfolder)

def build(self):
for patch in self.conan_data["patches"][self.version]:
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
tools.patch(**patch)
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
cmake = self._configure_cmake()
cmake.build()

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
self._cmake.definitions["BUILD_STATIC"] = not self.options.shared
self._cmake.definitions["BUILD_SHARED"] = self.options.shared
self._cmake.definitions["BUILD_TESTS"] = False
self._cmake.definitions["BUILD_BENCHMARKS"] = False
self._cmake.definitions["DEACTIVATE_SSE2"] = False
self._cmake.definitions["DEACTIVATE_AVX2"] = False
self._cmake.definitions["DEACTIVATE_LZ4"] = not self.options.with_lz4
self._cmake.definitions["DEACTIVATE_SNAPPY"] = not self.options.with_snappy
self._cmake.definitions["DEACTIVATE_ZLIB"] = not self.options.with_zlib
self._cmake.definitions["DEACTIVATE_ZSTD"] = not self.options.with_zstd
self._cmake.definitions["DEACTIVATE_SYMBOLS_CHECK"] = True
self._cmake.definitions["PREFER_EXTERNAL_LZ4"] = True
self._cmake.definitions["PREFER_EXTERNAL_SNAPPY"] = True
self._cmake.definitions["PREFER_EXTERNAL_ZLIB"] = True
self._cmake.definitions["PREFER_EXTERNAL_ZSTD"] = True
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def package(self):
licenses = ["BLOSC.txt", "BITSHUFFLE.txt", "FASTLZ.txt"]
for license_file in licenses:
self.copy(license_file, dst="licenses", src=os.path.join(self._source_subfolder, "LICENSES"))
cmake = self._configure_cmake()
cmake.install()
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.names["cmake_find_package"] = "Blosc"
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.names["cmake_find_package_multi"] = "Blosc"
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
168 changes: 168 additions & 0 deletions recipes/c-blosc/all/patches/cmake-dependencies_and_install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
--- a/CMakeLists.txt
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
+++ b/CMakeLists.txt
@@ -126,51 +126,18 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")


if(NOT DEACTIVATE_LZ4)
- if(PREFER_EXTERNAL_LZ4)
- find_package(LZ4)
- else()
- message(STATUS "Using LZ4 internal sources.")
- endif(PREFER_EXTERNAL_LZ4)
- # HAVE_LZ4 will be set to true because even if the library is
- # not found, we will use the included sources for it
set(HAVE_LZ4 TRUE)
endif(NOT DEACTIVATE_LZ4)

if(NOT DEACTIVATE_SNAPPY)
- if(PREFER_EXTERNAL_SNAPPY)
- find_package(Snappy)
- else()
- message(STATUS "Using Snappy internal sources.")
- endif(PREFER_EXTERNAL_SNAPPY)
- # HAVE_SNAPPY will be set to true because even if the library is not found,
- # we will use the included sources for it
set(HAVE_SNAPPY TRUE)
endif(NOT DEACTIVATE_SNAPPY)

if(NOT DEACTIVATE_ZLIB)
- # import the ZLIB_ROOT environment variable to help finding the zlib library
- if(PREFER_EXTERNAL_ZLIB)
- set(ZLIB_ROOT $ENV{ZLIB_ROOT})
- find_package(ZLIB)
- if (NOT ZLIB_FOUND )
- message(STATUS "No zlib found. Using internal sources.")
- endif (NOT ZLIB_FOUND )
- else()
- message(STATUS "Using zlib internal sources.")
- endif(PREFER_EXTERNAL_ZLIB)
- # HAVE_ZLIB will be set to true because even if the library is not found,
- # we will use the included sources for it
set(HAVE_ZLIB TRUE)
endif(NOT DEACTIVATE_ZLIB)

if (NOT DEACTIVATE_ZSTD)
- if (PREFER_EXTERNAL_ZSTD)
- find_package(Zstd)
- else ()
- message(STATUS "Using ZSTD internal sources.")
- endif (PREFER_EXTERNAL_ZSTD)
- # HAVE_ZSTD will be set to true because even if the library is
- # not found, we will use the included sources for it
set(HAVE_ZSTD TRUE)
endif (NOT DEACTIVATE_ZSTD)

--- a/blosc/CMakeLists.txt
+++ b/blosc/CMakeLists.txt
@@ -10,41 +10,6 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)

# includes
set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
-if(NOT DEACTIVATE_LZ4)
- if (LZ4_FOUND)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_INCLUDE_DIR})
- else(LZ4_FOUND)
- set(LZ4_LOCAL_DIR ${INTERNAL_LIBS}/lz4-1.9.2)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${LZ4_LOCAL_DIR})
- endif(LZ4_FOUND)
-endif(NOT DEACTIVATE_LZ4)
-
-if(NOT DEACTIVATE_SNAPPY)
- if (SNAPPY_FOUND)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${SNAPPY_INCLUDE_DIR})
- else(SNAPPY_FOUND)
- set(SNAPPY_LOCAL_DIR ${INTERNAL_LIBS}/snappy-1.1.1)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${SNAPPY_LOCAL_DIR})
- endif(SNAPPY_FOUND)
-endif(NOT DEACTIVATE_SNAPPY)
-
-if(NOT DEACTIVATE_ZLIB)
- if (ZLIB_FOUND)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
- else(ZLIB_FOUND)
- set(ZLIB_LOCAL_DIR ${INTERNAL_LIBS}/zlib-1.2.8)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZLIB_LOCAL_DIR})
- endif(ZLIB_FOUND)
-endif(NOT DEACTIVATE_ZLIB)
-
-if (NOT DEACTIVATE_ZSTD)
- if (ZSTD_FOUND)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_INCLUDE_DIR})
- else (ZSTD_FOUND)
- set(ZSTD_LOCAL_DIR ${INTERNAL_LIBS}/zstd-1.4.4)
- set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIRS} ${ZSTD_LOCAL_DIR} ${ZSTD_LOCAL_DIR}/common)
- endif (ZSTD_FOUND)
-endif (NOT DEACTIVATE_ZSTD)

include_directories(${BLOSC_INCLUDE_DIRS})

@@ -81,42 +46,19 @@ else(WIN32)
endif(WIN32)

if(NOT DEACTIVATE_LZ4)
- if(LZ4_FOUND)
- set(LIBS ${LIBS} ${LZ4_LIBRARY})
- else(LZ4_FOUND)
- file(GLOB LZ4_FILES ${LZ4_LOCAL_DIR}/*.c)
- set(SOURCES ${SOURCES} ${LZ4_FILES})
- endif(LZ4_FOUND)
+ set(LIBS ${LIBS} "CONAN_PKG::lz4")
endif(NOT DEACTIVATE_LZ4)

if(NOT DEACTIVATE_SNAPPY)
- if(SNAPPY_FOUND)
- set(LIBS ${LIBS} ${SNAPPY_LIBRARY})
- else(SNAPPY_FOUND)
- file(GLOB SNAPPY_FILES ${SNAPPY_LOCAL_DIR}/*.cc)
- set(SOURCES ${SOURCES} ${SNAPPY_FILES})
- endif(SNAPPY_FOUND)
+ set(LIBS ${LIBS} "CONAN_PKG::snappy")
endif(NOT DEACTIVATE_SNAPPY)

if(NOT DEACTIVATE_ZLIB)
- if(ZLIB_FOUND)
- set(LIBS ${LIBS} ${ZLIB_LIBRARY})
- else(ZLIB_FOUND)
- file(GLOB ZLIB_FILES ${ZLIB_LOCAL_DIR}/*.c)
- set(SOURCES ${SOURCES} ${ZLIB_FILES})
- endif(ZLIB_FOUND)
+ set(LIBS ${LIBS} "CONAN_PKG::zlib")
endif(NOT DEACTIVATE_ZLIB)

if (NOT DEACTIVATE_ZSTD)
- if (ZSTD_FOUND)
- set(LIBS ${LIBS} ${ZSTD_LIBRARY})
- else (ZSTD_FOUND)
- file(GLOB ZSTD_FILES
- ${ZSTD_LOCAL_DIR}/common/*.c
- ${ZSTD_LOCAL_DIR}/compress/*.c
- ${ZSTD_LOCAL_DIR}/decompress/*.c)
- set(SOURCES ${SOURCES} ${ZSTD_FILES})
- endif (ZSTD_FOUND)
+ set(LIBS ${LIBS} "CONAN_PKG::zstd")
endif (NOT DEACTIVATE_ZSTD)


@@ -193,6 +135,9 @@ endif()

if (BUILD_SHARED)
target_link_libraries(blosc_shared ${LIBS})
+ if(NOT DEACTIVATE_SNAPPY)
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
+ set_target_properties(blosc_shared PROPERTIES LINKER_LANGUAGE CXX)
+ endif()
target_include_directories(blosc_shared PUBLIC ${BLOSC_INCLUDE_DIRS})
endif()

@@ -212,7 +157,6 @@ if(BUILD_STATIC)
endif(BUILD_STATIC)

# install
-if(BLOSC_INSTALL)
install(FILES blosc.h blosc-export.h DESTINATION include COMPONENT DEV)
if(BUILD_SHARED)
install(TARGETS blosc_shared LIBRARY DESTINATION ${lib_dir} ARCHIVE DESTINATION ${lib_dir} RUNTIME DESTINATION bin COMPONENT LIB)
@@ -220,4 +164,3 @@ if(BLOSC_INSTALL)
if(BUILD_STATIC)
install(TARGETS blosc_static LIBRARY DESTINATION ${lib_dir} ARCHIVE DESTINATION ${lib_dir} RUNTIME DESTINATION bin COMPONENT DEV)
endif(BUILD_STATIC)
-endif(BLOSC_INSTALL)
9 changes: 9 additions & 0 deletions recipes/c-blosc/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.0.2)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) # only required if both Blosc and Snappy are static
17 changes: 17 additions & 0 deletions recipes/c-blosc/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
Loading