@@ -407,17 +407,36 @@ elseif(ANDROID)
407
407
include (${android_openssl_SOURCE_DIR} /android_openssl.cmake )
408
408
add_android_openssl_libraries (${CMAKE_PROJECT_NAME} )
409
409
410
- set (ANDROID_PLATFORM_ARCHITECTURE_CODE )
411
- if (${ANDROID_ABI} STREQUAL "armeabi-v7a" )
412
- set (ANDROID_PLATFORM_ARCHITECTURE_CODE "032" )
413
- elseif (${ANDROID_ABI} STREQUAL "arm64-v8a" )
414
- set (ANDROID_PLATFORM_ARCHITECTURE_CODE "064" )
415
- elseif (${ANDROID_ABI} STREQUAL "x86" )
416
- set (ANDROID_PLATFORM_ARCHITECTURE_CODE "132" )
417
- elseif (${ANDROID_ABI} STREQUAL "x86_64" )
418
- set (ANDROID_PLATFORM_ARCHITECTURE_CODE "164" )
410
+ # Generation of android version numbers must be consistent release to release such that they are always increasing
411
+
412
+ if (${PROJECT_VERSION_MAJOR} GREATER 9 )
413
+ message (FATAL_ERROR "Major version larger than 1 digit: ${PROJECT_VERSION_MAJOR} " )
414
+ endif ()
415
+ if (${PROJECT_VERSION_MINOR} GREATER 9 )
416
+ message (FATAL_ERROR "Minor version larger than 1 digit: ${PROJECT_VERSION_MINOR} " )
417
+ endif ()
418
+ if (${PROJECT_VERSION_PATCH} GREATER 99 )
419
+ message (FATAL_ERROR "Patch version larger than 2 digits: ${PROJECT_VERSION_PATCH} " )
419
420
endif ()
420
- set (ANDROID_VERSION_CODE "${ANDROID_PLATFORM_ARCHITECTURE_CODE}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR} " )
421
+
422
+ # Bitness for android version number is 66/34 instead of 64/32 in because of a required version number bump screw-up ages ago
423
+ set (ANDROID_BITNESS_CODE )
424
+ if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "x86" )
425
+ set (ANDROID_BITNESS_CODE 34 )
426
+ elseif (${ANDROID_ABI} STREQUAL "arm64-v8a" OR ${ANDROID_ABI} STREQUAL "x86_64" )
427
+ set (ANDROID_BITNESS_CODE 66 )
428
+ else ()
429
+ message (FATAL_ERROR "Unsupported Android ABI: ${ANDROID_ABI} " )
430
+ endif ()
431
+
432
+ set (ANDROID_PATCH_VERSION ${PROJECT_VERSION_PATCH} )
433
+ if (${PROJECT_VERSION_PATCH} LESS 10 )
434
+ set (ANDROID_PATCH_VERSION "0${PROJECT_VERSION_PATCH} " )
435
+ endif ()
436
+
437
+ # Version code format: BBMIPPDDD (B=Bitness, M=Major, I=Minor, P=Patch, D=Dev) - Dev not currently supported and always 000
438
+ set (ANDROID_VERSION_CODE "${ANDROID_BITNESS_CODE}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}${ANDROID_PATCH_VERSION} 000" )
439
+ message ("Android version code: ${ANDROID_VERSION_CODE} " )
421
440
422
441
set_target_properties (${CMAKE_PROJECT_NAME}
423
442
PROPERTIES
0 commit comments