android example template, base as shared library

This commit is contained in:
saschawillems 2018-05-08 07:10:30 +02:00
parent f8fc3e8b8e
commit 8924ce733e
2 changed files with 24 additions and 12 deletions

View file

@ -5,25 +5,16 @@ set(NAME %EXAMPLE_FOLDER%)
set(SRC_DIR ../../../examples/${NAME}) set(SRC_DIR ../../../examples/${NAME})
set(BASE_DIR ../../../base) set(BASE_DIR ../../../base)
set(EXTERNAL_DIR ../../../external) set(EXTERNAL_DIR ../../../external)
set(LIB_DIR ../../../libs)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES")
file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp") file(GLOB EXAMPLE_SRC "${SRC_DIR}/*.cpp")
file(GLOB BASE_SRC "${BASE_DIR}/*.cpp")
add_library( add_library(native-lib SHARED ${EXAMPLE_SRC})
native-lib SHARED
${EXAMPLE_SRC}
${BASE_SRC}
${EXTERNAL_DIR}/imgui/imgui.cpp
${EXTERNAL_DIR}/imgui/imgui_draw.cpp
)
add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) add_library(native-app-glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
add_library(libassimp STATIC IMPORTED) add_subdirectory(../base ${CMAKE_SOURCE_DIR}/../base)
set_target_properties(libassimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../../../libs/assimp/${ANDROID_ABI}/libassimp.a)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
@ -37,8 +28,8 @@ include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
target_link_libraries( target_link_libraries(
native-lib native-lib
native-app-glue native-app-glue
libbase
android android
log log
z z
libassimp
) )

View file

@ -0,0 +1,21 @@
file(GLOB BASE_SRC "../../../base/*.cpp" "../../../external/imgui/imgui.cpp" "../../../external/imgui/imgui_draw.cpp")
add_library(libbase SHARED ${BASE_SRC})
add_library(libassimp STATIC IMPORTED)
set_target_properties(libassimp PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../../../libs/assimp/${ANDROID_ABI}/libassimp.a)
include_directories(${BASE_DIR})
include_directories(../../../external/glm)
include_directories(../../../external/gli)
include_directories(../../../external/imgui)
include_directories(../../../external/assimp)
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
target_link_libraries(
libbase
android
log
z
libassimp
)