xref: /aosp_15_r20/external/sandboxed-api/contrib/c-blosc/CMakeLists.txt (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1# Copyright 2022 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15cmake_minimum_required(VERSION 3.13..3.26)
16
17project(sapi_blosc CXX)
18include(CTest)
19include(GoogleTest)
20
21set(CMAKE_CXX_STANDARD 17)
22set(CMAKE_CXX_STANDARD_REQUIRED True)
23
24if(NOT TARGET sapi::sapi)
25  set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
26  add_subdirectory("${SAPI_ROOT}"
27                   "${CMAKE_BINARY_DIR}/sandboxed-api-build"
28                   EXCLUDE_FROM_ALL)
29endif()
30
31FetchContent_Declare(libblosc
32  GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
33  GIT_TAG        ad6361f0151f830efb5ae113211c3559ab969886 # 2022-05-31
34)
35set(HIDE_SYMBOLS OFF CACHE BOOL "" FORCE)
36set(BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
37set(BUILD_FUZZERS OFF CACHE BOOL "" FORCE)
38set(BUILD_TESTS OFF CACHE BOOL "" FORCE)
39FetchContent_MakeAvailable(libblosc)
40
41add_sapi_library(sapi_blosc
42  FUNCTIONS blosc_init
43            blosc_destroy
44
45            blosc_compress
46            blosc_decompress
47
48            blosc_get_nthreads
49            blosc_set_nthreads
50
51            blosc_get_compressor
52            blosc_set_compressor
53
54            blosc_list_compressors
55
56            blosc_get_version_string
57
58            blosc_get_blocksize
59            blosc_set_blocksize
60
61            blosc_set_splitmode
62
63            blosc_cbuffer_sizes
64            blosc_cbuffer_validate
65            blosc_cbuffer_versions
66  INPUTS "${libblosc_SOURCE_DIR}/blosc/blosc.h"
67  LIBRARY blosc_static
68  LIBRARY_NAME Cblosc
69  NAMESPACE ""
70)
71add_library(sapi_contrib::blosc ALIAS sapi_blosc)
72target_include_directories(sapi_blosc INTERFACE
73  "${PROJECT_BINARY_DIR}"
74)
75
76if (SAPI_BUILD_EXAMPLES)
77  add_subdirectory(example)
78endif()
79
80if (BUILD_TESTING AND SAPI_BUILD_TESTING)
81  add_subdirectory(test)
82endif()
83