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
--- a/CMakeLists.txt Fri Mar 23 21:56:27 2012 -0400
+++ b/CMakeLists.txt Sat Mar 24 15:52:07 2012 +0100
@@ -193,7 +193,7 @@
add_subdirectory(hedgewars)
#run cmake -DBUILD_ANDROID_PORT=1 to enable this
-if(BUILD_ANDROID_PORT)
+if(ANDROID)
add_subdirectory(project_files/Android-build)
endif()
--- a/cmake_modules/FindLua.cmake Fri Mar 23 21:56:27 2012 -0400
+++ b/cmake_modules/FindLua.cmake Sat Mar 24 15:52:07 2012 +0100
@@ -7,14 +7,18 @@
IF(APPLE)
SET(LUA_DEFAULT lua)
ELSE(APPLE)
- #locate the system's lua library
- FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib)
- IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND")
- #UNSET(LUA_DEFAULT)
- MESSAGE(FATAL_ERROR "Couldn't find Lua 5.1 library!")
- ENDIF()
- #remove the path (fpc doesn't like it - why?)
- GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME)
+ if (ANDROID)
+ SET(LUA_DEFAULT "liblua5.1.so")
+ else (ANDROID)
+ #locate the system's lua library
+ FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib)
+ IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND")
+ #UNSET(LUA_DEFAULT)
+ MESSAGE(FATAL_ERROR "Couldn't find Lua 5.1 library!")
+ ENDIF()
+ #remove the path (fpc doesn't like it - why?)
+ GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME)
+ ENDIF(ANDROID)
ENDIF(APPLE)
ENDIF(WIN32)
SET(LUA_LIBRARY ${LUA_DEFAULT} CACHE STRING "Lua library to link to; file name without path only!")
--- a/project_files/Android-build/CMakeLists.txt Fri Mar 23 21:56:27 2012 -0400
+++ b/project_files/Android-build/CMakeLists.txt Sat Mar 24 15:52:07 2012 +0100
@@ -16,7 +16,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
###################################################################################
-find_program(ANT ant)
+find_program(ANT ant DOC "Path to the java package creator: ant")
if(NOT EXISTS ${ANT})
MESSAGE(FATAL_ERROR "Couldn't detect the Ant build tool")
endif()
@@ -33,17 +33,15 @@
if(NOT ANDROID_NDK_TOOLCHAINDIR)
set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt")
- find_program(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi-as
- "${toolchainbase}/linux-x86/bin"
- "${toolchainbase}/windows/bin")
- get_filename_component(ANDROID_NDK_TOOLCHAINDIR "${ANDROID_NDK_TOOLCHAINDIR}" PATH)
- get_filename_component(ANDROID_NDK_TOOLCHAINDIR "${ANDROID_NDK_TOOLCHAINDIR}" PATH)
+ find_path(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi
+ "${toolchainbase}/linux-x86"
+ "${toolchainbase}/windows")
endif()
if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}")
- MESSAGE(STATUS "Detected the Android NDK toolchain at: " ${ANDROID_NDK_TOOLCHAINDIR})
+ MESSAGE(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}")
else ()
- MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory")
+ MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}")
endif()
if(NOT ANDROID_SDK)#Check if its defined at the cmdline
@@ -62,7 +60,9 @@
if( NOT FPC_DIR)
find_program(FPC_DIR ppcrossarm)
get_filename_component(FPC_DIR "${FPC_DIR}" PATH)
- set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE)
+ if(IS_DIRECTORY "${FPC_DIR}")
+ set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE)
+ endif()
endif()
if( IS_DIRECTORY "${FPC_DIR}")
@@ -81,9 +81,9 @@
configure_file(Templates/Makefile.android .)
-find_program(ANDROID NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools")
-if(ANDROID)
- exec_program(${ANDROID}
+find_program(ANDROID_EXEC NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools")
+if(ANDROID_EXEC)
+ exec_program(${ANDROID_EXEC}
ARGS "update project"
"--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project"
"--target android-${ANDROID_SDK_API_LVL}"
--- a/project_files/Android-build/Templates/Makefile.android Fri Mar 23 21:56:27 2012 -0400
+++ b/project_files/Android-build/Templates/Makefile.android Sat Mar 24 15:52:07 2012 +0100
@@ -1,30 +1,33 @@
-SDL_ANDROID_DIR=./SDL-android-project
+SDL_ANDROID_DIR=${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project
PPCROSSARM=${FPC_DIR}/ppcrossarm
PPCROSSARM_FLAGS= -Xd -O2 -g -Tlinux -XParm-linux-androideabi- -B -vwnh
PPCROSSARM_INCLUDES= \
-FD${ANDROID_NDK_TOOLCHAINDIR}/bin \
- -Fu${FPC_DIR}/rtl/units/arm-linux \
+ -Fu${FPC_DIR}/../rtl/units/arm-linux \
+ -Fu${CMAKE_CURRENT_SOURCE_DIR} \
+ -Fi../../hedgewars \
-Fl${ANDROID_NDK}/platforms/android-${ANDROID_NDK_API_LVL}/arch-arm/usr/lib \
-Fl$(SDL_ANDROID_DIR)/libs/armeabi \
-Fl${ANDROID_NDK_TOOLCHAINDIR}/lib/gcc/arm-linux/arm-linux-androideabi/4.4.3/ \
+
#LINKERFLAGS= -k"--static"
FPC_DEFINES=-dandroid -darm
all: install
build:
- -${CMAKE_COMMAND} -E make_directory out
+ -${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/out
${ANDROID_NDK}/ndk-build -C $(SDL_ANDROID_DIR) -j 8
- $(PPCROSSARM) $(LINKERFLAGS) $(PPCROSSARM_FLAGS) $(PPCROSSARM_INCLUDES) $(FPC_DEFINES) -oout/libhwengine.so ../../hedgewars/hwLibrary.pas
- ${CMAKE_COMMAND} -E copy out/libhwengine.so SDL-android-project/libs/armeabi/
+ $(PPCROSSARM) $(LINKERFLAGS) $(PPCROSSARM_FLAGS) $(PPCROSSARM_INCLUDES) $(FPC_DEFINES) -o${CMAKE_CURRENT_SOURCE_DIR}/out/libhwengine.so ${CMAKE_CURRENT_SOURCE_DIR}/../../hedgewars/hwLibrary.pas
+ ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/out/libhwengine.so $(SDL_ANDROID_DIR)/libs/armeabi/
${ANT} clean -f $(SDL_ANDROID_DIR)/build.xml
${ANT} debug -f $(SDL_ANDROID_DIR)/build.xml
install: build
${ANT} installd -f $(SDL_ANDROID_DIR)/build.xml
clean:
- ${CMAKE_COMMAND} -E remove_directory out
+ ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_SOURCE_DIR}/out
${ANDROID_NDK}/ndk-build -C $(SDL_ANDROID_DIR) -j 8 clean
${ANT} clean -f $(SDL_ANDROID_DIR)/build.xml