1if(NOT trout_ANDROID_SYSCORE_DIR)
2    set(trout_ANDROID_SYSCORE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/android/system_core")
3endif()
4
5if(NOT trout_ANDROID_LIBBASE_DIR)
6    set(trout_ANDROID_LIBBASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/android/libbase")
7endif()
8
9if(NOT trout_ANDROID_LIBLOG_DIR)
10    set(trout_ANDROID_LIBLOG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/android/logging/liblog")
11endif()
12
13set(_trout_ANDROID_CXX_FLAGS
14    -std=c++17
15    -Wall -Werror -Wextra
16    -Wno-unknown-warning-option
17    -Wno-c99-designator
18    -Wno-sign-compare
19)
20
21set(trout_ANDROID_LIBLOG_INCLUDE_DIR ${trout_ANDROID_LIBLOG_DIR}/include)
22set(trout_ANDROID_LIBLOG_LIBRARY "android_liblog")
23
24set(trout_ANDROID_LIBBASE_INCLUDE_DIR ${trout_ANDROID_LIBBASE_DIR}/include)
25set(trout_ANDROID_LIBBASE_LIBRARY "android_libbase")
26
27set(trout_ANDROID_LIBUTILS_DIR ${trout_ANDROID_SYSCORE_DIR}/libutils)
28set(trout_ANDROID_LIBUTLS_INCLUDE_DIR ${trout_ANDROID_LIBUTILS_DIR}/include)
29set(trout_ANDROID_LIBUTILS_LIBRARY "android_libutils")
30
31set(trout_ANDROID_LIBCUTLS_INCLUDE_DIR ${trout_ANDROID_SYSCORE_DIR}/libcutils/include)
32
33
34# =========== libbase =================
35
36if (NOT TARGET ${trout_ANDROID_LIBBASE_LIBRARY})
37    add_library(${trout_ANDROID_LIBBASE_LIBRARY}
38        ${trout_ANDROID_LIBBASE_DIR}/logging.cpp
39        ${trout_ANDROID_LIBBASE_DIR}/strings.cpp
40        ${trout_ANDROID_LIBBASE_DIR}/stringprintf.cpp
41        ${trout_ANDROID_LIBBASE_DIR}/threads.cpp
42    )
43
44    target_include_directories(${trout_ANDROID_LIBBASE_LIBRARY}
45        PUBLIC ${trout_ANDROID_LIBBASE_INCLUDE_DIR}
46        PRIVATE ${trout_FMTLIB_INCLUDE_DIRS}
47    )
48
49    target_link_libraries(${trout_ANDROID_LIBBASE_LIBRARY}
50        ${trout_ANDROID_LIBLOG_LIBRARY}
51        ${trout_FMTLIB_LIBRARIES}
52    )
53
54    target_compile_options(${trout_ANDROID_LIBBASE_LIBRARY} PRIVATE ${_trout_ANDROID_CXX_FLAGS})
55endif()
56
57
58# =========== liblog =================
59
60if (NOT TARGET ${trout_ANDROID_LIBLOG_LIBRARY})
61    add_library(${trout_ANDROID_LIBLOG_LIBRARY}
62        ${trout_ANDROID_LIBLOG_DIR}/logger_write.cpp
63        ${trout_ANDROID_LIBLOG_DIR}/properties.cpp
64    )
65
66    target_include_directories(${trout_ANDROID_LIBLOG_LIBRARY}
67        PUBLIC ${trout_ANDROID_LIBLOG_INCLUDE_DIR}
68        PRIVATE ${trout_ANDROID_LIBBASE_INCLUDE_DIR}
69        PRIVATE ${trout_ANDROID_LIBCUTLS_INCLUDE_DIR}
70    )
71
72    target_compile_options(${trout_ANDROID_LIBLOG_LIBRARY} PRIVATE ${_trout_ANDROID_CXX_FLAGS})
73endif()
74
75
76# =========== libutils =================
77
78if (NOT TARGET ${trout_ANDROID_LIBUTILS_LIBRARY})
79    add_library(${trout_ANDROID_LIBUTILS_LIBRARY}
80         ${trout_ANDROID_LIBUTILS_DIR}/SystemClock.cpp
81         ${trout_ANDROID_LIBUTILS_DIR}/Timers.cpp
82    )
83
84    target_include_directories(${trout_ANDROID_LIBUTILS_LIBRARY}
85        PUBLIC ${trout_ANDROID_LIBUTLS_INCLUDE_DIR}
86        PRIVATE ${trout_ANDROID_LIBCUTLS_INCLUDE_DIR}
87    )
88
89    target_link_libraries(${trout_ANDROID_LIBUTILS_LIBRARY}
90        ${trout_ANDROID_LIBBASE_LIBRARY}
91        ${trout_ANDROID_LIBLOG_LIBRARY}
92    )
93
94    target_compile_options(${trout_ANDROID_LIBUTILS_LIBRARY} PRIVATE ${_trout_ANDROID_CXX_FLAGS})
95endif()
96
97
98# =========== export libraries =================
99
100set(trout_ANDROID_INCLUDE_DIRS
101    ${trout_ANDROID_LIBBASE_INCLUDE_DIR}
102    ${trout_ANDROID_LIBCUTLS_INCLUDE_DIR}
103)
104
105set(trout_ANDROID_LIBRARIES
106	${trout_ANDROID_LIBBASE_LIBRARY}
107	${trout_ANDROID_LIBLOG_LIBRARY}
108	${trout_ANDROID_LIBUTILS_LIBRARY}
109)
110