xref: /aosp_15_r20/external/sandboxed-api/oss-internship-2020/libpng/CMakeLists.txt (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1*ec63e07aSXin Li# Copyright 2020 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.12)
16*ec63e07aSXin Li
17*ec63e07aSXin Liproject(sandboxed_libpng CXX)
18*ec63e07aSXin Li
19*ec63e07aSXin Liset(CMAKE_CXX_STANDARD 17)
20*ec63e07aSXin Liset(CMAKE_CXX_STANDARD_REQUIRED True)
21*ec63e07aSXin Li
22*ec63e07aSXin Li# Set this on the command-line
23*ec63e07aSXin Liset(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
24*ec63e07aSXin Li# To obtain a full SAPI_ROOT check out its source separately:
25*ec63e07aSXin Li#   git clone https://github.com/google/sandboxed-api.git /path/to/sapi_root
26*ec63e07aSXin Li# Then configure:
27*ec63e07aSXin Li#   mkdir -p build && cd build
28*ec63e07aSXin Li#   cmake .. -G Ninja -DSAPI_ROOT=/path/to/sapi_root
29*ec63e07aSXin Li
30*ec63e07aSXin Lioption(LIBPNG_SAPI_BUILD_EXAMPLES "" OFF)
31*ec63e07aSXin Lioption(LIBPNG_SAPI_BUILD_TESTING "" OFF)
32*ec63e07aSXin Li
33*ec63e07aSXin Liset(SAPI_BUILD_EXAMPLES ${LIBPNG_SAPI_BUILD_EXAMPLES} CACHE BOOL "" FORCE)
34*ec63e07aSXin Liset(SAPI_BUILD_TESTING ${LIBPNG_SAPI_BUILD_TESTING} CACHE BOOL "" FORCE)
35*ec63e07aSXin Li
36*ec63e07aSXin Liset (CMAKE_FIND_LIBRARY_SUFFIXES .a $ {CMAKE_FIND_LIBRARY_SUFFIXES})
37*ec63e07aSXin Lifind_package(PNG REQUIRED)
38*ec63e07aSXin Lilist(GET PNG_INCLUDE_DIRS 0 PNG_INCLUDE_DIR)
39*ec63e07aSXin Li
40*ec63e07aSXin Liadd_subdirectory(wrapper)
41*ec63e07aSXin Li
42*ec63e07aSXin Liadd_subdirectory(
43*ec63e07aSXin Li  "${SAPI_ROOT}"
44*ec63e07aSXin Li  "${CMAKE_BINARY_DIR}/sandboxed-api-build"
45*ec63e07aSXin Li  # Omit this to have the full Sandboxed API in IDE
46*ec63e07aSXin Li  EXCLUDE_FROM_ALL
47*ec63e07aSXin Li)
48*ec63e07aSXin Li
49*ec63e07aSXin Liadd_sapi_library(libpng_sapi
50*ec63e07aSXin Li  # List of functions that we want to include in the
51*ec63e07aSXin Li  # generated sandboxed API class
52*ec63e07aSXin Li
53*ec63e07aSXin Li  FUNCTIONS png_image_free
54*ec63e07aSXin Li            png_image_finish_read
55*ec63e07aSXin Li            png_image_write_to_file
56*ec63e07aSXin Li            png_image_begin_read_from_file
57*ec63e07aSXin Li
58*ec63e07aSXin Li            png_get_rowbytes
59*ec63e07aSXin Li            png_get_bit_depth
60*ec63e07aSXin Li            png_get_color_type
61*ec63e07aSXin Li            png_get_image_width
62*ec63e07aSXin Li            png_get_image_height
63*ec63e07aSXin Li
64*ec63e07aSXin Li            png_set_IHDR
65*ec63e07aSXin Li            png_set_sig_bytes
66*ec63e07aSXin Li            png_set_interlace_handling
67*ec63e07aSXin Li
68*ec63e07aSXin Li            png_read_info
69*ec63e07aSXin Li            png_read_image_wrapper
70*ec63e07aSXin Li            png_read_update_info
71*ec63e07aSXin Li
72*ec63e07aSXin Li            png_write_end
73*ec63e07aSXin Li            png_write_info
74*ec63e07aSXin Li            png_write_image_wrapper
75*ec63e07aSXin Li
76*ec63e07aSXin Li            png_create_info_struct
77*ec63e07aSXin Li            png_create_read_struct_wrapper
78*ec63e07aSXin Li            png_create_write_struct_wrapper
79*ec63e07aSXin Li
80*ec63e07aSXin Li            png_init_io_wrapper
81*ec63e07aSXin Li
82*ec63e07aSXin Li            png_sig_cmp
83*ec63e07aSXin Li
84*ec63e07aSXin Li            png_fread
85*ec63e07aSXin Li            png_fdopen
86*ec63e07aSXin Li            png_rewind
87*ec63e07aSXin Li            png_fclose
88*ec63e07aSXin Li
89*ec63e07aSXin Li            png_setjmp
90*ec63e07aSXin Li
91*ec63e07aSXin Li  INPUTS "${PNG_INCLUDE_DIR}/png.h"
92*ec63e07aSXin Li         wrapper/func.h
93*ec63e07aSXin Li                          # Header files or .cc files that should be parsed
94*ec63e07aSXin Li  LIBRARY wrapper
95*ec63e07aSXin Li                          # Library dependency from the add_library() above
96*ec63e07aSXin Li  LIBRARY_NAME LibPNG     # Name prefix for the generated header. Will be
97*ec63e07aSXin Li                          # suffixed with "Api" and "Sandbox" as needed.
98*ec63e07aSXin Li  NAMESPACE ""            # Optional C++ namespace to wrap the generated code
99*ec63e07aSXin Li)
100*ec63e07aSXin Li
101*ec63e07aSXin Litarget_include_directories(libpng_sapi INTERFACE
102*ec63e07aSXin Li  "${PROJECT_BINARY_DIR}"  # To find the generated SAPI header
103*ec63e07aSXin Li)
104*ec63e07aSXin Li
105*ec63e07aSXin Liif (LIBPNG_SAPI_BUILD_EXAMPLES)
106*ec63e07aSXin Li  add_subdirectory(examples)
107*ec63e07aSXin Liendif()
108*ec63e07aSXin Li
109*ec63e07aSXin Liif (LIBPNG_SAPI_BUILD_TESTING)
110*ec63e07aSXin Li  add_subdirectory(tests)
111*ec63e07aSXin Liendif()
112*ec63e07aSXin Li
113