summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2019-01-16 01:25:59 +0100
committerMatthias Melcher <git@matthiasm.com>2019-01-16 01:25:59 +0100
commit6de1c93e545e8100a4e907938dccd9b0564e12a2 (patch)
treef9f0160239757d24cbf9ca84f25f2fe36e88174f
parenta4fc8b06e1d3f39b413a19174cb661f198759793 (diff)
Android CMake: macro for multiple tests
Added a macro that creates the IDE files for a named test. This is just a rough layout and will only work for the simpelest of test targets.
-rw-r--r--CMake/Android/AndroidManifest.xml.in4
-rw-r--r--CMake/Android/CMakeList.txt.in9
-rw-r--r--CMake/Android/HelloAndroid.cxx.in2
-rw-r--r--CMake/Android/app.build.gradle.in2
-rw-r--r--CMake/Android/settings.gradle.in3
-rw-r--r--CMake/Android/strings.xml.in2
-rw-r--r--CMake/android.cmake70
-rw-r--r--test/CMakeLists.txt2
8 files changed, 85 insertions, 9 deletions
diff --git a/CMake/Android/AndroidManifest.xml.in b/CMake/Android/AndroidManifest.xml.in
index e0131f422..4e5c6154b 100644
--- a/CMake/Android/AndroidManifest.xml.in
+++ b/CMake/Android/AndroidManifest.xml.in
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.fltk.android_hello"
+ package="org.fltk.@ANDROID_APP_NAME@"
android:versionCode="1"
android:versionName="1.0">
<application
@@ -12,7 +12,7 @@
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name">
<meta-data android:name="android.app.lib_name"
- android:value="android-hello" />
+ android:value="test_@ANDROID_APP_NAME@" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/CMake/Android/CMakeList.txt.in b/CMake/Android/CMakeList.txt.in
index 99019b009..48f8b07f0 100644
--- a/CMake/Android/CMakeList.txt.in
+++ b/CMake/Android/CMakeList.txt.in
@@ -27,10 +27,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_subdirectory(${FLTK_DIR}/ "${CMAKE_CURRENT_BINARY_DIR}/lib" EXCLUDE_FROM_ALL)
# now build app's shared lib
-add_library(android-hello SHARED
+add_library(
+ test_@ANDROID_APP_NAME@ SHARED
HelloAndroid.cxx)
-target_include_directories(android-hello PRIVATE
+target_include_directories(
+ test_@ANDROID_APP_NAME@ PRIVATE
${FLTK_DIR}/
${FLTK_IDE_DIR}/ )
@@ -40,7 +42,8 @@ set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
# add lib dependencies
-target_link_libraries(android-hello
+target_link_libraries(
+ test_@ANDROID_APP_NAME@
fltk
android
log
diff --git a/CMake/Android/HelloAndroid.cxx.in b/CMake/Android/HelloAndroid.cxx.in
index 42cdba663..e79cfcaf2 100644
--- a/CMake/Android/HelloAndroid.cxx.in
+++ b/CMake/Android/HelloAndroid.cxx.in
@@ -16,7 +16,7 @@
*/
-#include "../../../test/button.cxx"
+#include "../../../test/@ANDROID_APP_NAME@.cxx"
/*
diff --git a/CMake/Android/app.build.gradle.in b/CMake/Android/app.build.gradle.in
index dd66c8d93..9e579a4c7 100644
--- a/CMake/Android/app.build.gradle.in
+++ b/CMake/Android/app.build.gradle.in
@@ -4,7 +4,7 @@ apply plugin: 'com.android.application'
compileSdkVersion 25
defaultConfig {
- applicationId 'org.fltk.android_hello'
+ applicationId 'org.fltk.@ANDROID_APP_NAME@'
minSdkVersion 14
targetSdkVersion 25
externalNativeBuild {
diff --git a/CMake/Android/settings.gradle.in b/CMake/Android/settings.gradle.in
index 573abcb32..9cdfbec62 100644
--- a/CMake/Android/settings.gradle.in
+++ b/CMake/Android/settings.gradle.in
@@ -1,2 +1,3 @@
-include ':app'
+include ':arc'
+include ':hello'
diff --git a/CMake/Android/strings.xml.in b/CMake/Android/strings.xml.in
index e2f60e96f..351315218 100644
--- a/CMake/Android/strings.xml.in
+++ b/CMake/Android/strings.xml.in
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Hello Android</string>
+ <string name="app_name">@ANDROID_APP_NAME@</string>
</resources>
diff --git a/CMake/android.cmake b/CMake/android.cmake
index 75b3d4f4d..2ab4c4528 100644
--- a/CMake/android.cmake
+++ b/CMake/android.cmake
@@ -96,3 +96,73 @@ configure_file(
@ONLY
)
+
+macro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
+
+ message(STATUS "Creating Android IDE for ${NAME}")
+ set (ANDROID_APP_NAME ${NAME})
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/app.build.gradle.in"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/build.gradle"
+ @ONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/AndroidManifest.xml.in"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/AndroidManifest.xml"
+ @ONLY
+ )
+
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/Roboto-Regular.ttf"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/assets/fonts/Roboto-Regular.ttf"
+ COPYONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/mdpi.ic_launcher.png"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/res/mipmap-mdpi/ic_launcher.png"
+ COPYONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/hdpi.ic_launcher.png"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/res/mipmap-hdpi/ic_launcher.png"
+ COPYONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/xhdpi.ic_launcher.png"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/res/mipmap-xhdpi/ic_launcher.png"
+ COPYONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/xxhdpi.ic_launcher.png"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/res/mipmap-xxhdpi/ic_launcher.png"
+ COPYONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/strings.xml.in"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/res/values/strings.xml"
+ @ONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/CMakeList.txt.in"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/cpp/CMakeLists.txt"
+ @ONLY
+ )
+
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/CMake/Android/HelloAndroid.cxx.in"
+ "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/cpp/HelloAndroid.cxx"
+ @ONLY
+ )
+
+endmacro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
+
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0ffe3f881..64bed5ca3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -42,6 +42,8 @@ include_directories(
if(NOT ANDROID)
CREATE_EXAMPLE(adjuster adjuster.cxx fltk)
CREATE_EXAMPLE(arc arc.cxx fltk)
+CREATE_ANDROID_IDE_FOR_TEST(arc arc.cxx fltk)
+CREATE_ANDROID_IDE_FOR_TEST(hello hello.cxx fltk)
CREATE_EXAMPLE(animated animated.cxx fltk)
CREATE_EXAMPLE(ask ask.cxx fltk)
CREATE_EXAMPLE(bitmap bitmap.cxx fltk)