From 07430ae3d01f86406883d035c63f0718d5f13ed1 Mon Sep 17 00:00:00 2001
From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net>
Date: Mon, 28 Dec 2020 18:22:52 +0700
Subject: [PATCH] [*] Android fixes

---
 3rdparty/json-c/CMakeLists.txt    | 8 ++++++++
 CMakeLists.txt                    | 6 ++++++
 cmake/OS_Detection.cmake          | 9 +--------
 dap-sdk/net/server/CMakeLists.txt | 3 ---
 4 files changed, 15 insertions(+), 11 deletions(-)
 create mode 100644 3rdparty/json-c/CMakeLists.txt

diff --git a/3rdparty/json-c/CMakeLists.txt b/3rdparty/json-c/CMakeLists.txt
new file mode 100644
index 0000000000..63f3053fa0
--- /dev/null
+++ b/3rdparty/json-c/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 2.8)
+project (json-c)
+  
+file(GLOB JSON_C_SRCS FILES *.c)
+file(GLOB JSON_C_HEADERS FILES *.h)
+
+add_library(${PROJECT_NAME} STATIC ${JSON_C_SRCS} ${JSON_C_HEADERS})
+target_include_directories(json-c PUBLIC . )
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cefffc317..33f1006d19 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,12 @@ endif()
 add_subdirectory(dap-sdk)
 add_subdirectory(3rdparty/monero_crypto)
 add_subdirectory(3rdparty/cuttdb)
+if (ANDROID)
+    add_subdirectory(3rdparty/libmagic)
+    add_subdirectory(3rdparty/json-c)
+    include_directories(cellframe-sdk/3rdparty/)
+
+endif()
 add_subdirectory(modules/)
 
 add_library(${PROJECT_NAME} STATIC cellframe-sdk.c)
diff --git a/cmake/OS_Detection.cmake b/cmake/OS_Detection.cmake
index e2801cf8dd..31648a6311 100644
--- a/cmake/OS_Detection.cmake
+++ b/cmake/OS_Detection.cmake
@@ -12,7 +12,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
     set(ANDROID ON)
     set(UNIX ON)
-    set(LINUX ON)
+    set(LINUX OFF)
     set(OS_TYPE_MOBILE ON)
     message("[*] ANDROID build")
     add_definitions(-DANDROID -DDAP_OS_ANDROID)
@@ -69,13 +69,6 @@ if(UNIX)
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
     set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${_LOPT}")
 
-    if (ANDROID)
-      add_subdirectory(lib/json-c)
-      add_subdirectory(lib/sqlite3)
-      #add_subdirectory(lib/libev)
-      include_directories(lib/)
-    else()
-    endif(ANDROID)
 endif()
 
 if(WIN32)
diff --git a/dap-sdk/net/server/CMakeLists.txt b/dap-sdk/net/server/CMakeLists.txt
index 498ed08f7e..4bde7fcb05 100644
--- a/dap-sdk/net/server/CMakeLists.txt
+++ b/dap-sdk/net/server/CMakeLists.txt
@@ -1,9 +1,6 @@
 project(libdap-server C)
 cmake_minimum_required(VERSION 3.0)
 
-if (ANDROID)
-    add_subdirectory(../../../3rdparty/libmagic)
-endif()
 
 add_subdirectory(http_server)
 add_subdirectory(enc_server)
-- 
GitLab