Android CMake: icons, docs, more apps

This commit is contained in:
Matthias Melcher 2019-01-17 21:29:24 +01:00
parent 111985665d
commit 2f0e45e7a7
9 changed files with 62 additions and 122 deletions

View File

@ -13,25 +13,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Modified to be a template for Android builds in FLTK
# Copyright 2019 Matthias Melcher and others
#
cmake_minimum_required(VERSION 3.4.1)
set(FLTK_DIR ../../../../../../..)
set(FLTK_IDE_DIR ../../../..)
set(FLTK_DIR "@ANDROID_FLTK_DIR@")
set(FLTK_IDE_DIR "../../../..")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# FIXME: add as a second argument the binary build dir
# so that the first argument can link directly to FLTK
# instead of the fltk symlink, which is bad for SVN
add_subdirectory(${FLTK_DIR}/ "${CMAKE_CURRENT_BINARY_DIR}/lib" EXCLUDE_FROM_ALL)
# FIXME: this includes the entire CMakeLists again, creating an entire library
# build in every target
# TODO: create separate targets for all fltk libraries that can be easily
# linked by all app targets
add_subdirectory("${FLTK_DIR}/" "${CMAKE_CURRENT_BINARY_DIR}/lib" EXCLUDE_FROM_ALL)
# run FLuid commands if any
# run Fluid build steps for every .fl file, if any
@ANDROID_FLUID_COMMANDS@
# copy source files
@ANDROID_APP_COPY_SOURCES@
# now build app's shared lib
add_library(
test_@ANDROID_APP_NAME@ SHARED
@ -48,6 +48,8 @@ set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate")
# add lib dependencies
# FIXME: apps may depend on additional fltk libraries; thise dependencies
# must be created in the CREATE_ANDROID_IDE_FOR_TEST macro
target_link_libraries(
test_@ANDROID_APP_NAME@
fltk

BIN
CMake/Android/hdpi.ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
CMake/Android/mdpi.ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
CMake/Android/xhdpi.ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
CMake/Android/xxhdpi.ic_launcher.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -17,95 +17,38 @@
# http://www.fltk.org/str.php
#
# all target modules will be added here later
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/settings.gradle.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/settings.gradle"
@ONLY
)
# configuration file for all modules
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/build.gradle.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/build.gradle"
@ONLY
)
# create a custom abi file for this setup
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/abi-version.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/FL/abi-version.h"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/app.build.gradle.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/build.gradle"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/AndroidManifest.xml.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/AndroidManifest.xml"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/Roboto-Regular.ttf"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/assets/fonts/Roboto-Regular.ttf"
COPYONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/mdpi.ic_launcher.png"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/res/mipmap-mdpi/ic_launcher.png"
COPYONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/hdpi.ic_launcher.png"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/res/mipmap-hdpi/ic_launcher.png"
COPYONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/xhdpi.ic_launcher.png"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/res/mipmap-xhdpi/ic_launcher.png"
COPYONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/xxhdpi.ic_launcher.png"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/res/mipmap-xxhdpi/ic_launcher.png"
COPYONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/strings.xml.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/res/values/strings.xml"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/CMakeList.txt.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/cpp/CMakeLists.txt"
@ONLY
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMake/Android/HelloAndroid.cxx.in"
"${CMAKE_CURRENT_BINARY_DIR}/AndroidStudio/app/src/main/cpp/HelloAndroid.cxx"
@ONLY
)
# TODO: where should we create config.h?
macro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
message(STATUS "Creating Android IDE for ${NAME}")
# message(STATUS "Creating Android IDE for ${NAME}")
set (ANDROID_APP_NAME ${NAME})
set (ANDROID_FLTK_DIR ${CMAKE_SOURCE_DIR})
set (srcs)
set (ANDROID_APP_SOURCES)
set (ANDROID_APP_COPY_SOURCES)
set (ANDROID_FLUID_COMMANDS)
set (flsrcs) # fluid source files
foreach(src ${SOURCES})
@ -113,24 +56,23 @@ macro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
list(APPEND flsrcs ${src})
string(REGEX REPLACE "(.*).fl" \\1 basename ${src})
string(APPEND ANDROID_FLUID_COMMANDS
"add_custom_command( OUTPUT \"${basename}.cxx\" \"${basename}.h\"\n"
" OUTPUT \"${basename}.cxx\" \"${basename}.h\"\n"
" COMMAND fluid -c \"\${CMAKE_CURRENT_SOURCE_DIR}/${src}\"\n"
" DEPENDS ${src}\n"
" MAIN_DEPENDENCY ${src}\n"
"add_custom_command(\n"
" OUTPUT \"\${FLTK_DIR}/test/${basename}.cxx\" \"\${FLTK_DIR}/test/${basename}.h\"\n"
" COMMAND fluid -c \"${src}\"\n"
" WORKING_DIRECTORY \"\${FLTK_DIR}/test\"\n"
" DEPENDS \"\${FLTK_DIR}/test/${src}\"\n"
" MAIN_DEPENDENCY \"\${FLTK_DIR}/test/${src}\"\n"
")\n\n"
)
file(TOUCH "${basename}.cxx")
file(TOUCH "${basename}.h")
file(TOUCH "${basename}.fl")
set(src_cxx ${basename}.cxx)
else ()
list(APPEND srcs ${src})
set(src_cxx ${src})
endif ("${src}" MATCHES "\\.fl$")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/cpp/")
# FIXME: Unix only for older version of CMake
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_CURRENT_SOURCE_DIR}/${src}"
"${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/cpp/${src}")
string(APPEND ANDROID_APP_SOURCES " ${src_cxx}\n")
string(APPEND ANDROID_APP_SOURCES " \"\${FLTK_DIR}/test/${src_cxx}\"\n")
endforeach(src)
configure_file(
@ -187,12 +129,6 @@ macro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
@ONLY
)
configure_file(
"${CMAKE_SOURCE_DIR}/CMake/Android/HelloAndroid.cxx.in"
"${CMAKE_BINARY_DIR}/AndroidStudio/${ANDROID_APP_NAME}/src/main/cpp/HelloAndroid.cxx"
@ONLY
)
file(APPEND "${CMAKE_BINARY_DIR}/AndroidStudio/settings.gradle" "include ':${ANDROID_APP_NAME}'\n")
endmacro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
@ -200,7 +136,7 @@ endmacro(CREATE_ANDROID_IDE_FOR_TEST NAME SOURCES LIBRARIES)
macro(CREATE_ANDROID_IDE_WRAPUP)
message(STATUS "Wrapping up Android IDE creation")
# message(STATUS "Wrapping up Android IDE creation")
endmacro(CREATE_ANDROID_IDE_WRAPUP)

