1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Android build via CMake (#13528)

* the thing

* the thing 2
This commit is contained in:
sfan5 2023-05-26 15:21:23 +02:00 committed by GitHub
parent 00c647e4cc
commit 8cccd75e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 82 additions and 394 deletions

View file

@ -285,10 +285,8 @@ if(WIN32)
endif()
else()
# Unix probably
if(BUILD_CLIENT)
if(NOT HAIKU AND NOT APPLE)
find_package(X11 REQUIRED)
endif(NOT HAIKU AND NOT APPLE)
if(BUILD_CLIENT AND NOT (HAIKU OR APPLE OR ANDROID))
find_package(X11 REQUIRED)
endif()
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${CMAKE_DL_LIBS})
@ -310,6 +308,14 @@ else()
if (HAIKU)
set(PLATFORM_LIBS ${PLATFORM_LIBS} network)
endif()
if (ANDROID)
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
add_library(native_app_glue OBJECT ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
set(PLATFORM_LIBS ${PLATFORM_LIBS} native_app_glue)
set(PLATFORM_LIBS ${PLATFORM_LIBS} android log)
endif()
endif()
check_include_files(endian.h HAVE_ENDIAN_H)
@ -419,6 +425,10 @@ set(common_SRCS
${UTIL_SRCS}
)
if(ANDROID)
set(common_SRCS ${common_SRCS} porting_android.cpp)
endif()
if(BUILD_UNITTESTS)
set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
endif()
@ -524,7 +534,11 @@ if(NOT CMAKE_CROSSCOMPILING)
endif()
if(BUILD_CLIENT)
add_executable(${PROJECT_NAME} ${client_SRCS} ${extra_windows_SRCS})
if(ANDROID)
add_library(${PROJECT_NAME} SHARED ${client_SRCS})
else()
add_executable(${PROJECT_NAME} ${client_SRCS} ${extra_windows_SRCS})
endif()
add_dependencies(${PROJECT_NAME} GenerateVersion)
target_link_libraries(
${PROJECT_NAME}
@ -874,7 +888,7 @@ if(WIN32)
endif()
endif()
if(BUILD_CLIENT)
if(BUILD_CLIENT AND NOT ANDROID)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BINDIR}
LIBRARY DESTINATION ${BINDIR}
@ -900,13 +914,16 @@ if(BUILD_CLIENT)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt")
endif(BUILD_CLIENT)
endif()
if(BUILD_SERVER)
install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR})
endif()
if (USE_GETTEXT)
if (ANDROID)
# Android does this manually in app/build.gradle -> prepareAssets
# for now!
elseif (USE_GETTEXT)
set(MO_FILES)
foreach(LOCALE ${GETTEXT_USED_LOCALES})

View file

@ -1,27 +1,7 @@
/*
If CMake is used, includes the cmake-generated cmake_config.h.
Otherwise use default values
*/
#pragma once
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
#if defined USE_CMAKE_CONFIG_H
#include "cmake_config.h"
#else
#if defined (__ANDROID__)
#define PROJECT_NAME "minetest"
#define PROJECT_NAME_C "Minetest"
#define STATIC_SHAREDIR ""
#define ENABLE_UPDATE_CHECKER 0
#define VERSION_STRING STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_PATCH) STR(VERSION_EXTRA)
#endif
#ifdef NDEBUG
#define BUILD_TYPE "Release"
#else
#define BUILD_TYPE "Debug"
#endif
#warning Missing configuration
#endif

View file

@ -28,6 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define VERSION_GITHASH VERSION_STRING
#endif
#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)
const char *g_version_string = VERSION_STRING;
const char *g_version_hash = VERSION_GITHASH;
const char *g_build_info =