allow gvr-interface target to be compiled for desktop

This commit is contained in:
Stephen Birarda 2015-01-28 16:57:16 -08:00
parent 8460557135
commit 1dd74c9831
3 changed files with 43 additions and 29 deletions

View file

@ -123,6 +123,6 @@ if (NOT ANDROID)
add_subdirectory(interface) add_subdirectory(interface)
add_subdirectory(tests) add_subdirectory(tests)
add_subdirectory(tools) add_subdirectory(tools)
else () endif()
add_subdirectory(gvr-interface)
endif() add_subdirectory(gvr-interface)

View file

@ -1,12 +1,10 @@
set(TARGET_NAME gvr-interface) set(TARGET_NAME gvr-interface)
set(ANDROID_APK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk-build") if (ANDROID)
set(ANDROID_APK_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk") setup_hifi_library(Gui Widgets AndroidExtras)
else ()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}") setup_hifi_project(Gui Widgets)
set(BUILD_SHARED_LIBS ON) endif ()
setup_hifi_library(Gui Widgets AndroidExtras)
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
@ -15,30 +13,42 @@ include_glm()
link_hifi_libraries(shared networking audio-client) link_hifi_libraries(shared networking audio-client)
include_dependency_includes() include_dependency_includes()
set(ANDROID_SDK_ROOT $ENV{ANDROID_HOME}) if (ANDROID)
set(ANDROID_APP_DISPLAY_NAME Interface)
set(ANDROID_API_LEVEL 19) set(ANDROID_APK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk-build")
set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface) set(ANDROID_APK_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apk")
set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceActivity)
set(ANDROID_APK_VERSION_NAME "0.1") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}")
set(ANDROID_APK_VERSION_CODE 1) set(BUILD_SHARED_LIBS ON)
set(ANDROID_DEPLOY_QT_INSTALL "--install")
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) find_package(LibOVR)
if (LIBOVR_FOUND) if (LIBOVR_FOUND)
add_definitions(-DHAVE_LIBOVR) add_definitions(-DHAVE_LIBOVR)
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES})
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS}) 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 () endif ()
# the presence of a HOCKEY_APP_ID means we are making a beta build # 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_ENABLED true)
set(HOCKEY_APP_ACTIVITY "<activity android:name='net.hockeyapp.android.UpdateActivity' />") set(HOCKEY_APP_ACTIVITY "<activity android:name='net.hockeyapp.android.UpdateActivity' />")
set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceBetaActivity) set(ANDROID_ACTIVITY_NAME io.highfidelity.gvrinterface.InterfaceBetaActivity)
@ -56,10 +66,14 @@ if (HOCKEY_APP_ID)
set(ANDROID_APK_VERSION_CODE ${GIT_COMMIT_COUNT}) 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") 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) set(HOCKEY_APP_ENABLED false)
endif () endif ()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/hockeyapp.xml.in" "${ANDROID_APK_BUILD_DIR}/res/values/hockeyapp.xml") if (ANDROID)
qt_create_apk() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/templates/hockeyapp.xml.in" "${ANDROID_APK_BUILD_DIR}/res/values/hockeyapp.xml")
qt_create_apk()
endif (ANDROID)

View file

@ -37,7 +37,7 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange); connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange);
#ifdef HAVE_LIBOVR #ifdef Q_OS_ANDROID && HAVE_LIBOVR
QAndroidJniEnvironment jniEnv; QAndroidJniEnvironment jniEnv;
QPlatformNativeInterface* interface = QApplication::platformNativeInterface(); QPlatformNativeInterface* interface = QApplication::platformNativeInterface();
@ -54,7 +54,7 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
} }
void GVRInterface::idle() { void GVRInterface::idle() {
#ifdef HAVE_LIBOVR #ifdef Q_OS_ANDROID && HAVE_LIBOVR
if (!_inVRMode && ovr_IsHeadsetDocked()) { if (!_inVRMode && ovr_IsHeadsetDocked()) {
qDebug() << "The headset just got docked - assume we are in VR mode."; qDebug() << "The headset just got docked - assume we are in VR mode.";
_inVRMode = true; _inVRMode = true;