|
14 | 14 | # limitations under the License. |
15 | 15 | # |
16 | 16 |
|
17 | | -cmake_minimum_required(VERSION 3.22.1) |
| 17 | +cmake_minimum_required(VERSION 4.1.0) |
18 | 18 | project(NativeActivity LANGUAGES C CXX) |
19 | 19 |
|
20 | | -# build native_app_glue as a static lib |
21 | | -set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}") |
22 | | -add_library(native_app_glue STATIC |
23 | | - ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) |
24 | | - |
25 | | -# now build app's shared lib |
26 | | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") |
| 20 | +include(AppLibrary) |
27 | 21 |
|
28 | | -# Export ANativeActivity_onCreate(), |
29 | | -# Refer to: https://github.com/android-ndk/ndk/issues/381. |
30 | | -set(CMAKE_SHARED_LINKER_FLAGS |
31 | | - "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") |
| 22 | +add_library(native_app_glue STATIC |
| 23 | + ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c |
| 24 | +) |
32 | 25 |
|
33 | | -add_library(native-activity SHARED main.cpp) |
| 26 | +add_app_library(native-activity SHARED main.cpp) |
34 | 27 |
|
35 | 28 | target_include_directories(native-activity PRIVATE |
36 | | - ${ANDROID_NDK}/sources/android/native_app_glue) |
| 29 | + ${ANDROID_NDK}/sources/android/native_app_glue |
| 30 | +) |
37 | 31 |
|
38 | | -# add lib dependencies |
39 | 32 | target_link_libraries(native-activity |
40 | 33 | android |
41 | | - native_app_glue |
| 34 | + $<LINK_LIBRARY:WHOLE_ARCHIVE,native_app_glue> |
42 | 35 | EGL |
43 | 36 | GLESv1_CM |
44 | | - log) |
| 37 | + log |
| 38 | +) |
45 | 39 |
|
46 | 40 | if (ANDROID_ABI STREQUAL riscv64) |
47 | 41 | # This sample uses Sensor Manager and Choreographer APIs which are |
|
0 commit comments