1*ec63e07aSXin Li# Copyright 2022 Google LLC 2*ec63e07aSXin Li# 3*ec63e07aSXin Li# Licensed under the Apache License, Version 2.0 (the "License"); 4*ec63e07aSXin Li# you may not use this file except in compliance with the License. 5*ec63e07aSXin Li# You may obtain a copy of the License at 6*ec63e07aSXin Li# 7*ec63e07aSXin Li# https://www.apache.org/licenses/LICENSE-2.0 8*ec63e07aSXin Li# 9*ec63e07aSXin Li# Unless required by applicable law or agreed to in writing, software 10*ec63e07aSXin Li# distributed under the License is distributed on an "AS IS" BASIS, 11*ec63e07aSXin Li# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*ec63e07aSXin Li# See the License for the specific language governing permissions and 13*ec63e07aSXin Li# limitations under the License. 14*ec63e07aSXin Li 15*ec63e07aSXin Licmake_minimum_required(VERSION 3.13..3.26) 16*ec63e07aSXin Li 17*ec63e07aSXin Liproject(sapi_brotli CXX) 18*ec63e07aSXin Liinclude(CTest) 19*ec63e07aSXin Liinclude(GoogleTest) 20*ec63e07aSXin Li 21*ec63e07aSXin Liset(CMAKE_CXX_STANDARD 17) 22*ec63e07aSXin Liset(CMAKE_CXX_STANDARD_REQUIRED True) 23*ec63e07aSXin Li 24*ec63e07aSXin Liif(NOT TARGET sapi::sapi) 25*ec63e07aSXin Li set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree") 26*ec63e07aSXin Li add_subdirectory("${SAPI_ROOT}" 27*ec63e07aSXin Li "${CMAKE_BINARY_DIR}/sandboxed-api-build" 28*ec63e07aSXin Li EXCLUDE_FROM_ALL) 29*ec63e07aSXin Liendif() 30*ec63e07aSXin Li 31*ec63e07aSXin LiFetchContent_Declare(libbrotli 32*ec63e07aSXin Li GIT_REPOSITORY https://github.com/google/brotli.git 33*ec63e07aSXin Li GIT_TAG f4153a09f87cbb9c826d8fc12c74642bb2d879ea # 2022-01-10 34*ec63e07aSXin Li) 35*ec63e07aSXin LiFetchContent_MakeAvailable(libbrotli) 36*ec63e07aSXin Li 37*ec63e07aSXin Liset(brotli_INCLUDE_DIR "${brotli_SOURCE_DIR}/c/include") 38*ec63e07aSXin Liconfigure_file(brotli.gen.h.in brotli.gen.h) 39*ec63e07aSXin Li 40*ec63e07aSXin Liadd_library(brotli_static STATIC 41*ec63e07aSXin Li "${SAPI_BINARY_DIR}/sapi_force_cxx_linkage.cc" 42*ec63e07aSXin Li $<TARGET_OBJECTS:brotlicommon-static> 43*ec63e07aSXin Li $<TARGET_OBJECTS:brotlidec-static> 44*ec63e07aSXin Li $<TARGET_OBJECTS:brotlienc-static> 45*ec63e07aSXin Li) 46*ec63e07aSXin Li 47*ec63e07aSXin Liadd_sapi_library(sapi_brotli 48*ec63e07aSXin Li FUNCTIONS BrotliDecoderCreateInstance 49*ec63e07aSXin Li BrotliDecoderSetParameter 50*ec63e07aSXin Li BrotliDecoderDecompressStream 51*ec63e07aSXin Li BrotliDecoderTakeOutput 52*ec63e07aSXin Li BrotliDecoderDestroyInstance 53*ec63e07aSXin Li 54*ec63e07aSXin Li BrotliEncoderCreateInstance 55*ec63e07aSXin Li BrotliEncoderCompressStream 56*ec63e07aSXin Li BrotliEncoderTakeOutput 57*ec63e07aSXin Li BrotliEncoderSetParameter 58*ec63e07aSXin Li BrotliEncoderDestroyInstance 59*ec63e07aSXin Li 60*ec63e07aSXin Li INPUTS "${CMAKE_BINARY_DIR}/brotli.gen.h" 61*ec63e07aSXin Li 62*ec63e07aSXin Li LIBRARY brotli_static 63*ec63e07aSXin Li LIBRARY_NAME Brotli 64*ec63e07aSXin Li NAMESPACE "" 65*ec63e07aSXin Li) 66*ec63e07aSXin Liadd_library(sapi_contrib::brotli ALIAS sapi_brotli) 67*ec63e07aSXin Litarget_include_directories(sapi_brotli INTERFACE 68*ec63e07aSXin Li "${PROJECT_BINARY_DIR}" 69*ec63e07aSXin Li "${SAPI_SOURCE_DIR}" 70*ec63e07aSXin Li) 71*ec63e07aSXin Li 72*ec63e07aSXin Liif(SAPI_BUILD_EXAMPLES) 73*ec63e07aSXin Li add_subdirectory(example) 74*ec63e07aSXin Liendif() 75*ec63e07aSXin Li 76*ec63e07aSXin Liif(BUILD_TESTING AND SAPI_BUILD_TESTING) 77*ec63e07aSXin Li add_subdirectory(test) 78*ec63e07aSXin Liendif() 79