浏览代码

adjust project for Android (except AI)

Andrey Filipenkov 2 年之前
父节点
当前提交
970bd6ed34

+ 7 - 2
AI/CMakeLists.txt

@@ -31,6 +31,9 @@ if(NOT fuzzylite_FOUND)
     set(FL_BUILD_BINARY OFF CACHE BOOL "")
     set(FL_BUILD_BINARY OFF CACHE BOOL "")
     set(FL_BUILD_SHARED OFF CACHE BOOL "")
     set(FL_BUILD_SHARED OFF CACHE BOOL "")
 	set(FL_BUILD_TESTS OFF CACHE BOOL "")
 	set(FL_BUILD_TESTS OFF CACHE BOOL "")
+	if(ANDROID)
+		set(FL_BACKTRACE OFF CACHE BOOL "" FORCE)
+	endif()
 	#It is for compiling FuzzyLite, it will not compile without it on GCC
 	#It is for compiling FuzzyLite, it will not compile without it on GCC
 	if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
 	if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
 		add_compile_options(-Wno-error=deprecated-declarations)
 		add_compile_options(-Wno-error=deprecated-declarations)
@@ -45,9 +48,11 @@ endif()
 #######################################
 #######################################
 
 
 add_subdirectory(BattleAI)
 add_subdirectory(BattleAI)
-add_subdirectory(StupidAI)
-add_subdirectory(EmptyAI)
 add_subdirectory(VCAI)
 add_subdirectory(VCAI)
+if(NOT ANDROID)
+	add_subdirectory(StupidAI)
+	add_subdirectory(EmptyAI)
+endif()
 if(ENABLE_NULLKILLER_AI)
 if(ENABLE_NULLKILLER_AI)
 	add_subdirectory(Nullkiller)
 	add_subdirectory(Nullkiller)
 endif()
 endif()

+ 67 - 11
CMakeLists.txt

@@ -41,10 +41,15 @@ if(NOT CMAKE_BUILD_TYPE)
 	set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo)
 	set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo)
 endif()
 endif()
 
 
+set(qtParts ON)
+if(ANDROID)
+	set(qtParts OFF)
+endif()
+
 option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
 option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
 option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
 option(ENABLE_LUA "Enable compilation of LUA scripting module" OFF)
-option(ENABLE_LAUNCHER "Enable compilation of launcher" ON)
-option(ENABLE_EDITOR "Enable compilation of map editor" ON)
+option(ENABLE_LAUNCHER "Enable compilation of launcher" ${qtParts})
+option(ENABLE_EDITOR "Enable compilation of map editor" ${qtParts})
 option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
 option(ENABLE_TRANSLATIONS "Enable generation of translations for launcher and editor" ON)
 option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
 option(ENABLE_NULLKILLER_AI "Enable compilation of Nullkiller AI library" ON)
 
 
@@ -64,7 +69,7 @@ option(ENABLE_SINGLE_APP_BUILD "Builds client and server as single executable" O
 option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON)
 option(COPY_CONFIG_ON_BUILD "Copies config folder into output directory at building phase" ON)
 
 
 # Used for Snap packages and also useful for debugging
 # Used for Snap packages and also useful for debugging
-if(NOT APPLE_IOS)
+if(NOT APPLE_IOS AND NOT ANDROID)
 	option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)
 	option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)
 endif()
 endif()
 
 
@@ -81,8 +86,8 @@ if(ENABLE_ERM AND NOT ENABLE_LUA)
 	set(ENABLE_LUA ON)
 	set(ENABLE_LUA ON)
 endif()
 endif()
 
 
-# We don't want to deploy assets into build directory for iOS build
-if(APPLE_IOS AND COPY_CONFIG_ON_BUILD)
+# We don't want to deploy assets into build directory for android/iOS build
+if((APPLE_IOS OR ANDROID) AND COPY_CONFIG_ON_BUILD)
 	set(COPY_CONFIG_ON_BUILD OFF)
 	set(COPY_CONFIG_ON_BUILD OFF)
 endif()
 endif()
 
 
