1cmake_minimum_required(VERSION 3.4.1)
2
3set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99  -Werror -DVK_USE_PLATFORM_ANDROID_KHR")
4
5# ============== Games SDK
6
7# This will use swappy from a packaged version
8include("../../../samples/gamesdk.cmake")
9add_gamesdk_target("package/local" "localBuild")
10
11# ============== cube
12
13# Build Util Lib
14set(UTILS_NAME  vsamputils)
15set(GLSLANG_SPIRV_INCLUDE_DIR ${SHADERC_SRC}/third_party/glslang)
16get_filename_component(PROJECT_SOURCE_DIR
17                       "${CMAKE_SOURCE_DIR}/../../../.."
18                       ABSOLUTE)
19
20# Import shaderc lib in NDK
21add_library(shaderc_lib STATIC IMPORTED)
22set_target_properties(shaderc_lib PROPERTIES IMPORTED_LOCATION
23                         ${SHADERC_SRC}/libs/${ANDROID_STL}/${ANDROID_ABI}/libshaderc.a)
24
25find_program(GLSC names glslc HINTS "${ANDROID_NDK}/shader-tools/*")
26
27foreach(shader vert frag)
28    add_custom_command(
29            COMMENT "Compiling ${shader}"
30            OUTPUT cube.${shader}.inc
31            COMMAND ${GLSC} -mfmt=num src/main/cpp/cube.${shader} -o src/main/cpp/include/cube.${shader}.inc
32            MAIN_DEPENDENCY src/main/cpp/include/cube.${shader}.inc
33            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
34    )
35endforeach()
36
37# Force export ANativeActivity_onCreate(),
38# Refer to: https://github.com/android-ndk/ndk/issues/381.
39set(CMAKE_SHARED_LINKER_FLAGS
40    "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
41
42include_directories( src/main/cpp )
43
44set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99  -Werror -DVK_USE_PLATFORM_ANDROID_KHR")
45set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11  -Werror -DVK_USE_PLATFORM_ANDROID_KHR")
46
47add_library( native-lib
48
49             SHARED
50
51             cube.vert.inc
52             cube.frag.inc
53             ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c
54             src/main/cpp/cube.c
55             src/main/cpp/common/android_util.cpp
56             src/main/cpp/common/vulkan_wrapper.cpp
57        )
58
59target_include_directories(native-lib
60
61                           PRIVATE
62
63                           ${SHADERC_SRC}/third_party/spirv-tools/include
64                           ${SHADERC_SRC}/third_party/spirv-tools/include/spirv-tools
65                           src/main/cpp/include
66                           src/main/cpp/common
67                           ${ANDROID_NDK}/sources/android/native_app_glue)
68
69
70target_link_libraries( native-lib
71
72                       gamesdk
73                       android
74                       log
75                       )
76