sandboxed-api/contrib/libzip/CMakeLists.txt
Christian Blichmann 51799f99ae Introduce a transitional logging utility library
Instead of calling `google::InitGoogleLogging()` directly, introduce an
indirection via a new utility library. After this change, Sandboxed API
should consistently use `sapi::InitLogging()` everywhere.

For now, `sapi::InitLogging()` simply calls its glog equivalent. However,
this enables us to migrate away from the gflags dependency and use Abseil
flags. Once a follow-up change lands, `sapi::InitLogging()` will instead
initialize the google logging library with flags defined from Aseil.

Later still, once Abseil releases logging, we can then drop the glog
dependency entirely.

PiperOrigin-RevId: 445363592
Change-Id: Ia23a7dc88b8ffe65a422ea4d5233bba7bdd1303a
2022-04-29 02:14:06 -07:00

102 lines
2.3 KiB
CMake

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.13)
project(sapi_zip CXX)
include(CTest)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(NOT TARGET sapi::sapi)
set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
add_subdirectory("${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
EXCLUDE_FROM_ALL)
endif()
set(BUILD_SHARED_LIBS OFF)
set(BUILD_TOOLS OFF CACHE BOOL "" FORCE)
set(BUILD_REGRESS OFF CACHE BOOL "" FORCE)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_DOC OFF CACHE BOOL "" FORCE)
set(LIBZIP_DO_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(libzip
GIT_REPOSITORY https://github.com/nih-at/libzip/
GIT_TAG 34b13ca4e887a5aba050015e3a179069643f4e76
)
FetchContent_MakeAvailable(libzip)
include_directories("${libzip_BINARY_DIR}")
add_subdirectory(wrapper)
add_sapi_library(
sapi_zip
FUNCTIONS
zip_open_from_source
zip_close
zip_get_name
zip_get_num_entries
zip_stat
zip_stat_index
zip_fopen
zip_fopen_index
zip_fclose
zip_fread
zip_fseek
zip_ftell
zip_source_buffer
zip_read_fd_to_source
zip_source_to_fd
zip_source_filefd
zip_source_filefd_create
zip_source_keep
zip_source_free
zip_file_add
zip_file_replace
zip_delete
zip_strerror
INPUTS
"${libzip_BINARY_DIR}/zipconf.h"
"${libzip_SOURCE_DIR}/lib/zip.h"
"wrapper/wrapper_zip.h"
LIBRARY wrapper_zip
LIBRARY_NAME Zip
NAMESPACE ""
)
add_library(sapi_contrib::libzip ALIAS sapi_zip)
target_include_directories(sapi_zip INTERFACE
"${PROJECT_BINARY_DIR}"
"${SAPI_SOURCE_DIR}"
)
if(SAPI_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_subdirectory(test)
endif()