@YaronCT: Thanks for the information - it allowed me to move forward. Building iconv for Android was not an easy task, but I succeeded in making libiconv.so (note, that libiconv is under LGPL license so one needs to link to it dynamically). I didn't use patch that you mentioned earlier. Instead I used ndk-build and custom Application.mk and Android.mk configs. First I ran ./configure to generate iconv.h header. Next, I modified libcharset/config.h so it wouldn't include <langinfo.h> (nl_langinfo won't be available anyway). After that I manually copied headers and shared library to /opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/user (folders 'lib' and 'include').
Next, I installed previously built Ogre 1.10 to
/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/user - I've noticed that CMake with Android Toolchain automatically searches this paths for headers and libraries (also this is the default CMAKE_INSTALL_PREFIX when configuring project with Android Toolchain - at least on my system). I also installed ogre dependencies there (OIS, zzip, freetype, FreeImage). This allowed cmake to find Ogre along other dependencies.
But I also wanted to build only core CEGUI libraries (static) without samples and CEGUIOgreRenderer. I needed to change
cegui/src/CMakeLists.txt,
cmake/CEGUIMacros.make and
cmake/FindOgre.cmake to achieve this. This should really be option to build only static libs. The 'CEGUI_BUILD_STATIC_CONFIGURATION' causes to build static libraries along with shared ones.
CMake configuration command:
Code: Select all
cmake -DCMAKE_BUILD_TYPE=Release -DCEGUI_BUILD_STATIC_CONFIGURATION=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake__orig -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=10 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DCEGUI_SAMPLES_ENABLED=OFF -DCEGUI_BUILD_RENDERER_OPENGL=OFF -DCEGUI_BUILD_RENDERER_OPENGL3=OFF -DCEGUI_BUILD_RENDERER_OGRE=YES -DCEGUI_USE_GLEW=OFF -DCEGUI_USE_EPOXY=OFF -DCEGUI_USE_MINIBIDI=OFF -DCEGUI_USE_FRIBIDI=OFF ..
Diff for
cmake/FindOgre.cmake (this is so cmake won't complain about X11/XAW dependencies):
Code: Select all
diff -r ed25a866ade7 cmake/FindOgre.cmake
--- a/cmake/FindOgre.cmake Thu Apr 28 21:53:04 2016 +0200
+++ b/cmake/FindOgre.cmake Thu Jul 21 12:51:37 2016 +0200
@@ -234,7 +234,7 @@
if (NOT FREETYPE_FOUND)
set(OGRE_DEPS_FOUND FALSE)
endif ()
- if (UNIX AND NOT APPLE)
+ if (UNIX AND NOT APPLE AND NOT ANDROID)
if (NOT X11_FOUND)
set(OGRE_DEPS_FOUND FALSE)
endif ()
Diff for
cmake/CEGUIMacros.cmake (so only static libraries are being added as targets in CEGUI):
Code: Select all
diff -r ed25a866ade7 cmake/CEGUIMacros.cmake
--- a/cmake/CEGUIMacros.cmake Thu Apr 28 21:53:04 2016 +0200
+++ b/cmake/CEGUIMacros.cmake Thu Jul 21 13:04:39 2016 +0200
@@ -49,11 +49,14 @@
# Add libs to a target, and correctly handles static versions of libs built by the project
#
macro (cegui_target_link_libraries _TARGET_NAME)
- target_link_libraries(${_TARGET_NAME} ${ARGN})
+ if(NOT ANDROID)
+ target_link_libraries(${_TARGET_NAME} ${ARGN})
+ endif()
get_target_property(_TARGET_EXISTS ${_TARGET_NAME}_Static TYPE)
if (_TARGET_EXISTS)
foreach(_LIB ${ARGN})
+
if (${_LIB} STREQUAL optimized OR ${_LIB} STREQUAL debug OR ${_LIB} STREQUAL general)
set (_BUILD ${_LIB})
else()
@@ -243,8 +246,9 @@
###########################################################################
# SHARED LIBRARY SET UP
###########################################################################
- add_library(${_LIB_NAME} ${_LIB_TYPE} ${${_SOURCE_FILES_VAR}} ${${_HEADER_FILES_VAR}})
- set_target_properties(${_LIB_NAME} PROPERTIES DEFINE_SYMBOL ${_CEGUI_EXPORT_DEFINE})
+ if (NOT ANDROID)
+ add_library(${_LIB_NAME} ${_LIB_TYPE} ${${_SOURCE_FILES_VAR}} ${${_HEADER_FILES_VAR}})
+ set_target_properties(${_LIB_NAME} PROPERTIES DEFINE_SYMBOL ${_CEGUI_EXPORT_DEFINE})
if (NOT CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES)
# Starting with CMake 2.8.12 LINK_INTERFACE_LIBRARIES was renamed to INTERFACE_LINK_LIBRARIES
@@ -259,6 +263,8 @@
endif()
endif()
+ endif()
+
if (APPLE)
set_target_properties(${_LIB_NAME} PROPERTIES
INSTALL_NAME_DIR ${CEGUI_APPLE_DYLIB_INSTALL_PATH}
@@ -299,11 +305,13 @@
set(_CEGUI_LIB_DEST ${CEGUI_LIB_INSTALL_DIR})
endif()
- install(TARGETS ${_LIB_NAME}
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION ${_CEGUI_LIB_DEST}
- ARCHIVE DESTINATION ${CEGUI_LIB_INSTALL_DIR}
- )
+ if(NOT ANDROID)
+ install(TARGETS ${_LIB_NAME}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION ${_CEGUI_LIB_DEST}
+ ARCHIVE DESTINATION ${CEGUI_LIB_INSTALL_DIR}
+ )
+ endif()
if (CEGUI_BUILD_STATIC_CONFIGURATION)
install(TARGETS ${_LIB_NAME}_Static
@@ -415,12 +423,14 @@
# Each demo will become a dynamically linked library as plugin (module)
cegui_add_library_impl(${CEGUI_TARGET_NAME} TRUE CORE_SOURCE_FILES CORE_HEADER_FILES FALSE FALSE)
- # Setup custom install location
- install(TARGETS ${CEGUI_TARGET_NAME}
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION ${CEGUI_SAMPLE_INSTALL_DIR}
- ARCHIVE DESTINATION ${CEGUI_SAMPLE_INSTALL_DIR}
- )
+ if(NOT ANDROID)
+ # Setup custom install location
+ install(TARGETS ${CEGUI_TARGET_NAME}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION ${CEGUI_SAMPLE_INSTALL_DIR}
+ ARCHIVE DESTINATION ${CEGUI_SAMPLE_INSTALL_DIR}
+ )
+ endif()
if (CEGUI_BUILD_STATIC_CONFIGURATION)
install(TARGETS ${CEGUI_TARGET_NAME}_Static
Diff for
cegui/src/CMakeLists.txt:
Code: Select all
diff -r ed25a866ade7 cegui/src/CMakeLists.txt
--- a/cegui/src/CMakeLists.txt Thu Apr 28 21:53:04 2016 +0200
+++ b/cegui/src/CMakeLists.txt Thu Jul 21 12:51:13 2016 +0200
@@ -58,7 +58,11 @@
# multiple sub-dirs.
cegui_add_library_impl(${CEGUI_TARGET_NAME} FALSE CORE_SOURCE_FILES ALL_HEADER_FILES TRUE FALSE)
if (ANDROID)
- target_link_libraries (${CEGUI_TARGET_NAME} log)
+ if(CEGUI_BUILD_STATIC_CONFIGURATION)
+ target_link_libraries (${CEGUI_TARGET_NAME}_Static log)
+ else()
+ target_link_libraries (${CEGUI_TARGET_NAME} log)
+ endif()
endif ()
source_group("Source Files\\widget" FILES ${WIDGET_SOURCE_FILES})
@@ -67,7 +71,7 @@
source_group("Header Files\\widget" FILES ${WIDGET_HEADER_FILES})
source_group("Header Files\\falagard" FILES ${FALAGARD_HEADER_FILES})
-if (NOT WIN32 AND NOT ANDROID)
+if (NOT WIN32)
cegui_add_dependency(${CEGUI_TARGET_NAME} ICONV)
endif()
@@ -92,11 +96,17 @@
if (WIN32 AND NOT MINGW)
cegui_target_link_libraries(${CEGUI_TARGET_NAME} winmm debug DbgHelp)
+elseif (ANDROID AND NOT APPLE)
+ if(CEGUI_BUILD_STATIC_CONFIGURATION)
+ target_link_libraries(${CEGUI_TARGET_NAME}_Static ${CMAKE_DL_LIBS})
+ else()
+ target_link_libraries(${CEGUI_TARGET_NAME} ${CMAKE_DL_LIBS})
+ endif()
elseif (UNIX AND NOT APPLE)
# This is intentionally not using 'cegui_target_link_libraries'
target_link_libraries(${CEGUI_TARGET_NAME} ${CMAKE_DL_LIBS})
elseif (MINGW)
- cegui_target_link_libraries(${CEGUI_TARGET_NAME} ${CMAKE_DL_LIBS})
+ cegui_target_link_libraries(${CEGUI_TARGET_NAME} ${CMAKE_DL_LIBS})
endif()
if (APPLE AND CEGUI_BUILD_SHARED_LIBS_WITH_STATIC_DEPENDENCIES)
Please note that I made these changes to build only static CEGUI libraries for Android (with Ogre renderer component). Better would be to add option like 'CEGUI_BUILD_STATIC_ONLY' or something similar. In the end:
Code: Select all
[ 77%] Built target CEGUIBase-0_Static
[ 81%] Built target CEGUIOgreRenderer-0_Static
[ 83%] Built target CEGUIFreeImageImageCodec_Static
[ 97%] Built target CEGUICoreWindowRendererSet_Static
[100%] Built target CEGUICommonDialogs-0_Static
It builds without errors. But does it work? I haven't tested it yet - that's a different story (need to build Android application and link these static libs). Thanks again @YaronCT for pointing me in the right direction.