Appendix B: Example CMakeLists.txt
1
#
2
# Copyright (C) The Android Open Source Project
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of 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,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
#
16
17
cmake_minimum_required(VERSION 3.4.1)
18
19
# configure import libs
20
21
# build native_app_glue as a static lib
22
add_library(native_app_glue STATIC
23
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
24
25
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -fno-exceptions -fno-rtti")
26
27
# build the ndk-helper library
28
set(ndk_helper_dir ../../../../common/ndk_helper)
29
add_subdirectory(${ndk_helper_dir} ndk_helper)
30
31
# Export ANativeActivity_onCreate(),
32
# Refer to: https://github.com/android-ndk/ndk/issues/381.
33
set(CMAKE_SHARED_LINKER_FLAGS
34
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
35
36
# now build app's shared lib
37
add_library(MoreTeapotsNativeActivity SHARED
38
LeiaJNIDisplayParameters.cpp
39
MoreTeapotsNativeActivity.cpp
40
41
MoreTeapotsRenderer.cpp)
42
43
target_include_directories(MoreTeapotsNativeActivity PRIVATE
44
${ANDROID_NDK}/sources/android/cpufeatures
45
${ANDROID_NDK}/sources/android/native_app_glue
46
${ndk_helper_dir})
47
48
# add lib dependencies
49
target_link_libraries(MoreTeapotsNativeActivity
50
android
51
native_app_glue
52
atomic
53
EGL
54
GLESv2
55
log
56
ndk-helper)
57
58
set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../distribution)
59
add_library(lib_leia_sdk STATIC IMPORTED)
60
set_target_properties(lib_leia_sdk PROPERTIES IMPORTED_LOCATION
61
${distribution_DIR}/leia_sdk/lib/${ANDROID_ABI}/libleiasdk.so)
62
target_include_directories(MoreTeapotsNativeActivity PRIVATE
63
${distribution_DIR}/leia_sdk/include)
64
target_link_libraries(MoreTeapotsNativeActivity
65
lib_leia_sdk)
Copied!
Last modified 2yr ago
Copy link