1# Copyright (C) 2021 The Android Open Source Project 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# http://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 15# For more information about using CMake with Android Studio, read the 16# documentation: https://d.android.com/studio/projects/add-native-code.html 17 18# Sets the minimum version of CMake required to build the native library. 19 20cmake_minimum_required(VERSION 3.10.2) 21 22# Declares and names the project. 23 24project("RenderScript Toolkit") 25 26set(can_use_assembler TRUE) 27enable_language(ASM) 28add_definitions(-v -DANDROID -DOC_ARM_ASM) 29 30set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}") 31 32#message( STATUS "Architecture: ${CMAKE_SYSTEM_PROCESSOR}" ) 33#message( STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") 34#message( STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") 35#message( STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") 36#set(CMAKE_VERBOSE_MAKEFILE on) 37#set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-limit-debug-info -g") 38#set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Os -DNDEBUG") 39 40#TODO check that the definitions are all needed. Do they have impact outside of our code? 41if(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a) 42 add_definitions(-DARCH_ARM_USE_INTRINSICS -DARCH_ARM_HAVE_VFP) 43 set(ASM_SOURCES 44 Blend_neon.S 45 Blur_neon.S 46 ColorMatrix_neon.S 47 Convolve_neon.S 48 Lut3d_neon.S 49 Resize_neon.S 50 YuvToRgb_neon.S) 51endif() 52 53if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) 54 add_definitions(-DARCH_ARM_USE_INTRINSICS -DARCH_ARM64_USE_INTRINSICS -DARCH_ARM64_HAVE_NEON) 55 set(ASM_SOURCES 56 Blend_advsimd.S 57 Blur_advsimd.S 58 ColorMatrix_advsimd.S 59 Convolve_advsimd.S 60 Lut3d_advsimd.S 61 Resize_advsimd.S 62 YuvToRgb_advsimd.S) 63endif() 64# TODO add also for x86 65 66# Creates and names a library, sets it as either STATIC 67# or SHARED, and provides the relative paths to its source code. 68# You can define multiple libraries, and CMake builds them for you. 69# Gradle automatically packages shared libraries with your APK. 70 71add_library(# Sets the name of the library. 72 renderscript-toolkit 73 # Sets the library as a shared library. 74 SHARED 75 # Provides a relative path to your source file(s). 76 Blend.cpp 77 Blur.cpp 78 ColorMatrix.cpp 79 Convolve3x3.cpp 80 Convolve5x5.cpp 81 Histogram.cpp 82 JniEntryPoints.cpp 83 Lut.cpp 84 Lut3d.cpp 85 RenderScriptToolkit.cpp 86 Resize.cpp 87 TaskProcessor.cpp 88 Utils.cpp 89 YuvToRgb.cpp 90 ${ASM_SOURCES}) 91 92# Searches for a specified prebuilt library and stores the path as a 93# variable. Because CMake includes system libraries in the search path by 94# default, you only need to specify the name of the public NDK library 95# you want to add. CMake verifies that the library exists before 96# completing its build. 97 98find_library(# Sets the name of the path variable. 99 log-lib 100 # Specifies the name of the NDK library that 101 # you want CMake to locate. 102 log ) 103 104# Specifies libraries CMake should link to your target library. You 105# can link multiple libraries, such as libraries you define in this 106# build script, prebuilt third-party libraries, or system libraries. 107 108target_link_libraries(# Specifies the target library. 109 renderscript-toolkit 110 111 cpufeatures 112 jnigraphics 113 # Links the target library to the log library 114 # included in the NDK. 115 ${log-lib} ) 116 117include(AndroidNdkModules) 118android_ndk_import_module_cpufeatures() 119