xref: /aosp_15_r20/external/sandboxed-api/contrib/pffft/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(pffft CXX C)
18include(CTest)
19
20set(CMAKE_CXX_STANDARD 17)
21set(CMAKE_CXX_STANDARD_REQUIRED True)
22
23if(NOT TARGET sapi::sapi)
24  set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
25  add_subdirectory("${SAPI_ROOT}"
26                   "${CMAKE_BINARY_DIR}/sandboxed-api-build"
27                   EXCLUDE_FROM_ALL)
28endif()
29
30include(CheckLibraryExists)
31
32FetchContent_Declare(pffft
33  GIT_REPOSITORY https://bitbucket.org/jpommier/pffft.git
34  GIT_TAG        988259a41d1522047a9420e6265a6ba8289c1654 # 2021-12-02
35)
36FetchContent_MakeAvailable(pffft)
37
38add_library(pffft STATIC
39  "${pffft_SOURCE_DIR}/pffft.c"
40  "${pffft_SOURCE_DIR}/pffft.h"
41  "${pffft_SOURCE_DIR}/fftpack.c"
42  "${pffft_SOURCE_DIR}/fftpack.h"
43)
44
45add_executable(pffft_main
46  "${pffft_SOURCE_DIR}/test_pffft.c"
47)
48target_link_libraries(pffft_main PRIVATE
49  pffft
50)
51
52check_library_exists(m sin "" _sapi_HAVE_LIBM)
53if(_sapi_HAVE_LIBM)
54  target_link_libraries(pffft PUBLIC
55    m
56  )
57endif()
58
59add_sapi_library(pffft_sapi
60  FUNCTIONS pffft_new_setup
61            pffft_destroy_setup
62            pffft_transform
63            pffft_transform_ordered
64            pffft_zreorder
65            pffft_zconvolve_accumulate
66            pffft_aligned_malloc
67            pffft_aligned_free
68            pffft_simd_size
69            cffti
70            cfftf
71            cfftb
72            rffti
73            rfftf
74            rfftb
75            cosqi
76            cosqf
77            cosqb
78            costi
79            cost
80            sinqi
81            sinqb
82            sinqf
83            sinti
84            sint
85
86  INPUTS "${pffft_SOURCE_DIR}/pffft.h"
87         "${pffft_SOURCE_DIR}/fftpack.h"
88  LIBRARY pffft
89  LIBRARY_NAME Pffft
90
91  NAMESPACE ""
92)
93add_library(sapi_contrib::pffft ALIAS pffft_sapi)
94target_include_directories(pffft_sapi INTERFACE
95  "${PROJECT_BINARY_DIR}"
96  "${SAPI_SOURCE_DIR}"
97)
98
99add_executable(pffft_sandboxed
100  main_pffft_sandboxed.cc
101)
102target_link_libraries(pffft_sandboxed PRIVATE
103  absl::flags
104  absl::flags_parse
105  absl::log
106  absl::log_globals
107  absl::log_initialize
108  sapi_contrib::pffft
109  sapi::sapi
110)
111