View File

@ -188,6 +188,17 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES)
target_link_libraries(${tname} ${LIBRARIES})
# CREATE_EXAMPLE can have an optional fourth argument with a list of options
# - the option ANDROID_OK is set if CREATE_EXAMPLE creates code for Androids
# builds in addition to the native build
if (${ARGC} GREATER 3)
foreach(OPTION ${ARGV3})
if (${OPTION} STREQUAL ANDROID_OK AND OPTION_CREATE_ANDROID_STUDIO_IDE)
CREATE_ANDROID_IDE_FOR_TEST(${NAME} ${SOURCES} ${LIBRARIES})
endif()
endforeach()
endif()
endmacro(CREATE_EXAMPLE NAME SOURCES LIBRARIES)
#######################################################################

View File

@ -396,7 +396,7 @@ void Fl_Text_Display::buffer( Fl_Text_Buffer *buf ) {
Styles are ranged from 65 ('A') to 126.
\param styleBuffer this buffer works in parallel to the text buffer. For every
character in the text buffer, the stye buffer has a byte at the same offset
character in the text buffer, the style buffer has a byte at the same offset
that contains an index into an array of possible styles.
\param styleTable a list of styles indexed by the style buffer
\param nStyles number of styles in the style table

View File

@ -3,7 +3,7 @@
#
# CMakeLists.txt used to build test and demo apps by the CMake build system
#
# Copyright 2004-2018 by Bill Spitzak and others.
# Copyright 2004-2019 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file. If this
@ -39,39 +39,30 @@ include_directories(
)
#######################################################################
## testing creation of Android Studio IDE files
if (OPTION_CREATE_ANDROID_STUDIO_IDE)
CREATE_ANDROID_IDE_FOR_TEST(arc arc.cxx fltk)
CREATE_ANDROID_IDE_FOR_TEST(hello hello.cxx fltk)
CREATE_ANDROID_IDE_FOR_TEST(input input.cxx fltk)
CREATE_ANDROID_IDE_FOR_TEST(inactive inactive.fl fltk)
# FIXME: fails because in the current schmeme, we can't find the .h files
#CREATE_ANDROID_IDE_FOR_TEST(keyboard "keyboard.cxx;keyboard_ui.fl" fltk)
endif (OPTION_CREATE_ANDROID_STUDIO_IDE)
#######################################################################
# Add the ANDROID_OK option if the example can be compiled for Android
# as well as for other platforms.
if(NOT ANDROID)
CREATE_EXAMPLE(adjuster adjuster.cxx fltk)
CREATE_EXAMPLE(arc arc.cxx fltk)
CREATE_EXAMPLE(animated animated.cxx fltk)
CREATE_EXAMPLE(ask ask.cxx fltk)
CREATE_EXAMPLE(bitmap bitmap.cxx fltk)
CREATE_EXAMPLE(adjuster adjuster.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(arc arc.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(animated animated.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(ask ask.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(bitmap bitmap.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(blocks blocks.cxx "fltk;${AUDIOLIBS}")
CREATE_EXAMPLE(boxtype boxtype.cxx fltk)
CREATE_EXAMPLE(browser browser.cxx fltk)
CREATE_EXAMPLE(button button.cxx fltk)
CREATE_EXAMPLE(buttons buttons.cxx fltk)
CREATE_EXAMPLE(checkers checkers.cxx fltk)
CREATE_EXAMPLE(clock clock.cxx fltk)
CREATE_EXAMPLE(boxtype boxtype.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(browser browser.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(button button.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(buttons buttons.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(checkers checkers.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(clock clock.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(colbrowser colbrowser.cxx "fltk;fltk_forms")
CREATE_EXAMPLE(color_chooser color_chooser.cxx fltk)
CREATE_EXAMPLE(cursor cursor.cxx fltk)
CREATE_EXAMPLE(curve curve.cxx fltk)
CREATE_EXAMPLE(color_chooser color_chooser.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(cursor cursor.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(curve curve.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(demo demo.cxx fltk)
CREATE_EXAMPLE(device device.cxx fltk)
CREATE_EXAMPLE(doublebuffer doublebuffer.cxx fltk)
CREATE_EXAMPLE(editor editor.cxx fltk)
CREATE_EXAMPLE(fast_slow fast_slow.fl fltk)
CREATE_EXAMPLE(doublebuffer doublebuffer.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(editor editor.cxx fltk ANDROID_OK)
CREATE_EXAMPLE(fast_slow fast_slow.fl fltk ANDROID_OK)
CREATE_EXAMPLE(file_chooser file_chooser.cxx "fltk;fltk_images")
CREATE_EXAMPLE(fonts fonts.cxx fltk)
CREATE_EXAMPLE(forms forms.cxx "fltk;fltk_forms")