Viewing is open to everyone. Downloading and starring need a GitHub sign-in. Sign in with GitHub

CMakeLists.txt

v0.1.0-build.85 Latest Commit ede38f5

Size
2.9 KB
Lines
67
Language
cmake
SHA-256
d70d7f71b512…
View on GitHub

Sign in with GitHub to download. Each download is recorded with your GitHub username.

1# Native part of org.openckey:ckey: libckey_jni.so.
2#
3# Compiles the repository's core sources in place (by relative path; nothing
4# is copied) plus the JNI bridge, into one shared library that exports only
5# JNI_OnLoad and the Java_org_openckey_ckey_CKeyNative_* functions.
6#
7# Module switches (Gradle properties ckey.native.scan / .render / .telemetry,
8# all true for the published AAR):
9# CKEY_ANDROID_SCAN ckey_scan.cpp (decoding; scan-only apps keep this)
10# CKEY_ANDROID_RENDER ckey_render.cpp (render-only apps keep this)
11# CKEY_ANDROID_TELEMETRY telemetry.cpp (OS-vendor builds may drop it)
12# ckey_codec.cpp is always built. Certification (ckey_certify.cpp) is added
13# automatically when the core has it and both scan and render are on.
14cmake_minimum_required(VERSION 3.22.1)
15project(ckey_android LANGUAGES CXX)
16
17option(CKEY_ANDROID_SCAN "Include the scanner" ON)
18option(CKEY_ANDROID_RENDER "Include the renderer" ON)
19option(CKEY_ANDROID_TELEMETRY "Include the telemetry core" ON)
20
21# src/main/cpp -> repository root (six levels up).
22get_filename_component(CKEY_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE)
23set(CKEY_SRC "${CKEY_REPO_ROOT}/src")
24if(NOT EXISTS "${CKEY_SRC}/ckey_codec.cpp")
25 message(FATAL_ERROR "CKey core sources not found at ${CKEY_SRC}; build from the repository checkout.")
26endif()
27
28set(CKEY_SOURCES "${CKEY_SRC}/ckey_codec.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ckey_jni.cpp")
29set(CKEY_DEFS "")
30if(CKEY_ANDROID_SCAN)
31 list(APPEND CKEY_SOURCES "${CKEY_SRC}/ckey_scan.cpp")
32 list(APPEND CKEY_DEFS CKEY_JNI_SCAN=1)
33else()
34 list(APPEND CKEY_DEFS CKEY_JNI_SCAN=0)
35endif()
36if(CKEY_ANDROID_RENDER)
37 list(APPEND CKEY_SOURCES "${CKEY_SRC}/ckey_render.cpp")
38 list(APPEND CKEY_DEFS CKEY_JNI_RENDER=1)
39else()
40 list(APPEND CKEY_DEFS CKEY_JNI_RENDER=0)
41endif()
42if(CKEY_ANDROID_TELEMETRY)
43 list(APPEND CKEY_SOURCES "${CKEY_SRC}/telemetry.cpp")
44 list(APPEND CKEY_DEFS CKEY_JNI_TELEMETRY=1)
45else()
46 list(APPEND CKEY_DEFS CKEY_JNI_TELEMETRY=0)
47endif()
48if(CKEY_ANDROID_SCAN AND CKEY_ANDROID_RENDER AND EXISTS "${CKEY_SRC}/ckey_certify.cpp")
49 list(APPEND CKEY_SOURCES "${CKEY_SRC}/ckey_certify.cpp")
50 list(APPEND CKEY_DEFS CKEY_JNI_CERTIFY=1)
51else()
52 list(APPEND CKEY_DEFS CKEY_JNI_CERTIFY=0)
53endif()
54
55add_library(ckey_jni SHARED ${CKEY_SOURCES})
56target_compile_features(ckey_jni PRIVATE cxx_std_20)
57target_include_directories(ckey_jni PRIVATE "${CKEY_REPO_ROOT}/include" "${CKEY_SRC}")
58target_compile_definitions(ckey_jni PRIVATE ${CKEY_DEFS})
59set_target_properties(ckey_jni PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES)
60target_compile_options(ckey_jni PRIVATE -Wno-unused-function -ffunction-sections -fdata-sections
61 $<$<NOT:$<CONFIG:Debug>>:-O2>)
62target_link_options(ckey_jni PRIVATE
63 -Wl,--gc-sections
64 -Wl,--exclude-libs,ALL
65 "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ckey_jni.map"
66 # 16 KB page alignment (required for Android 15+ devices with 16 KB pages).
67 -Wl,-z,max-page-size=16384)