1cmake_minimum_required(VERSION 3.4.1) 2 3include_directories(third_party) 4 5include_directories(src/main/cpp/) 6 7add_library( native-lib 8 SHARED 9 10 # main game files 11 src/main/cpp/native-lib.cpp 12 src/main/cpp/Game.cpp 13 14 # audio engine 15 src/main/cpp/audio/AAssetDataSource.cpp 16 src/main/cpp/audio/Player.cpp 17 18 # UI engine 19 src/main/cpp/ui/OpenGLFunctions.cpp 20 21 # utility functions 22 src/main/cpp/utils/logging.h 23 src/main/cpp/utils/UtilityFunctions.cpp 24 25 ) 26 27set (TARGET_LIBS log android oboe GLESv2) 28 29if(${USE_FFMPEG}) 30 31 MESSAGE(STATUS "Using FFmpeg extractor") 32 33 add_definitions(-DUSE_FFMPEG=1) 34 target_sources( native-lib PRIVATE src/main/cpp/audio/FFMpegExtractor.cpp ) 35 36 # Add the local path to FFmpeg, you can use the ${ANDROID_ABI} variable to specify the ABI name 37 # e.g. /Users/donturner/Code/ffmpeg/build/${ANDROID_ABI} 38 set(FFMPEG_DIR "/path/to/ffmpeg") 39 40 include_directories(native-lib ${FFMPEG_DIR}/include) 41 42 add_library( avformat SHARED IMPORTED) 43 set_target_properties(avformat PROPERTIES IMPORTED_LOCATION 44 ${FFMPEG_DIR}/lib/libavformat.so) 45 add_library( avutil SHARED IMPORTED) 46 set_target_properties(avutil PROPERTIES IMPORTED_LOCATION 47 ${FFMPEG_DIR}/lib/libavutil.so) 48 add_library( avcodec SHARED IMPORTED) 49 set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION 50 ${FFMPEG_DIR}/lib/libavcodec.so) 51 add_library( swresample SHARED IMPORTED) 52 set_target_properties(swresample PROPERTIES IMPORTED_LOCATION 53 ${FFMPEG_DIR}/lib/libswresample.so) 54 set (TARGET_LIBS ${TARGET_LIBS} avformat avutil avcodec swresample) 55 56else() 57 MESSAGE(STATUS "Using NDK media extractor") 58 add_definitions(-DUSE_FFMPEG=0) 59 target_sources( native-lib PRIVATE src/main/cpp/audio/NDKExtractor.cpp ) 60 set (TARGET_LIBS ${TARGET_LIBS} mediandk) 61endif() 62 63target_link_libraries( native-lib ${TARGET_LIBS} ) 64 65 66# Set the path to the Oboe directory. 67set (OBOE_DIR ../..) 68 69# Add the Oboe library as a subdirectory in your project. 70add_subdirectory (${OBOE_DIR} ./oboe-bin) 71 72# Specify the path to the Oboe header files. 73include_directories (${OBOE_DIR}/include ${OBOE_DIR}/samples) 74 75# Enable optimization flags: if having problems with source level debugging, 76# disable -Ofast ( and debug ), re-enable after done debugging. 77target_compile_options(native-lib 78 PRIVATE -std=c++14 -Wall -Werror "$<$<CONFIG:RELEASE>:-Ofast>") 79