project_files/Android-build/CMakeLists.txt
author nemo
Sat, 23 Jan 2016 16:07:14 -0500
changeset 11532 44e646598e6a
parent 10108 c68cf030eded
permissions -rw-r--r--
sparkles for dynamite at sheepy's request. he can tweak values if he wishes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5621
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     1
###################################################################################
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     2
# Hedgewars, a free turn based strategy game
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     3
# Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     4
#
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     5
# This program is free software; you can redistribute it and/or modify
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     6
# it under the terms of the GNU General Public License as published by
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     7
# the Free Software Foundation; version 2 of the License
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     8
#
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
     9
# This program is distributed in the hope that it will be useful,
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    12
# GNU General Public License for more details.
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    13
#
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    14
# You should have received a copy of the GNU General Public License
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    15
# along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 10015
diff changeset
    16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
5621
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    17
###################################################################################
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    18
6812
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    19
find_program(ANT ant DOC "Path to the java package creator: ant")
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    20
if(NOT EXISTS ${ANT})
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    21
    message(FATAL_ERROR "Couldn't detect the Ant build tool")
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    22
endif()
5621
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    23
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    24
if(NOT ANDROID_NDK)
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    25
    find_path(ANDROID_NDK ndk-build)
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    26
endif()
5621
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    27
6340
9dd921c0c7e7 added quotes for those with spaces in their path
Xeli
parents: 6230
diff changeset
    28
if(IS_DIRECTORY "${ANDROID_NDK}")
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    29
    message(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK})
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    30
else()
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    31
    message(FATAL_ERROR "Couldn't detect the Android NDK directory")
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    32
endif()
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    33
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    34
if(NOT ANDROID_NDK_TOOLCHAINDIR)
7693
0bdb1dd83b63 Hedgeroid: Update to new NDK toolchain (requires NDK r8b)
Medo <smaxein@googlemail.com>
parents: 6812
diff changeset
    35
    set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt")
6812
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    36
    find_path(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    37
                "${toolchainbase}/linux-x86"
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    38
                "${toolchainbase}/windows")
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    39
endif()
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    40
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    41
if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}")
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    42
    message(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}")
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    43
else()
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    44
    message(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}")
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    45
endif()
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    46
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    47
if(NOT ANDROID_SDK) #Check if its defined at the cmdline
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    48
    find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    49
    get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
6340
9dd921c0c7e7 added quotes for those with spaces in their path
Xeli
parents: 6230
diff changeset
    50
    get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH)
9dd921c0c7e7 added quotes for those with spaces in their path
Xeli
parents: 6230
diff changeset
    51
    set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE)
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    52
endif()
5621
ea796c83ea47 added licenses
Xeli
parents: 5448
diff changeset
    53
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    54
if(IS_DIRECTORY "${ANDROID_SDK}")
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    55
    message(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK})
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    56
else()
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    57
    message(FATAL_ERROR "Couldn't detect the Android SDK directory")
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    58
endif()
5442
7c1e5a5f7f34 Greatly simplifies the buildenvironment plus makes cmake a bit more vocal
Xeli
parents: 5408
diff changeset
    59
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    60
if(NOT FPC_DIR)
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    61
    find_program(FPC_DIR ppcrossarm)
6340
9dd921c0c7e7 added quotes for those with spaces in their path
Xeli
parents: 6230
diff changeset
    62
    get_filename_component(FPC_DIR "${FPC_DIR}" PATH)
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    63
    if(IS_DIRECTORY "${FPC_DIR}")
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    64
        set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE)
6812
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    65
    endif()
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    66
endif()
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    67
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    68
if(IS_DIRECTORY "${FPC_DIR}")
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    69
    message(STATUS "Detected the FreePascal directory at: ${FPC_DIR}")
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9374
diff changeset
    70
else()
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    71
    message(FATAL_ERROR "Couldn't detect the FreePascal directory")
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    72
endif()
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    73
5442
7c1e5a5f7f34 Greatly simplifies the buildenvironment plus makes cmake a bit more vocal
Xeli
parents: 5408
diff changeset
    74
set(SDL_DIR /home/richard/Downloads/android-project)
7c1e5a5f7f34 Greatly simplifies the buildenvironment plus makes cmake a bit more vocal
Xeli
parents: 5408
diff changeset
    75
7c1e5a5f7f34 Greatly simplifies the buildenvironment plus makes cmake a bit more vocal
Xeli
parents: 5408
diff changeset
    76
