diff --git a/CMakeLists.txt b/CMakeLists.txt index 2df532229f..39d40350d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,6 +123,6 @@ if (NOT ANDROID) add_subdirectory(interface) add_subdirectory(tests) add_subdirectory(tools) -else () - add_subdirectory(gvr-interface) -endif() \ No newline at end of file +endif() + +add_subdirectory(gvr-interface) \ No newline at end of file diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index f360e3416e..52c88a5c8b 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -1,12 +1,10 @@ set(TARGET_NAME gvr-interface) -set(ANDROID_APK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk-build") -set(ANDROID_APK_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk") - -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}") -set(BUILD_SHARED_LIBS ON) - -setup_hifi_library(Gui Widgets AndroidExtras) +if (ANDROID) + setup_hifi_library(Gui Widgets AndroidExtras) +else () + setup_hifi_project(Gui Widgets) +endif () include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) @@ -15,30 +13,42 @@ include_glm() link_hifi_libraries(shared networking audio-client) include_dependency_includes() -set(ANDROID_SDK_ROOT $ENV{ANDROID_HOME}) -set(ANDROID_APP_DISPLAY_NAME Interface) -set(ANDROID_API_LEVEL 19) -set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface) -set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceActivity) -set(ANDROID_APK_VERSION_NAME "0.1") -set(ANDROID_APK_VERSION_CODE 1) -set(ANDROID_DEPLOY_QT_INSTALL "--install") +if (ANDROID) + + set(ANDROID_APK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk-build") + set(ANDROID_APK_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk") + + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}") + set(BUILD_SHARED_LIBS ON) + + set(ANDROID_SDK_ROOT $ENV{ANDROID_HOME}) + set(ANDROID_APP_DISPLAY_NAME Interface) + set(ANDROID_API_LEVEL 19) + set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface) + set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceActivity) + set(ANDROID_APK_VERSION_NAME "0.1") + set(ANDROID_APK_VERSION_CODE 1) + set(ANDROID_DEPLOY_QT_INSTALL "--install") + +endif () find_package(LibOVR) if (LIBOVR_FOUND) add_definitions(-DHAVE_LIBOVR) target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES}) include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS}) - - # we need VRLib, so add a project.properties to our apk build folder that says that - file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}") - file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}") - list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES}) + if (ANDROID) + # we need VRLib, so add a project.properties to our apk build folder that says that + file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}") + file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}") + + list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES}) + endif (ANDROID) endif () # the presence of a HOCKEY_APP_ID means we are making a beta build -if (HOCKEY_APP_ID) +if (ANDROID AND HOCKEY_APP_ID) set(HOCKEY_APP_ENABLED true) set(HOCKEY_APP_ACTIVITY "") set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceBetaActivity) @@ -56,10 +66,14 @@ if (HOCKEY_APP_ID) set(ANDROID_APK_VERSION_CODE ${GIT_COMMIT_COUNT}) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/InterfaceBetaActivity.java.in" "${ANDROID_APK_BUILD_DIR}/src/io/highfidelity/gvrinterface/InterfaceBetaActivity.java") -else () +elseif (ANDROID) set(HOCKEY_APP_ENABLED false) endif () -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/hockeyapp.xml.in" "${ANDROID_APK_BUILD_DIR}/res/values/hockeyapp.xml") +if (ANDROID) -qt_create_apk() \ No newline at end of file + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/hockeyapp.xml.in" "${ANDROID_APK_BUILD_DIR}/res/values/hockeyapp.xml") + + qt_create_apk() + +endif (ANDROID) \ No newline at end of file diff --git a/gvr-interface/src/GVRInterface.cpp b/gvr-interface/src/GVRInterface.cpp index ebedae1073..ef5a05099d 100644 --- a/gvr-interface/src/GVRInterface.cpp +++ b/gvr-interface/src/GVRInterface.cpp @@ -37,7 +37,7 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange); -#ifdef HAVE_LIBOVR +#ifdef Q_OS_ANDROID && HAVE_LIBOVR QAndroidJniEnvironment jniEnv; QPlatformNativeInterface* interface = QApplication::platformNativeInterface(); @@ -54,7 +54,7 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : } void GVRInterface::idle() { -#ifdef HAVE_LIBOVR +#ifdef Q_OS_ANDROID && HAVE_LIBOVR if (!_inVRMode && ovr_IsHeadsetDocked()) { qDebug() << "The headset just got docked - assume we are in VR mode."; _inVRMode = true;