Browse Source

Initial step of integrating with CMake and Megasource

Miku AuahDark 3 years ago
parent
commit
d4da2103a4
3 changed files with 26 additions and 2 deletions
  1. 2 2
      README.md
  2. 17 0
      app/build.gradle
  3. 7 0
      app/src/main/cpp/CMakeLists.txt

+ 2 - 2
README.md

@@ -41,8 +41,8 @@ Quick Start:
 Before you start, install JDK 11 or later. If you intend to build from Android Studio, skip this step as
 Before you start, install JDK 11 or later. If you intend to build from Android Studio, skip this step as
 Android Studio bundles its own JDK 11.
 Android Studio bundles its own JDK 11.
 
 
-Install Android SDK with SDK API 31 (31.0.0) and Android NDK 23.1.7779620, set the environment variables
-`ANDROID_SDK_ROOT` to your Android SDK location and run.
+Install CMake version 3.21 or later in your system. Install Android SDK with SDK API 31 (31.0.0) and Android NDK 23.1.7779620.
+Set the environment variables `ANDROID_SDK_ROOT` to your Android SDK location and run.
 
 
 ```
 ```
 $ ./gradlew assembleNormalRecord
 $ ./gradlew assembleNormalRecord

+ 17 - 0
app/build.gradle

@@ -4,6 +4,7 @@ plugins {
 
 
 android {
 android {
     compileSdk 31
     compileSdk 31
+    ndkVersion "23.1.7779620"
 
 
     defaultConfig {
     defaultConfig {
         applicationId "org.love2d.android"
         applicationId "org.love2d.android"
@@ -11,6 +12,11 @@ android {
         versionName "12.0"
         versionName "12.0"
         minSdk 21
         minSdk 21
         targetSdk 31
         targetSdk 31
+        externalNativeBuild {
+            cmake {
+                cppFlags ''
+            }
+        }
     }
     }
 
 
     buildTypes {
     buildTypes {
@@ -58,6 +64,17 @@ android {
     buildFeatures {
     buildFeatures {
         viewBinding true
         viewBinding true
     }
     }
+    externalNativeBuild {
+        cmake {
+            path file('src/main/cpp/CMakeLists.txt')
+            // '+' notation apparently has been supported long time ago
+            // https://issuetracker.google.com/issues/110693527#comment22
+            // We require CMake 3.21 because r23 has important fixes
+            // that's only fixed if CMake 3.21 is used.
+            // https://github.com/android/ndk/issues/463
+            version '3.21.0+'
+        }
+    }
 }
 }
 
 
 dependencies {
 dependencies {

+ 7 - 0
app/src/main/cpp/CMakeLists.txt

@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(love-android LANGUAGES C CXX)
+
+set(MEGA_LOVE "${CMAKE_CURRENT_SOURCE_DIR}/love")
+
+add_subdirectory(megasource)