xref: /aosp_15_r20/external/sandboxed-api/contrib/libtiff/CMakeLists.txt (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1# Copyright 2020 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(sandboxed_libtiff CXX)
18include(CTest)
19include(GoogleTest)
20
21set(CMAKE_CXX_STANDARD 17)
22set(CMAKE_CXX_STANDARD_REQUIRED True)
23
24if(NOT TARGET sapi::sapi)
25  set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
26  add_subdirectory("${SAPI_ROOT}"
27                   "${CMAKE_BINARY_DIR}/sandboxed-api-build"
28                   EXCLUDE_FROM_ALL)
29endif()
30
31FetchContent_Declare(libtiff
32  GIT_REPOSITORY https://gitlab.com/libtiff/libtiff
33  GIT_TAG        v4.4.0  # 2022-05-20
34)
35FetchContent_MakeAvailable(libtiff)
36
37add_subdirectory(wrapper)
38
39add_sapi_library(tiff_sapi
40  # List of functions that we want to include in the
41  # generated sandboxed API class
42  FUNCTIONS TIFFOpen
43            TIFFClose
44
45            TIFFGetField1
46            TIFFGetField2
47            TIFFGetField3
48
49            TIFFSetFieldUChar1
50            TIFFSetFieldUChar2
51            TIFFSetFieldUChar3
52            TIFFSetFieldSChar1
53            TIFFSetFieldSChar2
54            TIFFSetFieldSChar3
55            TIFFSetFieldU1
56            TIFFSetFieldU2
57            TIFFSetFieldU3
58            TIFFSetFieldS1
59            TIFFSetFieldS2
60            TIFFSetFieldS3
61            TIFFSetFieldUShort1
62            TIFFSetFieldUShort2
63            TIFFSetFieldUShort3
64            TIFFSetFieldSShort1
65            TIFFSetFieldSShort2
66            TIFFSetFieldSShort3
67            TIFFSetFieldULLong1
68            TIFFSetFieldULLong2
69            TIFFSetFieldULLong3
70            TIFFSetFieldSLLong1
71            TIFFSetFieldSLLong2
72            TIFFSetFieldSLLong3
73            TIFFSetFieldFloat1
74            TIFFSetFieldFloat2
75            TIFFSetFieldFloat3
76            TIFFSetFieldDouble1
77            TIFFSetFieldDouble2
78            TIFFSetFieldDouble3
79
80            TIFFReadRGBATile
81            TIFFReadRGBATileExt
82            TIFFReadEncodedTile
83            TIFFReadEncodedStrip
84            TIFFReadFromUserBuffer
85
86            TIFFTileSize
87            TIFFSetDirectory
88            TIFFFreeDirectory
89            TIFFCreateDirectory
90
91            TIFFForceStrileArrayWriting
92            TIFFDeferStrileArrayWriting
93
94            TIFFWriteCheck
95            TIFFWriteScanline
96            TIFFWriteDirectory
97            TIFFWriteEncodedTile
98            TIFFWriteEncodedStrip
99
100            TIFFGetStrileOffsetWithErr
101            TIFFGetStrileByteCountWithErr
102
103            TIFFCreateEXIFDirectory
104            TIFFWriteCustomDirectory
105
106  INPUTS "${libtiff_SOURCE_DIR}/libtiff/tiffio.h"
107         wrapper/func.h
108                          # Header files or .cc files that should be parsed
109  LIBRARY wrapped_tiff    # Library dependency from the add_library() above
110  LIBRARY_NAME Tiff       # Name prefix for the generated header. Will be
111                          # suffixed with "Api" and "Sandbox" as needed.
112  NAMESPACE ""            # Optional C++ namespace to wrap the generated code
113)
114add_library(sapi_contrib::libtiff ALIAS tiff_sapi)
115target_include_directories(tiff_sapi INTERFACE
116  "${PROJECT_BINARY_DIR}"  # To find the generated SAPI header
117)
118
119if (SAPI_BUILD_EXAMPLES)
120  add_subdirectory(example)
121endif()
122
123if (BUILD_TESTING AND SAPI_BUILD_TESTING)
124  add_subdirectory(test)
125endif()
126