Created
March 23, 2018 03:51
-
-
Save thenewvu/42605854cb80fc93198be871f0b1d61a to your computer and use it in GitHub Desktop.
build bgfx examples for android using cmakelist with android-ndk-native-activity-sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (C) The Android Open Source Project | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
cmake_minimum_required(VERSION 3.4.1) | |
# build native_app_glue as a static lib | |
set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}") | |
add_library(native_app_glue STATIC | |
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) | |
# now build app's shared lib | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fno-exceptions -fno-rtti") | |
# Export ANativeActivity_onCreate(), | |
# Refer to: https://github.com/android-ndk/ndk/issues/381. | |
set(CMAKE_SHARED_LINKER_FLAGS | |
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") | |
add_library(native-activity SHARED | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/25-c99/helloworld.c | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/01-cubes/cubes.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/02-metaballs/metaballs.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/03-raymarch/raymarch.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/04-mesh/mesh.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/06-bump/bump.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/07-callback/callback.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/08-update/update.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/09-hdr/hdr.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/10-font/font.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/11-fontsdf/fontsdf.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/12-lod/lod.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/13-stencil/stencil.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/16-shadowmaps/shadowmaps.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/17-drawstress/drawstress.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/18-ibl/ibl.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/19-oit/oit.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/21-deferred/deferred.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/22-windows/windows.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/23-vectordisplay/main.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/23-vectordisplay/vectordisplay.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/24-nbody/nbody.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/26-occlusion/occlusion.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/27-terrain/terrain.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/28-wireframe/wireframe.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/29-debugdraw/debugdraw.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/30-picking/picking.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/31-rsm/reflectiveshadowmap.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/32-particles/particles.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/33-pom/pom.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/34-mvs/mvs.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/35-dynamic/dynamic.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/36-sky/sky.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/37-gpudrivenrendering/gpudrivenrendering.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/00-helloworld/helloworld.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/05-instancing/instancing.cpp | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/20-nanovg/nanovg.cpp | |
) | |
target_include_directories(native-activity PRIVATE | |
${ANDROID_NDK}/sources/android/native_app_glue | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bx/include | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bimg/include | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/3rdparty | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/include | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/examples/common | |
) | |
add_library(bx STATIC IMPORTED) | |
add_library(bimg STATIC IMPORTED) | |
add_library(bimg_decode STATIC IMPORTED) | |
add_library(bgfx STATIC IMPORTED) | |
add_library(example_common STATIC IMPORTED) | |
add_library(example_glue STATIC IMPORTED) | |
set_target_properties(bx | |
PROPERTIES IMPORTED_LOCATION | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/.build/android-x86/bin/libbxDebug.a) | |
set_target_properties(bimg | |
PROPERTIES IMPORTED_LOCATION | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/.build/android-x86/bin/libbimgDebug.a) | |
set_target_properties(bimg_decode | |
PROPERTIES IMPORTED_LOCATION | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/.build/android-x86/bin/libbimg_decodeDebug.a) | |
set_target_properties(bgfx | |
PROPERTIES IMPORTED_LOCATION | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/.build/android-x86/bin/libbgfxDebug.a) | |
set_target_properties(example_common | |
PROPERTIES IMPORTED_LOCATION | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/.build/android-x86/bin/libexample-commonDebug.a) | |
set_target_properties(example_glue | |
PROPERTIES IMPORTED_LOCATION | |
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../submodules/bgfx/.build/android-x86/bin/libexample-glueDebug.a) | |
# add lib dependencies | |
target_link_libraries(native-activity | |
example_common | |
example_glue | |
bgfx | |
bimg | |
bimg_decode | |
bx | |
native_app_glue | |
c | |
dl | |
m | |
android | |
log | |
gcc | |
EGL | |
GLESv2 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment