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
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. |
| 14 | cmake_minimum_required(VERSION 3.22.1) |
| 15 | project(ckey_android LANGUAGES CXX) |
| 16 | |
| 17 | option(CKEY_ANDROID_SCAN "Include the scanner" ON) |
| 18 | option(CKEY_ANDROID_RENDER "Include the renderer" ON) |
| 19 | option(CKEY_ANDROID_TELEMETRY "Include the telemetry core" ON) |
| 20 | |
| 21 | # src/main/cpp -> repository root (six levels up). |
| 22 | get_filename_component(CKEY_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../.." ABSOLUTE) |
| 23 | set(CKEY_SRC "${CKEY_REPO_ROOT}/src") |
| 24 | if(NOT EXISTS "${CKEY_SRC}/ckey_codec.cpp") |
| 25 | message(FATAL_ERROR "CKey core sources not found at ${CKEY_SRC}; build from the repository checkout.") |
| 26 | endif() |
| 27 | |
| 28 | set(CKEY_SOURCES "${CKEY_SRC}/ckey_codec.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ckey_jni.cpp") |
| 29 | set(CKEY_DEFS "") |
| 30 | if(CKEY_ANDROID_SCAN) |
| 31 | list(APPEND CKEY_SOURCES "${CKEY_SRC}/ckey_scan.cpp") |
| 32 | list(APPEND CKEY_DEFS CKEY_JNI_SCAN=1) |
| 33 | else() |
| 34 | list(APPEND CKEY_DEFS CKEY_JNI_SCAN=0) |
| 35 | endif() |
| 36 | if(CKEY_ANDROID_RENDER) |
| 37 | list(APPEND CKEY_SOURCES "${CKEY_SRC}/ckey_render.cpp") |
| 38 | list(APPEND CKEY_DEFS CKEY_JNI_RENDER=1) |
| 39 | else() |
| 40 | list(APPEND CKEY_DEFS CKEY_JNI_RENDER=0) |
| 41 | endif() |
| 42 | if(CKEY_ANDROID_TELEMETRY) |
| 43 | list(APPEND CKEY_SOURCES "${CKEY_SRC}/telemetry.cpp") |
| 44 | list(APPEND CKEY_DEFS CKEY_JNI_TELEMETRY=1) |
| 45 | else() |
| 46 | list(APPEND CKEY_DEFS CKEY_JNI_TELEMETRY=0) |
| 47 | endif() |
| 48 | if(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) |
| 51 | else() |
| 52 | list(APPEND CKEY_DEFS CKEY_JNI_CERTIFY=0) |
| 53 | endif() |
| 54 | |
| 55 | add_library(ckey_jni SHARED ${CKEY_SOURCES}) |
| 56 | target_compile_features(ckey_jni PRIVATE cxx_std_20) |
| 57 | target_include_directories(ckey_jni PRIVATE "${CKEY_REPO_ROOT}/include" "${CKEY_SRC}") |
| 58 | target_compile_definitions(ckey_jni PRIVATE ${CKEY_DEFS}) |
| 59 | set_target_properties(ckey_jni PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES) |
| 60 | target_compile_options(ckey_jni PRIVATE -Wno-unused-function -ffunction-sections -fdata-sections |
| 61 | $<$<NOT:$<CONFIG:Debug>>:-O2>) |
| 62 | target_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) |