From 2316cfb885965d8ed76f6ac790f210124216f7e0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 17 Nov 2014 15:19:07 -0800 Subject: [PATCH] link hifi libs and openssl statically to gvr-interface --- cmake/android/Apk.cmake | 17 ++++++++++++----- cmake/macros/SetupHifiLibrary.cmake | 8 ++++++-- gvr-interface/CMakeLists.txt | 22 ++++++++++++++++------ gvr-interface/src/main.cpp | 4 ---- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/cmake/android/Apk.cmake b/cmake/android/Apk.cmake index 7c5d8cbbba..3b70cc22d4 100755 --- a/cmake/android/Apk.cmake +++ b/cmake/android/Apk.cmake @@ -68,7 +68,7 @@ set(ANDROID_THIS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) # Directory this CMake fil ## - "jarsigner" (part of the JDK) ## - "zipalign" (part of the Android SDK) ################################################## -macro(android_create_apk name apk_directory shared_libraries jar_libraries assets data_directory) +macro(android_create_apk name apk_directory shared_libraries static_libraries jar_libraries assets data_directory) if(ANDROID_APK_CREATE) # Construct the current package name and theme set(ANDROID_APK_PACKAGE "${ANDROID_APK_TOP_LEVEL_DOMAIN}.${ANDROID_APK_DOMAIN}.${ANDROID_APK_SUBDOMAIN}") @@ -99,9 +99,9 @@ macro(android_create_apk name apk_directory shared_libraries jar_libraries asset get_filename_component(shared_library_filename ${value} NAME_WE) # "shared_library_filename" is e.g. "libPLCore", but we need "PLCore" - string(LENGTH ${shared_library_filename} shared_library_filename_length) - math(EXPR shared_library_filename_length ${shared_library_filename_length}-3) - string(SUBSTRING ${shared_library_filename} 3 ${shared_library_filename_length} shared_library_filename) + string(LENGTH ${shared_library_filename} shared_library_filename_length) + math(EXPR shared_library_filename_length ${shared_library_filename_length}-3) + string(SUBSTRING ${shared_library_filename} 3 ${shared_library_filename_length} shared_library_filename) # "shared_library_filename" is now e.g. "PLCore", this is what we want -> Add it to the list set(ANDROID_SHARED_LIBRARIES_TO_LOAD ${ANDROID_SHARED_LIBRARIES_TO_LOAD} ${shared_library_filename}) @@ -128,6 +128,14 @@ macro(android_create_apk name apk_directory shared_libraries jar_libraries asset ) endforeach() + # Copy the used shared libraries + foreach(value ${static_libraries}) + add_custom_command(TARGET ${ANDROID_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${value} "${apk_directory}/libs/${ARM_TARGET}" + ) + endforeach() + # Copy any required external jars to the libs folder foreach(value ${jar_libraries}) add_custom_command(TARGET ${ANDROID_NAME} @@ -135,7 +143,6 @@ macro(android_create_apk name apk_directory shared_libraries jar_libraries asset COMMAND ${CMAKE_COMMAND} -E copy ${value} "${apk_directory}/libs/" ) endforeach() - # Create "build.xml", "default.properties", "local.properties" and "proguard.cfg" files add_custom_command(TARGET ${ANDROID_NAME} diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 97e1c63f4c..0b81e9bfba 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -9,14 +9,18 @@ macro(SETUP_HIFI_LIBRARY) - project(${TARGET_NAME}) + project(${TARGET_NAME}) # grab the implemenation and header files file(GLOB_RECURSE LIB_SRCS "src/*.h" "src/*.cpp") list(APPEND ${TARGET_NAME}_SRCS ${LIB_SRCS}) # create a library and set the property so it can be referenced later - add_library(${TARGET_NAME} ${${TARGET_NAME}_SRCS} ${AUTOMTC_SRC}) + if (${${TARGET_NAME}_SHARED}) + add_library(${TARGET_NAME} SHARED ${${TARGET_NAME}_SRCS} ${AUTOMTC_SRC}) + else () + add_library(${TARGET_NAME} ${${TARGET_NAME}_SRCS} ${AUTOMTC_SRC}) + endif () set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index c97b84aeaa..c07f14e8e3 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -1,11 +1,10 @@ set(TARGET_NAME gvr-interface) -set(BUILD_SHARED_LIBS ON) - set(${TARGET_NAME}_SRCS ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c ) +set(${TARGET_NAME}_SHARED true) setup_hifi_library() include_directories(${ANDROID_NDK}/sources/android/native_app_glue) @@ -23,20 +22,31 @@ set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_DEFINITIONS "ANDROID") set(ANDROID_API_LEVEL 19) set(ARM_TARGET "armeabi-v7a") -set(TARGET_SHARED_LIBRARIES ${${TARGET_NAME}_LIBRARIES_TO_LINK}) -list(APPEND TARGET_SHARED_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${TARGET_NAME}.so") +foreach(TARGET_LINK_LIBRARY ${${TARGET_NAME}_LIBRARIES_TO_LINK}) + get_filename_component(LIB_EXTENSION ${TARGET_LINK_LIBRARY} NAME_WE) + + if (LIB_EXTENSION STREQUAL "so") + list(APPEND TARGET_SHARED_LIBRARIES ${TARGET_LINK_LIBRARY}) + else () + list(APPEND TARGET_STATIC_LIBRARIES ${TARGET_LINK_LIBRARY}) + endif () + +endforeach() # append each of the hifi shared libraries to our list of libs to link -foreach(HIFI_SHARED_LIBRARY ${REQUIRED_HIFI_LIBRARIES}) - list(APPEND TARGET_SHARED_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${HIFI_SHARED_LIBRARY}.so") +foreach(HIFI_STATIC_LIBRARY ${REQUIRED_HIFI_LIBRARIES}) + list(APPEND TARGET_STATIC_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${HIFI_STATIC_LIBRARY}.a") endforeach() +list(APPEND TARGET_SHARED_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${TARGET_NAME}.so") + set(TARGET_JAR_LIBRARIES "${QT_CMAKE_PREFIX_PATH}/../../jar/QtAndroid-bundled.jar") android_create_apk( ${TARGET_NAME} "${CMAKE_BINARY_DIR}/apk" "${TARGET_SHARED_LIBRARIES}" + "${TARGET_STATIC_LIBRARIES}" "${TARGET_JAR_LIBRARIES}" "${CMAKE_CURRENT_SOURCE_DIR}/assets" "Data" diff --git a/gvr-interface/src/main.cpp b/gvr-interface/src/main.cpp index 7b8cf06f1e..6bae565605 100644 --- a/gvr-interface/src/main.cpp +++ b/gvr-interface/src/main.cpp @@ -12,8 +12,6 @@ #include #include -#include - // usage of log #define APP_NAME "Interface" @@ -37,8 +35,6 @@ void android_main(struct android_app* state) { // set up so when commands happen we call our custom handler state->onAppCmd = custom_handle_cmd; - - NodeList* nodeList = NodeList::createInstance(NodeType::Agent); while (1) { struct android_poll_source* source;