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.
This commit is contained in:
Matthias Melcher 2019-01-16 01:25:59 +01:00
parent a4fc8b06e1
commit 6de1c93e54
8 changed files with 85 additions and 9 deletions

View File

@ -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" />

View File

@ -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

View File

@ -16,7 +16,7 @@
*/
#include "../../../test/button.cxx"
#include "../../../test/@ANDROID_APP_NAME@.cxx"
/*

View File

@ -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 {

View File

@ -1,2 +1,3 @@
include ':app'
include ':arc'
include ':hello'

View File

@ -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>

View File

@ -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)

View File

@ -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)