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 DOC "Path to the java package creator: ant") |
19 find_program(ANT ant DOC "Path to the java package creator: ant") |
20 if(NOT EXISTS ${ANT}) |
20 if(NOT EXISTS ${ANT}) |
21 MESSAGE(FATAL_ERROR "Couldn't detect the Ant build tool") |
21 message(FATAL_ERROR "Couldn't detect the Ant build tool") |
22 endif() |
22 endif() |
23 |
23 |
24 if(NOT ANDROID_NDK) |
24 if(NOT ANDROID_NDK) |
25 find_path(ANDROID_NDK ndk-build) |
25 find_path(ANDROID_NDK ndk-build) |
26 endif() |
26 endif() |
27 |
27 |
28 if(IS_DIRECTORY "${ANDROID_NDK}") |
28 if(IS_DIRECTORY "${ANDROID_NDK}") |
29 MESSAGE(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) |
29 message(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) |
30 else () |
30 else () |
31 MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK directory") |
31 message(FATAL_ERROR "Couldn't detect the Android NDK directory") |
32 endif() |
32 endif() |
33 |
33 |
34 if(NOT ANDROID_NDK_TOOLCHAINDIR) |
34 if(NOT ANDROID_NDK_TOOLCHAINDIR) |
35 set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt") |
35 set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt") |
36 find_path(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi |
36 find_path(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi |
37 "${toolchainbase}/linux-x86" |
37 "${toolchainbase}/linux-x86" |
38 "${toolchainbase}/windows") |
38 "${toolchainbase}/windows") |
39 endif() |
39 endif() |
40 |
40 |
41 if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}") |
41 if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}") |
42 MESSAGE(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}") |
42 message(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}") |
43 else () |
43 else () |
44 MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}") |
44 message(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}") |
45 endif() |
45 endif() |
46 |
46 |
47 if(NOT ANDROID_SDK)#Check if its defined at the cmdline |
47 if(NOT ANDROID_SDK)#Check if its defined at the cmdline |
48 find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path |
48 find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path |
49 get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH) |
49 get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH) |
50 get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH) |
50 get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH) |
51 set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE) |
51 set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE) |
52 endif() |
52 endif() |
53 |
53 |
54 if( IS_DIRECTORY "${ANDROID_SDK}") |
54 if( IS_DIRECTORY "${ANDROID_SDK}") |
55 MESSAGE(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK}) |
55 message(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK}) |
56 else () |
56 else () |
57 MESSAGE(FATAL_ERROR "Couldn't detect the Android SDK directory") |
57 message(FATAL_ERROR "Couldn't detect the Android SDK directory") |
58 endif() |
58 endif() |
59 |
59 |
60 if( NOT FPC_DIR) |
60 if( NOT FPC_DIR) |
61 find_program(FPC_DIR ppcrossarm) |
61 find_program(FPC_DIR ppcrossarm) |
62 get_filename_component(FPC_DIR "${FPC_DIR}" PATH) |
62 get_filename_component(FPC_DIR "${FPC_DIR}" PATH) |
64 set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE) |
64 set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE) |
65 endif() |
65 endif() |
66 endif() |
66 endif() |
67 |
67 |
68 if( IS_DIRECTORY "${FPC_DIR}") |
68 if( IS_DIRECTORY "${FPC_DIR}") |
69 MESSAGE(STATUS "Detected the FreePascal directory at: " "${FPC_DIR}") |
69 message(STATUS "Detected the FreePascal directory at: " "${FPC_DIR}") |
70 else () |
70 else () |
71 MESSAGE(FATAL_ERROR "Couldn't detect the FreePascal directory") |
71 message(FATAL_ERROR "Couldn't detect the FreePascal directory") |
72 endif() |
72 endif() |
73 |
73 |
74 set(SDL_DIR /home/richard/Downloads/android-project) |
74 set(SDL_DIR /home/richard/Downloads/android-project) |
75 |
75 |
76 |
76 |
77 set(ANDROID_SDK_API_LVL 16) |
77 set(ANDROID_SDK_API_LVL 16) |
78 set(ANDROID_NDK_API_LVL 5) |
78 set(ANDROID_NDK_API_LVL 5) |
79 |
79 |
80 MESSAGE(STATUS "Creating Makefile.android...") |
80 message(STATUS "Creating Makefile.android...") |
81 |
81 |
82 configure_file(Templates/Makefile.android .) |
82 configure_file(Templates/Makefile.android .) |
83 |
83 |
84 find_program(ANDROID_EXEC NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools") |
84 find_program(ANDROID_EXEC NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools") |
85 if(ANDROID_EXEC) |
85 if(ANDROID_EXEC) |
87 ARGS "update project" |
87 ARGS "update project" |
88 "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project" |
88 "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project" |
89 "--target android-${ANDROID_SDK_API_LVL}" |
89 "--target android-${ANDROID_SDK_API_LVL}" |
90 OUTPUT_VARIABLE androidoutput |
90 OUTPUT_VARIABLE androidoutput |
91 ) |
91 ) |
92 MESSAGE(STATUS "Updating android project config...\n" ${androidoutput}) |
92 message(STATUS "Updating android project config...\n" ${androidoutput}) |
93 else() |
93 else() |
94 MESSAGE(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.") |
94 message(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.") |
95 endif() |
95 endif() |
96 |
96 |
97 exec_program(${HGCOMMAND} |
97 exec_program(${HGCOMMAND} |
98 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp |
98 ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp |
99 OUTPUT_VARIABLE dontcare |
99 OUTPUT_VARIABLE dontcare |