@@ -95,6 +100,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules ${PROJECT_SOURCE_DIR
 
 
 include(VCMIUtils)
 include(VCMIUtils)
 include(VersionDefinition)
 include(VersionDefinition)
+if(ANDROID)
+	set(VCMI_VERSION "${APP_SHORT_VERSION}")
+	configure_file("android/GeneratedVersion.java.in" "${CMAKE_SOURCE_DIR}/android/vcmi-app/src/main/java/eu/vcmi/vcmi/util/GeneratedVersion.java" @ONLY)
+endif()
 
 
 vcmi_print_important_variables()
 vcmi_print_important_variables()
 
 
@@ -280,6 +289,15 @@ if(MINGW OR MSVC)
 	endif(MINGW)
 	endif(MINGW)
 endif(MINGW OR MSVC)
 endif(MINGW OR MSVC)
 
 
+if(ANDROID)
+	if(ANDROID_NDK_MAJOR LESS 23 AND ANDROID_ABI MATCHES "^armeabi")
+		# libunwind must come before other shared libs:
+		# https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Unwinding
+		list(APPEND SYSTEM_LIBS unwind)
+	endif()
+	list(APPEND SYSTEM_LIBS log)
+endif()
+
 if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32)
 if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32)
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith")
@@ -447,6 +465,10 @@ elseif(APPLE)
 			set(DATA_DIR ".")
 			set(DATA_DIR ".")
 		endif()
 		endif()
 	endif()
 	endif()
+elseif(ANDROID)
+	include(GNUInstallDirs)
+	set(LIB_DIR "jniLibs/${ANDROID_ABI}")
+	set(DATA_DIR "assets")
 else()
 else()
 	# includes lib path which determines where to install shared libraries (either /lib or /lib64)
 	# includes lib path which determines where to install shared libraries (either /lib or /lib64)
 	include(GNUInstallDirs)
 	include(GNUInstallDirs)
@@ -482,8 +504,8 @@ else()
 	endif()
 	endif()
 endif()
 endif()
 
 
-# iOS has flat libs directory structure
-if(APPLE_IOS)
+# iOS/Android have flat libs directory structure
+if(APPLE_IOS OR ANDROID)
 	set(AI_LIB_DIR "${LIB_DIR}")
 	set(AI_LIB_DIR "${LIB_DIR}")
 	set(SCRIPTING_LIB_DIR "${LIB_DIR}")
 	set(SCRIPTING_LIB_DIR "${LIB_DIR}")
 else()
 else()
@@ -535,14 +557,48 @@ endif()
 #        Installation section         #
 #        Installation section         #
 #######################################
 #######################################
 
 
