2022-02-09 20:56:47 +08:00
|
|
|
# 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.
|
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
cmake_minimum_required(VERSION 3.13..2.22)
|
2022-02-09 20:56:47 +08:00
|
|
|
|
|
|
|
project(sapi_zip CXX)
|
2022-04-21 16:14:48 +08:00
|
|
|
include(CTest)
|
2022-06-14 20:41:29 +08:00
|
|
|
include(GoogleTest)
|
2022-02-09 20:56:47 +08:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2022-04-29 17:13:32 +08:00
|
|
|
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)
|
2022-02-09 20:56:47 +08:00
|
|
|
FetchContent_Declare(libzip
|
|
|
|
GIT_REPOSITORY https://github.com/nih-at/libzip/
|
2022-06-14 20:41:29 +08:00
|
|
|
GIT_TAG e076a6fd97663025785a64cc8160aa633220be61 # 2022-06-08
|
2022-02-09 20:56:47 +08:00
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(libzip)
|
|
|
|
|
|
|
|
add_subdirectory(wrapper)
|
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
add_sapi_library(sapi_zip
|
|
|
|
FUNCTIONS zip_open_from_source
|
|
|
|
zip_close
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
zip_get_name
|
|
|
|
zip_get_num_entries
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
zip_stat
|
|
|
|
zip_stat_index
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
zip_fopen
|
|
|
|
zip_fopen_index
|
|
|
|
zip_fclose
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
zip_fread
|
|
|
|
zip_fseek
|
|
|
|
zip_ftell
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
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
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
zip_file_add
|
|
|
|
zip_file_replace
|
|
|
|
zip_delete
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
zip_strerror
|
|
|
|
INPUTS "${libzip_BINARY_DIR}/zipconf.h"
|
|
|
|
"${libzip_SOURCE_DIR}/lib/zip.h"
|
|
|
|
wrapper/wrapper_zip.h
|
2022-02-09 20:56:47 +08:00
|
|
|
|
2022-06-14 20:41:29 +08:00
|
|
|
LIBRARY libzip::zip
|
2022-02-09 20:56:47 +08:00
|
|
|
LIBRARY_NAME Zip
|
|
|
|
NAMESPACE ""
|
|
|
|
)
|
|
|
|
add_library(sapi_contrib::libzip ALIAS sapi_zip)
|
2022-06-14 20:41:29 +08:00
|
|
|
target_include_directories(sapi_zip PUBLIC
|
2022-02-09 20:56:47 +08:00
|
|
|
"${PROJECT_BINARY_DIR}"
|
2022-06-14 20:41:29 +08:00
|
|
|
"${libzip_BINARY_DIR}"
|
|
|
|
)
|
|
|
|
target_sources(sapi_zip PUBLIC
|
|
|
|
sandboxed.h
|
|
|
|
utils/utils_zip.cc
|
|
|
|
utils/utils_zip.h
|
2022-02-09 20:56:47 +08:00
|
|
|
)
|
|
|
|
|
2022-04-21 16:17:08 +08:00
|
|
|
if(SAPI_BUILD_EXAMPLES)
|
2022-02-09 20:56:47 +08:00
|
|
|
add_subdirectory(example)
|
|
|
|
endif()
|
|
|
|
|
2022-04-21 16:17:08 +08:00
|
|
|
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
|
2022-02-09 20:56:47 +08:00
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|