Starting to create CMakeLists to android

This commit is contained in:
Tulioh 2014-12-18 00:31:28 -02:00
parent 5ada7eb5ec
commit 997daa2d49
10 changed files with 108 additions and 8 deletions

View File

@ -19,10 +19,6 @@ endif()
option(USE_PCH "Use precompiled header (speed up compile)" OFF)
set(executable_SOURCES
src/main.cpp
)
# add executable icon for win32 platforms
if(WIN32)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o
@ -35,8 +31,23 @@ endif()
add_definitions(-D"VERSION=\\"${VERSION}\\"")
# add client executable
add_executable(${PROJECT_NAME} ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES})
if(NOT __ANDROID__)
set(executable_SOURCES
src/android.cpp
src/main.cpp
)
# add shared library for android
add_executable(${PROJECT_NAME} ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES})
else()
set(executable_SOURCES
src/main.cpp
)
# add client executable
add_executable(${PROJECT_NAME} ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES})
endif()
target_link_libraries(${PROJECT_NAME} ${framework_LIBRARIES})
if(USE_PCH)

View File

@ -0,0 +1,26 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="otclientmob.tuliohdev.com.otclientmob">
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme"
android:hasCode="false"> <!-- This .apk has no Java code itself, so set hasCode to false. -->
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name"
android:value="native-activity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-10

View File

@ -0,0 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">OTClientMob</string>
</resources>

7
compile_android.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=x86 ..
make
cd ../ && rm -r build && mkdir build && cd build

17
compile_android.sh~ Normal file
View File

@ -0,0 +1,17 @@
#!/bin/sh
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a ..
make
cd ../ && rm -r build && mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=armeabi ..
make
cd ../ && rm -r build && mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE/android.toolchain.cmake -DANDROID_ABI=x86 ..
make
cd ../ && rm -r build

10
src/android.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <jni.h>
#include <main.cpp>
void android_main( struct android_app* state ) {
int argc = 0;
char* argv[] = char[1];
argv[0] = "";
main(argc, argv);
}

10
src/android.cpp~ Normal file
View File

@ -0,0 +1,10 @@
#include <jni.h>
#include <main.cpp>
void android_main( struct android_app* state ) {
int argc = 0;
char* argv[] = char[1];
argv[0] = '';
main(argc, argv);
}

View File

@ -224,7 +224,11 @@ message(STATUS "LuaJIT: " ${LUAJIT})
find_package(PhysFS REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
# android already has zlib
if(NOT __ANDROID__)
find_package(ZLIB REQUIRED)
endif()
set(framework_LIBRARIES ${framework_LIBRARIES}
${Boost_LIBRARIES}

View File

@ -15,4 +15,4 @@ ELSE()
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR)
MARK_AS_ADVANCED(LUA_LIBRARY LUA_INCLUDE_DIR)
MARK_AS_ADVANCED(LUA_LIBRARY LUA_INCLUDE_DIR)