From Rafa Gaitan and Jorge Izquierdo, build support for Android NDK.
"- In order to build against GLES1 we execute: $ mkdir build_android_gles1 $ cd build_android_gles1 $ cmake .. -DOSG_BUILD_PLATFORM_ANDROID=ON -DDYNAMIC_OPENTHREADS=OFF -DDYNAMIC_OPENSCENEGRAPH=OFF -DANDROID_NDK=<path_to_android_ndk>/ -DOSG_GLES1_AVAILABLE=ON -DOSG_GL1_AVAILABLE=OFF -DOSG_GL2_AVAILABLE=OFF -DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF -DJ=2 -DOSG_CPP_EXCEPTIONS_AVAILABLE=OFF $ make If all is correct you will have and static OSG inside: build_android_gles1/bin/ndk/local/armeabi. - GLES2 is not tested/proved, but I think it could be possible build it with the correct cmake flags. - The flag -DJ=2 is used to pass to the ndk-build the number of processors to speed up the building. - make install is not yet supported."
This commit is contained in:
55
CMakeModules/OsgAndroidMacroUtils.cmake
Normal file
55
CMakeModules/OsgAndroidMacroUtils.cmake
Normal file
@@ -0,0 +1,55 @@
|
||||
MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
|
||||
|
||||
foreach(arg ${TARGET_LIBRARIES})
|
||||
set(MODULE_LIBS "${MODULE_LIBS} -l${arg}")
|
||||
endforeach(arg ${TARGET_LIBRARIES})
|
||||
|
||||
foreach(arg ${TARGET_SRC})
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" n_f ${arg})
|
||||
set(MODULE_SOURCES "${MODULE_SOURCES} ${n_f}")
|
||||
endforeach(arg ${TARGET_SRC})
|
||||
|
||||
#SET(MODULE_INCLUDES "${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include")
|
||||
GET_DIRECTORY_PROPERTY(loc_includes INCLUDE_DIRECTORIES)
|
||||
foreach(arg ${loc_includes})
|
||||
IF(NOT "${arg}" MATCHES "/usr/include" AND NOT "${arg}" MATCHES "/usr/local/include")
|
||||
set(MODULE_INCLUDES "${MODULE_INCLUDES} ${arg}")
|
||||
ENDIF()
|
||||
endforeach(arg ${loc_includes})
|
||||
|
||||
GET_DIRECTORY_PROPERTY(loc_definitions COMPILE_DEFINITIONS)
|
||||
foreach(arg ${loc_definitions})
|
||||
set(DEFINITIONS "${DEFINITIONS} -D${arg}")
|
||||
endforeach(arg ${loc_definitions})
|
||||
|
||||
message(STATUS "##############Creating Android Makefile#################")
|
||||
message(STATUS "name: ${LIB_NAME}")
|
||||
|
||||
set(MODULE_NAME ${LIB_NAME})
|
||||
set(MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(MODULE_FLAGS_C ${DEFINITIONS})
|
||||
set(MODULE_FLAGS_CPP ${DEFINITIONS})
|
||||
#TODO: determine if GLES2 or GLES
|
||||
IF(OSG_GLES1_AVAILABLE)
|
||||
SET(OPENGLES_LIBRARY -lGLESv1_CM)
|
||||
ELSEIF(OSG_GLES2_AVAILABLE)
|
||||
SET(OPENGLES_LIBRARY -lGLESv2)
|
||||
ENDIF()
|
||||
set(MODULE_LIBS "${MODULE_LIBS} ${OPENGLES_LIBRARY} -ldl")
|
||||
if(NOT CPP_EXTENSION)
|
||||
set(CPP_EXTENSION "cpp")
|
||||
endif()
|
||||
IF(NOT MODULE_USER_STATIC_OR_DYNAMIC)
|
||||
MESSAGE(FATAL_ERROR "Not defined MODULE_USER_STATIC_OR_DYNAMIC")
|
||||
ENDIF()
|
||||
IF("MODULE_USER_STATIC_OR_DYNAMIC" MATCHES "STATIC")
|
||||
SET(MODULE_BUILD_TYPE "\$\(BUILD_STATIC_LIBRARY\)")
|
||||
ELSE()
|
||||
SET(MODULE_BUILD_TYPE "\$\(BUILD_DYNAMIC_LIBRARY\)")
|
||||
ENDIF()
|
||||
set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} ${LIB_NAME}")
|
||||
set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${CMAKE_CURRENT_BINARY_DIR}/Android.mk \n")
|
||||
|
||||
configure_file("${OSG_ANDROID_TEMPLATES}/Android.mk.modules.in" "${CMAKE_CURRENT_BINARY_DIR}/Android.mk")
|
||||
|
||||
ENDMACRO()
|
||||
Reference in New Issue
Block a user