SDKBOX CMake integration

SDKBOX CMake integration
0

#1

In case anyone is interested, I’ve managed to get SDKBOX included in the CMake build process, so I no longer need to use Android.mk.

In your /[gamefolder]/CMakeLists.txt, add this:

set(GAME_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(ANDROID)
	add_definitions(-DSDKBOX_ENABLED)
	include_directories(
		${GAME_ROOT_PATH}/proj.android/app/jni/
		${GAME_ROOT_PATH}/proj.android/app/jni/pluginfacebook
		${GAME_ROOT_PATH}/proj.android/app/jni/sdkbox
	)

    if("${ANDROID_STL}" STREQUAL "c++_static")
        set(SDKBOX_LIBS_FOLDER libs_c++_static)
    else()
        set(SDKBOX_LIBS_FOLDER libs)
    endif()

    # sdkbox module
    set(SDKBOX_LIB_PATH ${GAME_ROOT_PATH}/proj.android/app/jni/sdkbox/${SDKBOX_LIBS_FOLDER}/${ANDROID_ABI}/)
    set(_sdkbox_prefix sdkbox)
    set(sdkbox_INCLUDE_DIRS ${SDKBOX_LIB_PATH})
    set(sdkbox_LIBRARIES sdkbox)
    add_library(sdkbox STATIC IMPORTED)
    set_target_properties(sdkbox
                          PROPERTIES IMPORTED_LOCATION
                          ${SDKBOX_LIB_PATH}/libsdkbox.a)

    # PluginFacebook module
    set(FACEBOOK_LIB_PATH ${GAME_ROOT_PATH}/proj.android/app/jni/pluginfacebook/${SDKBOX_LIBS_FOLDER}/${ANDROID_ABI}/)
    set(_PluginFacebook_prefix PluginFacebook)
    set(PluginFacebook_INCLUDE_DIRS ${FACEBOOK_LIB_PATH}/)
    set(PluginFacebook_LIBRARIES PluginFacebook)
    add_library(PluginFacebook STATIC IMPORTED)
    set_target_properties(PluginFacebook
                          PROPERTIES IMPORTED_LOCATION
                          ${FACEBOOK_LIB_PATH}/libPluginFacebook.a)

endif()

and then down the bottom of that file look for “cocos_build_app”, and change it to this:

cocos_build_app(${APP_NAME}
                APP_SRC "${APP_SRC}"
                DEPEND_COMMON_LIBS "cocos2d"
                DEPEND_ANDROID_LIBS "cocos2d_android" "sdkbox" "PluginFacebook"
                )

That’s pretty much it. I hope it helps.


CMake GUI to generate iOS project
How to add library to cocos2d-x project the right way for all(more than one) platforms?
#2

That’s really COOL.

What about iOS platform?


#3

looks good. :smile:


#4

I haven’t got around to working on the iOS version of my app just yet, so I haven’t looked into it, and unfortunately it will be a while before I get around to doing that.