Qt6 Android service with separate ".so" library and CMake

Viewed 112

I have Qt 6.3 CMake-project that contains two subdirectories "app" and "service", i want include Android service .so library into result APK. With qmake-project i can achieve this like that at app.pri:

contains(ANDROID_TARGET_ARCH, arm64-v8a) {
  release: ANDROID_EXTRA_LIBS = $$OUT_PWD/../service/libservice_arm64-v8a.so
  debug: ANDROID_EXTRA_LIBS = $$OUT_PWD/../service/libservice_arm64-v8a.so
}

with CMake i tried to set(QT_ANDROID_EXTRA_LIBS C:/workspace/build-test-Android_Qt_6_3_0_Clang_arm64_v8a-Debug/service/libservice_arm64-v8a.so) at app->CMakeLists.txt and it has no effect.

1 Answers

Found that QT_ANDROID_EXTRA_LIBS is 'target property' and should be set via set_target_properties() then it adds .so into result.

set_target_properties(project_name  PROPERTIES 
QT_ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_BINARY_DIR}/../service/libservice_${ANDROID_ABI}.so)
Related