1#
2# Copyright (C) 2021 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may not
5# use this file except in compliance with the License. You may obtain a copy of
6# the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations under
14# the License.
15#
16
17cmake_minimum_required(VERSION 3.22.1)
18
19project(compose_ui_inspection)
20
21set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
22
23add_library(
24        compose_inspection_jni SHARED
25        lambda_location_java_jni.cpp)
26
27find_library(android-lib android)
28find_library(log-lib log)
29
30# jvmti.h isn't distributed with android ndk, so we need to compile against jdk's one.
31# Unfortunately we can't simply use it, because of "include "jni.h"" in it.
32# Include with quotes priorities file's directory, so it resolves jdk's jni instead of ndk's one.
33# To avoid jdk's jni jvmti.h is copied in another folder.
34configure_file($ENV{JAVA_HOME}/include/jvmti.h external_jvmti/jvmti.h COPYONLY)
35
36target_include_directories(compose_inspection_jni
37        PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external_jvmti)
38target_link_libraries(compose_inspection_jni ${android-lib} ${log-lib})
39target_link_options(compose_inspection_jni PRIVATE "-Wl,-z,max-page-size=16384")
40