8042
644231dded72 up android target api (but this commit is actually just to test buildbot: desync
Xeli
parents: 7693
diff changeset
    77
set(ANDROID_SDK_API_LVL 16)
6230
de1e43054017 automated the build process some more, users must add the android ndk, sdk and fpc dir to their $PATH and cmake will do the rest, I still need a solution for the sdl dir. Subrepo's perhaps?
Xeli
parents: 6039
diff changeset
    78
set(ANDROID_NDK_API_LVL 5)
5381
8f95038f3f75 Removed protocol check, using CMake now to setup the building scripts using Templates/* removed old scripts
Xeli
parents:
diff changeset
    79
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    80
message(STATUS "Creating Makefile.android...")
6589
2fa0a274a1e3 some tweaks to the build process, cmake now generates some vital files, fpc only compiles those files which have been changed since the last time, SDL still does not work
Xeli
parents: 6340
diff changeset
    81
2fa0a274a1e3 some tweaks to the build process, cmake now generates some vital files, fpc only compiles those files which have been changed since the last time, SDL still does not work
Xeli
parents: 6340
diff changeset
    82
configure_file(Templates/Makefile.android .)
5442
7c1e5a5f7f34 Greatly simplifies the buildenvironment plus makes cmake a bit more vocal
Xeli
parents: 5408
diff changeset
    83
6812
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    84
find_program(ANDROID_EXEC NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools")
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    85
if(ANDROID_EXEC)
929b467c7277 fixed some typo's. LUA_LIBRARY now points to the right name, regardless of the host machine. Running cmake after a bad attempt (ie forgot to add paths to PATH) now works rather than having to clean the cache
Xeli
parents: 6807
diff changeset
    86
    exec_program(${ANDROID_EXEC}
6589
2fa0a274a1e3 some tweaks to the build process, cmake now generates some vital files, fpc only compiles those files which have been changed since the last time, SDL still does not work
Xeli
parents: 6340
diff changeset
    87
                 ARGS "update project"
2fa0a274a1e3 some tweaks to the build process, cmake now generates some vital files, fpc only compiles those files which have been changed since the last time, SDL still does not work
Xeli
parents: 6340
diff changeset
    88
                 "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project"
2fa0a274a1e3 some tweaks to the build process, cmake now generates some vital files, fpc only compiles those files which have been changed since the last time, SDL still does not work
Xeli
parents: 6340
diff changeset
    89
                 "--target android-${ANDROID_SDK_API_LVL}"
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    90
                 OUTPUT_VARIABLE androidoutput
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    91
                )
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    92
    message(STATUS "Updating android project config...\n" ${androidoutput})
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    93
else()
8146
1fba650c2aa4 GCI2012: Lowercase CMake functions (main files only)
m4tx
parents: 8042
diff changeset
    94
    message(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.")
6807
f4816282ba01 Improved cmake build script for Android:
simmax@googlemail.com
parents: 6619
diff changeset
    95
endif()
5381
8f95038f3f75 Removed protocol check, using CMake now to setup the building scripts using Templates/* removed old scripts
Xeli
parents:
diff changeset
    96
9374
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
    97
##
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
    98
# FIXME: this was useful for early version of SDL 1.3 so is most likely not needed anymore
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
    99
#        if so delete the files referenced here from the repository
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   100
#        commenting out because it inteferes with SDL 2 builds
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   101
##
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   102
#exec_program(${HGCOMMAND}
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   103
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   104
#    OUTPUT_VARIABLE dontcare
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   105
#)
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   106
#exec_program(${HGCOMMAND}
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   107
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   108
#    OUTPUT_VARIABLE dontcare
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   109
#)
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   110
#exec_program(${HGCOMMAND}
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   111
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/file/SDL_rwops.c
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   112
#    OUTPUT_VARIABLE dontcare
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   113
#)
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   114
#exec_program(${HGCOMMAND}
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   115
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL_mixer/Android.mk
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   116
#    OUTPUT_VARIABLE dontcare
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   117
#)
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   118
#exec_program(${HGCOMMAND}
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   119
#    ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL_ttf/Android.mk
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   120
#    OUTPUT_VARIABLE dontcare
60063430445b patching files is so SDL1.3, we're SDL2 nowadays
koda
parents: 8146
diff changeset
   121
#)
6593
6f978fca3711 revert Android.mk back after copying SDL_mixer and SDL_ttf
Xeli
parents: 6591
diff changeset
   122