xref: /aosp_15_r20/external/sandboxed-api/contrib/zopfli/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_zopfli CXX)
18include(CTest)
19
20set(CMAKE_CXX_STANDARD 17)
21set(CMAKE_CXX_STANDARD_REQUIRED True)
22
23if(NOT TARGET sapi::sapi)
24  set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
25  add_subdirectory("${SAPI_ROOT}"
26                   "${CMAKE_BINARY_DIR}/sandboxed-api-build"
27                   EXCLUDE_FROM_ALL)
28endif()
29
30FetchContent_Declare(zopfli
31  GIT_REPOSITORY https://github.com/google/zopfli.git
32  GIT_TAG 831773bc28e318b91a3255fa12c9fcde1606058b
33)
34FetchContent_MakeAvailable(zopfli)
35
36add_subdirectory(wrapper)
37
38add_sapi_library(
39  sapi_zopfli
40
41  FUNCTIONS
42    ZopfliInitOptions
43
44    ZopfliCompress
45
46    ZopfliDeflate
47    ZopfliZlibCompress
48    ZopfliGzipCompress
49
50    ZopfliCompressFD
51  INPUTS
52    "${zopfli_SOURCE_DIR}/src/zopfli/deflate.h"
53    "${zopfli_SOURCE_DIR}/src/zopfli/gzip_container.h"
54    "${zopfli_SOURCE_DIR}/src/zopfli/zlib_container.h"
55    wrapper/wrapper_zopfli.h
56
57  LIBRARY wrapper_zopfli
58  LIBRARY_NAME Zopfli
59  NAMESPACE ""
60)
61add_library(sapi_contrib::zopfli ALIAS sapi_zopfli)
62target_include_directories(sapi_zopfli INTERFACE
63  "${PROJECT_BINARY_DIR}"
64  "${SAPI_SOURCE_DIR}"
65)
66
67if(SAPI_BUILD_EXAMPLES)
68  add_subdirectory(example)
69endif()
70
71if(BUILD_TESTING AND SAPI_BUILD_TESTING)
72  add_subdirectory(test)
73endif()
74