summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-07-09 00:42:12 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-08 15:48:42 -0700
commit5cbbff008411c322ce8184e121e93e40424a400d (patch)
tree3ec206a43ae121a4e609c407b526239798d81539
parent1f112c7738603269b47085d93c02d1a703b18618 (diff)
downloadsubsurface-5cbbff008411c322ce8184e121e93e40424a400d.tar.gz
Use qt-android-cmake to produce a android apk
This introduces code to use qt-android-cmake to produce a working apk. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--CMakeLists.txt21
-rw-r--r--packaging/android/build.sh15
2 files changed, 27 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2e7dd5ac..1d002a014 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -163,7 +163,7 @@ if(SUBSURFACE_MOBILE)
set(QT_QUICK_PKG Quick)
set(QT_QUICK_LIB Qt5::Quick)
endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Android")
+if(ANDROID)
set(ANDROID_PKG AndroidExtras)
set(ANDROID_LIB Qt5::AndroidExtras)
set(FBSUPPORT OFF)
@@ -235,9 +235,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# in some builds we appear to be missing libz for some strange reason...
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lz)
endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Android")
+if(ANDROID)
set(PLATFORM_SRC android.cpp)
- # FIXME: Shouldn't cmake/Qt add this automatically somehow?
add_definitions(-DQ_OS_ANDROID)
set(SUBSURFACE_TARGET subsurface)
endif()
@@ -448,7 +447,7 @@ target_link_libraries(subsurface_interface ${QT_LIBRARIES} ${MARBLE_LIBRARIES})
# add pthread to the end of the library list on Linux
# this is only needed on Ubuntu (why do these idiots break everything?)
# but shouldn't hurt on other Linux versions
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread)
endif()
@@ -468,9 +467,9 @@ if(SUBSURFACE_MOBILE)
subsurface_corelib
${SUBSURFACE_LINK_LIBRARIES})
else()
- if(CMAKE_SYSTEM_NAME STREQUAL "Android")
- # FIXME: is this the right way to link somehting which
- # androiddeployqt can work with?
+ if(ANDROID)
+ # Produce a shared-library instead of a program.
+ # Something that androiddeployqt can work with.
add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
else()
add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
@@ -714,9 +713,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
)
endif()
-if(CMAKE_SYSTEM_NAME STREQUAL "Android")
+if(ANDROID)
# Android template directory
set(ANDROID_PACKAGE_SOURCE_DIR, ${CMAKE_BINARY_DIR}/android)
+ include(${QT_ANDROID_CMAKE})
+ add_qt_android_apk(subsurface.apk ${SUBSURFACE_TARGET}
+ NAME "Subsurface"
+ PACKAGE_NAME "org.subsurfacedivelog"
+ PACKAGE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/android
+ )
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
diff --git a/packaging/android/build.sh b/packaging/android/build.sh
index b70704f45..c569c74f6 100644
--- a/packaging/android/build.sh
+++ b/packaging/android/build.sh
@@ -16,6 +16,7 @@ export ANDROID_NDK_HOST=linux-x86
SQLITE_VERSION=3081002
LIBXML2_VERSION=2.9.2
LIBXSLT_VERSION=1.1.28
+LIBZIP_VERSION=1.0.1
LIBZIP_VERSION=0.11.2
LIBGIT2_VERSION=0.23.0
LIBUSB_VERSION=1.0.19
@@ -41,6 +42,9 @@ export PREFIX=${BUILDROOT}/ndk-$ARCH/sysroot/usr
export PKG_CONFIG_LIBDIR=${PREFIX}/lib/pkgconfig
export CC=${BUILDROOT}/ndk-$ARCH/bin/${BUILDCHAIN}-gcc
export CXX=${BUILDROOT}/ndk-$ARCH/bin/${BUILDCHAIN}-g++
+# Junk needed for qt-android-cmake
+export ANDROID_STANDALONE_TOOLCHAIN=${BUILDROOT}/ndk-$ARCH
+export JAVA_HOME=/usr
if [ ! -e sqlite-autoconf-${SQLITE_VERSION}.tar.gz ] ; then
wget http://www.sqlite.org/2015/sqlite-autoconf-${SQLITE_VERSION}.tar.gz
@@ -156,9 +160,18 @@ if [ ! -e $PKG_CONFIG_LIBDIR/libdivecomputer.pc ] ; then
popd
fi
+if [ ! -e qt-android-cmake ] ; then
+ git clone git://github.com/LaurentGomila/qt-android-cmake.git
+else
+ pushd qt-android-cmake
+ git pull -u
+ popd
+fi
+
mkdir -p subsurface-build-$ARCH
cd subsurface-build-$ARCH
-cmake -DCMAKE_SYSTEM_NAME=Android -DFORCE_LIBSSH=OFF -DLIBDC_FROM_PKGCONFIG=ON -DLIBGIT2_FROM_PKGCONFIG=ON -DUSE_LIBGIT23_API=ON -DNO_MARBLE=ON -DNO_PRINTING=ON -DNO_USERMANUAL=ON -DCMAKE_PREFIX_PATH:UNINITIALIZED=${QT5_ANDROID}/android_${QT_ARCH}/lib/cmake $SUBSURFACE_SOURCE
+# somehting in the qt-android-cmake-thingies mangles your path, so thats why we need to hard-code ant and pkg-config here.
+cmake -DQT_ANDROID_ANT=/usr/bin/ant -DPKG_CONFIG_EXECUTABLE=/usr/bin/pkg-config -DQT_ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT -DQT_ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT -DCMAKE_TOOLCHAIN_FILE=$BUILDROOT/qt-android-cmake/toolchain/android.toolchain.cmake -DQT_ANDROID_CMAKE=$BUILDROOT/qt-android-cmake/AddQtAndroidApk.cmake -DFORCE_LIBSSH=OFF -DLIBDC_FROM_PKGCONFIG=ON -DLIBGIT2_FROM_PKGCONFIG=ON -DUSE_LIBGIT23_API=ON -DNO_MARBLE=ON -DNO_PRINTING=ON -DNO_USERMANUAL=ON -DCMAKE_PREFIX_PATH:UNINITIALIZED=${QT5_ANDROID}/android_${QT_ARCH}/lib/cmake $SUBSURFACE_SOURCE
make
#make install INSTALL_ROOT=android_build
# bug in androiddeployqt? why is it looking for something with the builddir in it?