-install(DIRECTORY config DESTINATION ${DATA_DIR})
-install(DIRECTORY Mods DESTINATION ${DATA_DIR})
+if(ANDROID)
+	if(ANDROID_STL MATCHES "_shared$")
+		set(stlLibName "${CMAKE_SHARED_LIBRARY_PREFIX}${ANDROID_STL}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+		install(FILES "${CMAKE_SYSROOT}/usr/lib/${ANDROID_SYSROOT_LIB_SUBDIR}/${stlLibName}"
+			DESTINATION ${LIB_DIR}
+		)
+	endif()
+
+	install(FILES AUTHORS
+		DESTINATION res/raw
+		RENAME authors.txt
+	)
+
+	# zip internal assets - 'config' and 'Mods' dirs, save md5 of the zip
+	install(CODE "
+		cmake_path(ABSOLUTE_PATH CMAKE_INSTALL_PREFIX
+			OUTPUT_VARIABLE absolute_install_prefix
+		)
+		set(absolute_data_dir \"\${absolute_install_prefix}/${DATA_DIR}\")
+		file(MAKE_DIRECTORY \"\${absolute_data_dir}\")
+
+		set(internal_data_zip \"\${absolute_data_dir}/internalData.zip\")
+		execute_process(COMMAND
+			\"${CMAKE_COMMAND}\" -E tar c \"\${internal_data_zip}\" --format=zip -- config Mods
+			WORKING_DIRECTORY \"${CMAKE_SOURCE_DIR}\"
+		)
+
+		file(MD5 \"\${internal_data_zip}\" internal_data_zip_md5)
+		file(WRITE \"\${absolute_data_dir}/internalDataHash.txt\"
+			\${internal_data_zip_md5}
+		)
+	")
+else()
+	install(DIRECTORY config DESTINATION ${DATA_DIR})
+	install(DIRECTORY Mods DESTINATION ${DATA_DIR})
+endif()
 if(ENABLE_LUA)
 if(ENABLE_LUA)
 	install(DIRECTORY scripts DESTINATION ${DATA_DIR})
 	install(DIRECTORY scripts DESTINATION ${DATA_DIR})
 endif()
 endif()
 
 
-# that script is useless for Windows and iOS
-if(NOT WIN32 AND NOT APPLE_IOS)
+# that script is useless for Windows / iOS / Android
+if(NOT WIN32 AND NOT APPLE_IOS AND NOT ANDROID)
 	install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS
 	install(FILES vcmibuilder DESTINATION ${BIN_DIR} PERMISSIONS
 		OWNER_WRITE OWNER_READ OWNER_EXECUTE
 		OWNER_WRITE OWNER_READ OWNER_EXECUTE
 					GROUP_READ GROUP_EXECUTE
 					GROUP_READ GROUP_EXECUTE

+ 1 - 1
Global.h

@@ -34,7 +34,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #elif defined(__linux__) || defined(__gnu_linux__) || defined(linux) || defined(__linux)
 #elif defined(__linux__) || defined(__gnu_linux__) || defined(linux) || defined(__linux)
 #  define VCMI_UNIX
 #  define VCMI_UNIX
 #  define VCMI_XDG
 #  define VCMI_XDG
-#  ifdef __ANDROID__
+#  if defined(__ANDROID__) || defined(ANDROID)
 #    define VCMI_ANDROID
 #    define VCMI_ANDROID
 #  endif
 #  endif
 #elif defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
 #elif defined(__FreeBSD_kernel__) || defined(__FreeBSD__)

+ 1 - 1
android/GeneratedVersion.java.in

@@ -1,7 +1,7 @@
 package eu.vcmi.vcmi.util;
 package eu.vcmi.vcmi.util;
 
 
 /**
 /**
- * Generated via cmake (./project/vcmi-app/cmake-scripts/versions.cmake)
+ * Generated via cmake
  */
  */
 public class GeneratedVersion
 public class GeneratedVersion
 {
 {

+ 7 - 0
android/vcmi-app/.gitignore

@@ -1 +1,8 @@
 /build
 /build
+
+# generated by CMake build
+/src/main/assets/internalData.zip
+/src/main/assets/internalDataHash.txt
+/src/main/java/eu/vcmi/vcmi/util/GeneratedVersion.java
+/src/main/jniLibs
+/src/main/res/raw/authors.txt

+ 1 - 1
android/vcmi-app/src/main/java/eu/vcmi/vcmi/VcmiSDLActivity.java

@@ -80,7 +80,7 @@ public class VcmiSDLActivity extends SDLActivity
 
 
     @Override
     @Override
     protected String getMainSharedObject() {
     protected String getMainSharedObject() {
-        String library = "libvcmi-client.so";
+        String library = "libvcmiclient.so";
 
 
         return getContext().getApplicationInfo().nativeLibraryDir + "/" + library;
         return getContext().getApplicationInfo().nativeLibraryDir + "/" + library;
     }
     }

+ 2 - 2
android/vcmi-app/src/main/java/eu/vcmi/vcmi/util/LibsLoader.java

@@ -52,7 +52,7 @@ public final class LibsLoader
     public static void loadClientLibs(Context ctx)
     public static void loadClientLibs(Context ctx)
     {
     {
         loadCommon();
         loadCommon();
-        loadLib("vcmi-client", false);
+        loadLib("vcmiclient", false);
         SDL.setContext(ctx);
         SDL.setContext(ctx);
         NativeMethods.clientSetupJNI();
         NativeMethods.clientSetupJNI();
         NativeMethods.initClassloader();
         NativeMethods.initClassloader();
@@ -61,7 +61,7 @@ public final class LibsLoader
     public static void loadServerLibs()
     public static void loadServerLibs()
     {
     {
         loadCommon();
         loadCommon();
-        loadLib("vcmi-server", false);
+        loadLib("vcmiserver", false);
         NativeMethods.initClassloader();
         NativeMethods.initClassloader();
     }
     }
 }
 }

+ 4 - 5
android/vcmi-app/src/main/java/org/libsdl/app/SDLActivity.java

@@ -243,9 +243,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
      * It can be overridden by derived classes.
      * It can be overridden by derived classes.
      */
      */
     protected String getMainSharedObject() {
     protected String getMainSharedObject() {
-        String library = "libvcmi-client.so";
-
-        return getContext().getApplicationInfo().nativeLibraryDir + "/" + library;
+        return null;
     }
     }
 
 
     /**
     /**
@@ -265,13 +263,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
      * @return names of shared libraries to be loaded (e.g. "SDL2", "main").
      * @return names of shared libraries to be loaded (e.g. "SDL2", "main").
      */
      */
     protected String[] getLibraries() {
     protected String[] getLibraries() {
+        // SDL is linked statically, no need to load anything
         return new String[] {
         return new String[] {
-                "SDL2",
+                // "SDL2",
                 // "SDL2_image",
                 // "SDL2_image",
                 // "SDL2_mixer",
                 // "SDL2_mixer",
                 // "SDL2_net",
                 // "SDL2_net",
                 // "SDL2_ttf",
                 // "SDL2_ttf",
-                "main"
+                // "main"
         };
         };
     }
     }
 
 

+ 2 - 2
client/CMT.cpp

@@ -57,7 +57,7 @@
 #include <SDL_syswm.h>
 #include <SDL_syswm.h>
 #endif
 #endif
 #ifdef VCMI_ANDROID
 #ifdef VCMI_ANDROID
-#include "lib/CAndroidVMHelper.h"
+#include "../lib/CAndroidVMHelper.h"
 #endif
 #endif
 
 
 #include "CMT.h"
 #include "CMT.h"
@@ -580,7 +580,7 @@ void playIntro()
 	}
 	}
 }
 }
 
 
-#ifndef VCMI_IOS
+#if !defined(VCMI_IOS) && !defined(VCMI_ANDROID)
 static bool checkVideoMode(int monitorIndex, int w, int h)
 static bool checkVideoMode(int monitorIndex, int w, int h)
 {
 {
 	//we only check that our desired window size fits on screen
 	//we only check that our desired window size fits on screen

+ 15 - 6
client/CMakeLists.txt

@@ -245,13 +245,16 @@ endif()
 
 
 assign_source_group(${client_SRCS} ${client_HEADERS} VCMI_client.rc)
 assign_source_group(${client_SRCS} ${client_HEADERS} VCMI_client.rc)
 
 
-if(ANDROID) # android needs client/server to be libraries, not executables, so we can't reuse the build part of this script
-	return()
+if(ANDROID)
+	add_library(vcmiclient SHARED ${client_SRCS} ${client_HEADERS})
+else()
+	add_executable(vcmiclient ${client_SRCS} ${client_HEADERS})
 endif()
 endif()
 
 
-add_executable(vcmiclient ${client_SRCS} ${client_HEADERS})
-
-add_dependencies(vcmiclient vcmiserver BattleAI StupidAI VCAI)
+add_dependencies(vcmiclient vcmiserver BattleAI VCAI)
+if(NOT ANDROID)
+	add_dependencies(vcmiclient StupidAI)
+endif()
 if(ENABLE_NULLKILLER_AI)
 if(ENABLE_NULLKILLER_AI)
 	add_dependencies(vcmiclient Nullkiller)
 	add_dependencies(vcmiclient Nullkiller)
 endif()
 endif()
@@ -362,12 +365,18 @@ if(APPLE_IOS)
 		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 	)
 	)
 	install(TARGETS vcmiclient DESTINATION Payload COMPONENT app) # for ipa generation with cpack
 	install(TARGETS vcmiclient DESTINATION Payload COMPONENT app) # for ipa generation with cpack
+elseif(ANDROID)
+	vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
+	add_custom_command(TARGET vcmiclient POST_BUILD
+		COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --config "$<CONFIG>" --prefix "${CMAKE_SOURCE_DIR}/android/vcmi-app/src/main"
+	)
+	install(TARGETS vcmiclient DESTINATION ${LIB_DIR})
 else()
 else()
 	install(TARGETS vcmiclient DESTINATION ${BIN_DIR})
 	install(TARGETS vcmiclient DESTINATION ${BIN_DIR})
 endif()
 endif()
 
 
 #install icons and desktop file on Linux
 #install icons and desktop file on Linux
-if(NOT WIN32 AND NOT APPLE)
+if(NOT WIN32 AND NOT APPLE AND NOT ANDROID)
 	#FIXME: move to client makefile?
 	#FIXME: move to client makefile?
 	install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png"   DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png)
 	install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.64x64.png"   DESTINATION share/icons/hicolor/64x64/apps RENAME vcmiclient.png)
 	install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png"   DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png)
 	install(FILES "${CMAKE_SOURCE_DIR}/client/icons/vcmiclient.48x48.png"   DESTINATION share/icons/hicolor/48x48/apps RENAME vcmiclient.png)

+ 0 - 4
cmake_modules/VCMI_lib.cmake

@@ -488,10 +488,6 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
 		)
 		)
 	endif()
 	endif()
 
 
-	if(ANDROID)
-		return()
-	endif()
-
 	vcmi_set_output_dir(${TARGET_NAME} "")
 	vcmi_set_output_dir(${TARGET_NAME} "")
 
 
 	enable_pch(${TARGET_NAME})
 	enable_pch(${TARGET_NAME})

+ 7 - 0
conanfile.py

@@ -227,6 +227,13 @@ class VCMI(ConanFile):
         tc = CMakeToolchain(self)
         tc = CMakeToolchain(self)
         tc.variables["USING_CONAN"] = True
         tc.variables["USING_CONAN"] = True
         tc.variables["CONAN_INSTALL_FOLDER"] = self.install_folder
         tc.variables["CONAN_INSTALL_FOLDER"] = self.install_folder
+        if self.settings.os == "Android":
+            tc.variables["ANDROID_SYSROOT_LIB_SUBDIR"] = {
+                'armv7': 'arm-linux-androideabi',
+                'armv8': 'aarch64-linux-android',
+                'x86': 'i686-linux-android',
+                'x86_64': 'x86_64-linux-android',
+            }.get(str(self.settings.arch))
         if cross_building(self) and self.settings.os == "Windows":
         if cross_building(self) and self.settings.os == "Windows":
             tc.variables["CONAN_SYSTEM_LIBRARY_LOCATION"] = self.env["CONAN_SYSTEM_LIBRARY_LOCATION"]
             tc.variables["CONAN_SYSTEM_LIBRARY_LOCATION"] = self.env["CONAN_SYSTEM_LIBRARY_LOCATION"]
         tc.generate()
         tc.generate()

+ 1 - 1
lib/CAndroidVMHelper.h

@@ -17,7 +17,7 @@
 #include <string>
 #include <string>
 
 
 /// helper class that allows access to java vm to communicate with java code from native
 /// helper class that allows access to java vm to communicate with java code from native
-class CAndroidVMHelper
+class DLL_LINKAGE CAndroidVMHelper
 {
 {
 	JNIEnv * envPtr;
 	JNIEnv * envPtr;
 	bool detachInDestructor;
 	bool detachInDestructor;

+ 1 - 1
lib/logging/CLogger.cpp

@@ -348,7 +348,7 @@ EConsoleTextColor::EConsoleTextColor CColorMapping::getColorFor(const CLoggerDom
 }
 }
 
 
 CLogConsoleTarget::CLogConsoleTarget(CConsoleHandler * console) :
 CLogConsoleTarget::CLogConsoleTarget(CConsoleHandler * console) :
-#ifndef VCMI_IOS
+#if !defined(VCMI_IOS) && !defined(VCMI_ANDROID)
 	console(console),
 	console(console),
 #endif
 #endif
 	threshold(ELogLevel::INFO), coloredOutputEnabled(true)
 	threshold(ELogLevel::INFO), coloredOutputEnabled(true)

+ 1 - 1
lib/logging/CLogger.h

@@ -198,7 +198,7 @@ public:
 	void write(const LogRecord & record) override;
 	void write(const LogRecord & record) override;
 
 
 private:
 private:
-#ifndef VCMI_IOS
+#if !defined(VCMI_IOS) && !defined(VCMI_ANDROID)
 	CConsoleHandler * console;
 	CConsoleHandler * console;
 #endif
 #endif
 	ELogLevel::ELogLevel threshold;
 	ELogLevel::ELogLevel threshold;

+ 10 - 6
server/CMakeLists.txt

@@ -20,16 +20,16 @@ set(server_HEADERS
 
 
 assign_source_group(${server_SRCS} ${server_HEADERS})
 assign_source_group(${server_SRCS} ${server_HEADERS})
 
 
-if(ANDROID) # android needs client/server to be libraries, not executables, so we can't reuse the build part of this script
-	return()
-endif()
-
 if(ENABLE_SINGLE_APP_BUILD)
 if(ENABLE_SINGLE_APP_BUILD)
 	add_library(vcmiserver STATIC ${server_SRCS} ${server_HEADERS})
 	add_library(vcmiserver STATIC ${server_SRCS} ${server_HEADERS})
 	target_compile_definitions(vcmiserver PUBLIC VCMI_DLL_STATIC=1)
 	target_compile_definitions(vcmiserver PUBLIC VCMI_DLL_STATIC=1)
 	set(server_LIBS vcmi_lib_server)
 	set(server_LIBS vcmi_lib_server)
 else()
 else()
-	add_executable(vcmiserver ${server_SRCS} ${server_HEADERS})
+	if(ANDROID)
+		add_library(vcmiserver SHARED ${server_SRCS} ${server_HEADERS})
+	else()
+		add_executable(vcmiserver ${server_SRCS} ${server_HEADERS})
+	endif()
 	set(server_LIBS vcmi)
 	set(server_LIBS vcmi)
 endif()
 endif()
 
 
@@ -54,5 +54,9 @@ vcmi_set_output_dir(vcmiserver "")
 enable_pch(vcmiserver)
 enable_pch(vcmiserver)
 
 
 if(NOT ENABLE_SINGLE_APP_BUILD)
 if(NOT ENABLE_SINGLE_APP_BUILD)
-	install(TARGETS vcmiserver DESTINATION ${BIN_DIR})
+	if(ANDROID)
+		install(TARGETS vcmiserver DESTINATION ${LIB_DIR})
+	else()
+		install(TARGETS vcmiserver DESTINATION ${BIN_DIR})
+	endif()
 endif()
 endif()