14 # You should have received a copy of the GNU General Public License |
14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software |
15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 ################################################################################### |
17 ################################################################################### |
18 |
18 |
|
19 find_program(ANT ant) |
|
20 |
|
21 if(NOT ANDROID_NDK) |
|
22 find_path(ANDROID_NDK ndk-build) |
|
23 endif() |
|
24 |
|
25 if(IS_DIRECTORY ${ANDROID_NDK}) |
|
26 MESSAGE(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) |
|
27 else () |
|
28 MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK directory") |
|
29 endif() |
|
30 |
|
31 if(NOT ANDROID_SDK)#Check if its defined at the cmdline |
|
32 find_path(ANDROID_SDK adb ) #assume they've added platform-tools to their path |
|
33 get_filename_component(ANDROID_SDK ${ANDROID_SDK} PATH) |
|
34 set(ANDROID_SDK ${ANDROID_SDK} CACHE PATH "Path to the android sdk" FORCE) |
|
35 endif() |
|
36 |
|
37 if( IS_DIRECTORY ${ANDROID_SDK}) |
|
38 MESSAGE(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK}) |
|
39 else () |
|
40 MESSAGE(FATAL_ERROR "Couldn't detect the Android SDK directory") |
|
41 endif() |
|
42 |
|
43 if( NOT FPC_DIR) |
|
44 find_path(FPC_DIR ppcrossarm) |
|
45 get_filename_component(FPC_DIR ${FPC_DIR} PATH) |
|
46 set(FPC_DIR ${FPC_DIR} CACHE PATH "Path to fpc dir used in the android port" FORCE) |
|
47 endif() |
|
48 |
|
49 if( IS_DIRECTORY ${FPC_DIR}) |
|
50 MESSAGE(STATUS "Detected the FreePascal directory at: " ${FPC_DIR}) |
|
51 else () |
|
52 MESSAGE(FATAL_ERROR "Couldn't detect the FreePascal directory") |
|
53 endif() |
|
54 |
|
55 set(SDL_DIR /home/richard/Downloads/android-project) |
19 |
56 |
20 |
57 |
|
58 set(ANDROID_SDK_API_LVL 8) |
|
59 set(ANDROID_NDK_API_LVL 5) |
21 |
60 |
22 ################################################################################### |
61 MESSAGE(STATUS "Creating android scripts and configuration files") |
23 # Uncomment (remove the leading '#') and change the paths accordingly to your own |
|
24 # build environment, please do specify an absolute path (/home/richard/SoftDev |
|
25 # rather than ~/SoftDev). |
|
26 # You only need to change the three lines below, after that you can run 'cmake .' |
|
27 # from the hedgewars root directory |
|
28 # |
|
29 # optionally you can specify SDL_DIR this will move the required SDL libraries to |
|
30 # the correct place |
|
31 ################################################################################## |
|
32 |
62 |
33 set(ANDROID_NDK /home/richard/SoftDev/android/android-ndk-r5b) |
63 configure_file(Templates/complete_build.sh .) |
34 set(ANDROID_SDK /home/richard/SoftDev/android/android-sdk-linux_86) |
64 configure_file(Templates/default.properties SDL-android-project/) |
35 set(FPC_DIR /home/richard/SoftDev/fpc-2.4.4) |
65 configure_file(Templates/local.properties SDL-android-project/) |
36 set(SDL_DIR /home/richard/Downloads/android-project) |
66 configure_file(Templates/Makefile.android .) |
|
67 configure_file(Templates/pushToDevice.sh .) |
37 |
68 |
38 if(ANDROID_NDK AND ANDROID_SDK AND FPC_DIR) |
69 if(SDL_DIR_TEMP_DISABLE) |
|
70 MESSAGE("Moving Android port of SDL to the proper directories") |
|
71 set(DirsToCopy |
|
72 SDL |
|
73 SDL_image |
|
74 SDL_mixer |
|
75 SDL_ttf |
|
76 jpeg |
|
77 png |
|
78 mikmod |
|
79 ) |
|
80 foreach(DIR ${DirsToCopy}) |
|
81 exec_program( |
|
82 ${CMAKE_COMMAND} |
|
83 ARGS -E copy_directory |
|
84 ${SDL_DIR}/jni/${DIR} |
|
85 ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/${DIR} |
|
86 ) |
|
87 MESSAGE(STATUS "Moved ${DIR}") |
|
88 endforeach(DIR) |
|
89 exec_program(${HGCOMMAND} |
|
90 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp |
|
91 ) |
|
92 exec_program(${HGCOMMAND} |
|
93 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp |
|
94 ) |
|
95 exec_program(${HGCOMMAND} |
|
96 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.c |
|
97 ) |
39 |
98 |
40 set(ANDROID_SDK_API_LVL 8) |
99 exec_program(${HGCOMMAND} |
41 set(ANDROID_NDK_API_LVL 5) |
100 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.h |
42 |
101 ) |
43 MESSAGE("Creating android scripts and configuration files") |
102 endif(SDL_DIR_TEMP_DISABLE) |
44 |
|
45 configure_file(Templates/complete_build.sh .) |
|
46 configure_file(Templates/default.properties SDL-android-project/) |
|
47 configure_file(Templates/local.properties SDL-android-project/) |
|
48 configure_file(Templates/Makefile.android .) |
|
49 configure_file(Templates/pushToDevice.sh .) |
|
50 |
|
51 if(SDL_DIR) |
|
52 |
|
53 MESSAGE("Moving Android port of SDL to the proper directories") |
|
54 |
|
55 set(DirsToCopy |
|
56 SDL |
|
57 SDL_image |
|
58 SDL_mixer |
|
59 SDL_ttf |
|
60 jpeg |
|
61 png |
|
62 mikmod |
|
63 ) |
|
64 foreach(DIR ${DirsToCopy}) |
|
65 exec_program( |
|
66 ${CMAKE_COMMAND} |
|
67 ARGS -E copy_directory |
|
68 ${SDL_DIR}/jni/${DIR} |
|
69 ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/${DIR} |
|
70 ) |
|
71 MESSAGE("Moved ${DIR}") |
|
72 endforeach(DIR) |
|
73 exec_program(${HGCOMMAND} |
|
74 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp |
|
75 ) |
|
76 exec_program(${HGCOMMAND} |
|
77 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp |
|
78 ) |
|
79 exec_program(${HGCOMMAND} |
|
80 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.c |
|
81 ) |
|
82 |
|
83 exec_program(${HGCOMMAND} |
|
84 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.h |
|
85 ) |
|
86 |
|
87 |
|
88 else(SDL_DIR) |
|
89 MESSAGE("Android port of SDL not moved..") |
|
90 endif(SDL_DIR) |
|
91 |
|
92 |
|
93 else(ANDROID_AND AND ANDROID_SDK AND FPC_DIR) |
|
94 MESSAGE("Android port files not created, edit top of ${CMAKE_CURRENT_SOURCE_DIR}/CMakeList.txt to create android specific files") |
|
95 endif(ANDROID_NDK AND ANDROID_SDK AND FPC_DIR) |
|
96 |
|
97 |
|