|
| 1 | +# For more information about using CMake with Android Studio, read the |
| 2 | +# documentation: https://d.android.com/studio/projects/add-native-code.html |
| 3 | + |
| 4 | +# Sets the minimum version of CMake required to build the native library. |
| 5 | +include(FetchContent OPTIONAL RESULT_VARIABLE HAS_FETCH_CONTENT) |
| 6 | + |
| 7 | +cmake_minimum_required(VERSION 3.18.1) |
| 8 | +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) |
| 9 | +set(CMAKE_CXX_STANDARD 11) |
| 10 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 11 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 12 | +project (apl-android-native VERSION 1.0.0 LANGUAGES C CXX) |
| 13 | + |
| 14 | +set(APL_PROJECT_DIR ${APL_PROJECT_DIR}) |
| 15 | + |
| 16 | +if (DEFINED SCENE_GRAPH) |
| 17 | + set(ENABLE_SCENEGRAPH ${SCENE_GRAPH}) |
| 18 | +endif() |
| 19 | + |
| 20 | +# Tell core to compile alexa extensions. |
| 21 | +set(ENABLE_ALEXAEXTENSIONS ON) |
| 22 | +set(BUILD_ALEXAEXTENSIONS ON) |
| 23 | +set(USE_PROVIDED_YOGA_INLINE ON) |
| 24 | +set(ENABLE_PIC ON) |
| 25 | + |
| 26 | +FetchContent_Declare( |
| 27 | + aplcore |
| 28 | + SOURCE_DIR ${APL_PROJECT_DIR} |
| 29 | +) |
| 30 | +FetchContent_MakeAvailable(aplcore) |
| 31 | + |
| 32 | +set(RAPIDJSON_INCLUDE "${CMAKE_BINARY_DIR}/_deps/rapidjson-src/include") |
| 33 | +set(ENUMGEN_BIN "${CMAKE_BINARY_DIR}/tools/enumgen") |
| 34 | + |
| 35 | +add_custom_target(generate-android-enums ALL |
| 36 | + COMMAND cd ${APL_PROJECT_DIR} && ${ENUMGEN_BIN} |
| 37 | + -f "AnimationQuality" |
| 38 | + -f "AudioPlayerEventType" |
| 39 | + -f "BlendMode" |
| 40 | + -f "ComponentType" |
| 41 | + -f "ContainerDirection" |
| 42 | + -f "DimensionType" |
| 43 | + -f "Display" |
| 44 | + -f "DisplayState" |
| 45 | + -f "EventAudioTrack" |
| 46 | + -f "EventControlMediaCommand" |
| 47 | + -f "EventDirection" |
| 48 | + -f "EventHighlightMode" |
| 49 | + -f "EventProperty" |
| 50 | + -f "EventReason" |
| 51 | + -f "EventScrollAlign" |
| 52 | + -f "EventType" |
| 53 | + -f "EventMediaType" |
| 54 | + -f "FilterType" |
| 55 | + -f "FilterProperty" |
| 56 | + -f "FlexboxAlign" |
| 57 | + -f "FlexboxJustifyContent" |
| 58 | + -f "FocusDirection" |
| 59 | + -f "FontStyle" |
| 60 | + -f "GradientProperty" |
| 61 | + -f "GradientSpreadMethod" |
| 62 | + -f "GradientType" |
| 63 | + -f "GradientUnits" |
| 64 | + -f "GraphicTextAnchor" |
| 65 | + -f "GraphicElementType" |
| 66 | + -f "GraphicLayoutDirection" |
| 67 | + -f "GraphicLineCap" |
| 68 | + -f "GraphicLineJoin" |
| 69 | + -f "GraphicPropertyKey" |
| 70 | + -f "GraphicFilterType" |
| 71 | + -f "GraphicFilterProperty" |
| 72 | + -f "GraphicScale" |
| 73 | + -f "GraphicScale" |
| 74 | + -f "ImageAlign" |
| 75 | + -f "ImageCount" |
| 76 | + -f "ImageScale" |
| 77 | + -f "KeyHandlerType" |
| 78 | + -f "LayoutDirection" |
| 79 | + -f "MediaPlayerEventType" |
| 80 | + -f "Navigation" |
| 81 | + -f "NoiseFilterKind" |
| 82 | + -f "Position" |
| 83 | + -f "PointerEventType" |
| 84 | + -f "PointerType" |
| 85 | + -f "PropertyKey" |
| 86 | + -f "RootProperty" |
| 87 | + -f "ScreenShape" |
| 88 | + -f "ScrollDirection" |
| 89 | + -f "SpanAttributeName" |
| 90 | + -f "SpanType" |
| 91 | + -f "Snap" |
| 92 | + -f "SpeechMarkType" |
| 93 | + -f "TextAlign" |
| 94 | + -f "TextAlignVertical" |
| 95 | + -f "TextTrackType" |
| 96 | + -f "TokenType" |
| 97 | + -f "TrackState" |
| 98 | + -f "UpdateType" |
| 99 | + -f "VectorGraphicAlign" |
| 100 | + -f "VectorGraphicScale" |
| 101 | + -f "VideoScale" |
| 102 | + -f "ViewportMode" |
| 103 | + -f "AudioTrack" |
| 104 | + -f "KeyboardType" |
| 105 | + -f "SubmitKeyType" |
| 106 | + -f "ScreenMode" |
| 107 | + -f "Role" |
| 108 | + -f "ExtensionComponentResourceState" |
| 109 | + -l java -p com.amazon.apl.enums -o ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java/com/amazon/apl/enums |
| 110 | + ${APL_PROJECT_DIR}/aplcore/include/apl/action/*.h |
| 111 | + ${APL_PROJECT_DIR}/aplcore/include/apl/animation/*.h |
| 112 | + ${APL_PROJECT_DIR}/aplcore/include/apl/audio/*.h |
| 113 | + ${APL_PROJECT_DIR}/aplcore/include/apl/command/*.h |
| 114 | + ${APL_PROJECT_DIR}/aplcore/include/apl/component/*.h |
| 115 | + ${APL_PROJECT_DIR}/aplcore/include/apl/content/*.h |
| 116 | + ${APL_PROJECT_DIR}/aplcore/include/apl/datagrammar/*.h |
| 117 | + ${APL_PROJECT_DIR}/aplcore/include/apl/document/*.h |
| 118 | + ${APL_PROJECT_DIR}/aplcore/include/apl/engine/*.h |
| 119 | + ${APL_PROJECT_DIR}/aplcore/include/apl/graphic/*.h |
| 120 | + ${APL_PROJECT_DIR}/aplcore/include/apl/media/*.h |
| 121 | + ${APL_PROJECT_DIR}/aplcore/include/apl/primitives/*.h |
| 122 | + ${APL_PROJECT_DIR}/aplcore/include/apl/time/*.h |
| 123 | + ${APL_PROJECT_DIR}/aplcore/include/apl/utils/*.h |
| 124 | + ${APL_PROJECT_DIR}/aplcore/include/apl/touch/*.h |
| 125 | + ${APL_PROJECT_DIR}/aplcore/include/apl/focus/*.h |
| 126 | + DEPENDS enumgen |
| 127 | + ) |
| 128 | + |
| 129 | +get_target_property(RAPIDJSON_INCLUDE rapidjson-apl INTERFACE_INCLUDE_DIRECTORIES) |
| 130 | +add_custom_target(rapidjson ALL |
| 131 | + COMMAND ${CMAKE_COMMAND} -E copy_directory ${RAPIDJSON_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/rapidjson/include |
| 132 | + ) |
| 133 | + |
| 134 | +get_target_property(APL_INCLUDE apl INTERFACE_INCLUDE_DIRECTORIES) |
| 135 | +get_target_property(ALEXAEXT_INCLUDE alexaext INTERFACE_INCLUDE_DIRECTORIES) |
| 136 | + |
| 137 | +add_custom_target(copy-headers |
| 138 | + COMMAND ${CMAKE_COMMAND} -E copy_directory ${APL_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/apl/include |
| 139 | + COMMAND ${CMAKE_COMMAND} -E copy_directory ${ALEXAEXT_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/alexaext/include |
| 140 | + DEPENDS apl alexaext |
| 141 | + ) |
| 142 | + |
| 143 | +if (ENABLE_SCENEGRAPH) |
| 144 | + add_custom_target(copy-config |
| 145 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/apl/include/apl/apl_config.h ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/aplsgconfig/include/apl/apl_config.h |
| 146 | + DEPENDS copy-headers) |
| 147 | +else() |
| 148 | + add_custom_target(copy-config |
| 149 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/apl/include/apl/apl_config.h ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/aplconfig/include/apl/apl_config.h |
| 150 | + DEPENDS copy-headers) |
| 151 | +endif() |
| 152 | + |
| 153 | +if (NOT ANDROID) |
| 154 | + # Ensure jni.h is found |
| 155 | + find_package(JNI REQUIRED) |
| 156 | + include_directories(${JAVA_INCLUDE_PATH}) |
| 157 | + include_directories(${JAVA_INCLUDE_PATH2}) |
| 158 | +endif() |
0 commit comments