project_files/Android-build/CMakeLists.txt
changeset 6807 f4816282ba01
parent 6619 229b99faf580
child 6812 929b467c7277
equal deleted inserted replaced
6806:cdfb6c7099e5 6807:f4816282ba01
    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)
    19 find_program(ANT ant)
       
    20 if(NOT EXISTS ${ANT})
       
    21     MESSAGE(FATAL_ERROR "Couldn't detect the Ant build tool")
       
    22 endif()
    20 
    23 
    21 if(NOT ANDROID_NDK)
    24 if(NOT ANDROID_NDK)
    22     find_path(ANDROID_NDK ndk-build)
    25     find_path(ANDROID_NDK ndk-build)
    23 endif()
    26 endif()
    24 
    27 
    26     MESSAGE(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) 
    29     MESSAGE(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) 
    27 else ()
    30 else ()
    28     MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK directory")
    31     MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK directory")
    29 endif()
    32 endif()
    30 
    33 
       
    34 if(NOT ANDROID_NDK_TOOLCHAINDIR)
       
    35     set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt")
       
    36     find_program(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi-as
       
    37                 "${toolchainbase}/linux-x86/bin"
       
    38                 "${toolchainbase}/windows/bin")
       
    39     get_filename_component(ANDROID_NDK_TOOLCHAINDIR "${ANDROID_NDK_TOOLCHAINDIR}" PATH)
       
    40     get_filename_component(ANDROID_NDK_TOOLCHAINDIR "${ANDROID_NDK_TOOLCHAINDIR}" PATH)
       
    41 endif()
       
    42 
       
    43 if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}")
       
    44     MESSAGE(STATUS "Detected the Android NDK toolchain at: " ${ANDROID_NDK_TOOLCHAINDIR}) 
       
    45 else ()
       
    46     MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory")
       
    47 endif()
       
    48 
    31 if(NOT ANDROID_SDK)#Check if its defined at the cmdline
    49 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
    50     find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path
       
    51     get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
    33     get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
    52     get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
    34     set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE)
    53     set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE)
    35 endif()
    54 endif()
    36 
    55 
    37 if( IS_DIRECTORY "${ANDROID_SDK}")
    56 if( IS_DIRECTORY "${ANDROID_SDK}")
    39 else ()
    58 else ()
    40     MESSAGE(FATAL_ERROR "Couldn't detect the Android SDK directory")
    59     MESSAGE(FATAL_ERROR "Couldn't detect the Android SDK directory")
    41 endif()
    60 endif()
    42 
    61 
    43 if( NOT FPC_DIR)
    62 if( NOT FPC_DIR)
    44     find_path(FPC_DIR ppcrossarm)
    63     find_program(FPC_DIR ppcrossarm)
    45     get_filename_component(FPC_DIR "${FPC_DIR}" PATH)
    64     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)
    65     set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE)
    47 endif()
    66 endif()
    48 
    67 
    49 if( IS_DIRECTORY "${FPC_DIR}")
    68 if( IS_DIRECTORY "${FPC_DIR}")
    60 
    79 
    61 MESSAGE(STATUS "Creating Makefile.android...")
    80 MESSAGE(STATUS "Creating Makefile.android...")
    62 
    81 
    63 configure_file(Templates/Makefile.android .)
    82 configure_file(Templates/Makefile.android .)
    64 
    83 
    65 find_program(ANDROID android "${ANDROID_SDK}" "${ANDROID_SDK}/tools")
    84 find_program(ANDROID NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools")
    66 if(ANDROID)
    85 if(ANDROID)
    67     exec_program(${ANDROID}
    86     exec_program(${ANDROID}
    68                  ARGS "update project"
    87                  ARGS "update project"
    69                  "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project"
    88                  "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project"
    70                  "--target android-${ANDROID_SDK_API_LVL}"
    89                  "--target android-${ANDROID_SDK_API_LVL}"
    71                  OUTPUT_VARIABLE dontcare
    90                  OUTPUT_VARIABLE androidoutput
    72                 ) 
    91                 )
    73 endif(ANDROID)
    92     MESSAGE(STATUS "Updating android project config...\n" ${androidoutput})
       
    93 else()
       
    94     MESSAGE(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.")
       
    95 endif()
    74 
    96 
    75 exec_program(${HGCOMMAND}
    97 exec_program(${HGCOMMAND}
    76     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
    77     OUTPUT_VARIABLE dontcare
    99     OUTPUT_VARIABLE dontcare
    78 )
   100 )