Skip to content

Commit 6e16dc6

Browse files
schwabecron2
authored andcommitted
Add (fake) Android cmake building
There is a mode to build with a real Android NDK that requires setting up cmake to build with the NDK and so. For quick&dirty compile tests that do not actually use the Android NDK on Linux, -DFAKE_ANDROID on Linux can be used to compile a binary using TARGET_ANDROID. Change-Id: If6afa1108f9234f98afdbe0de7b7320403871772 Signed-off-by: Arne Schwabe <[email protected]> Acked-by: Frank Lichtenheld <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg30885.html Signed-off-by: Gert Doering <[email protected]>
1 parent 666e440 commit 6e16dc6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ option(ENABLE_LZ4 "BUILD with lz4" ON)
3939
option(ENABLE_LZO "BUILD with lzo" ON)
4040
option(ENABLE_PKCS11 "BUILD with pkcs11-helper" ON)
4141
option(USE_WERROR "Treat compiler warnings as errors (-Werror)" ON)
42+
option(FAKE_ANDROID "Target Android but do not use actual cross compile/Android cmake to build for simple compile checks on Linux")
4243

4344
set(PLUGIN_DIR /usr/local/lib/openvpn/plugins CACHE FILEPATH "Location of the plugin directory")
4445

@@ -122,7 +123,14 @@ set(OPENVPN_VERSION_RESOURCE ${PRODUCT_VERSION_RESOURCE})
122123
set(CMAKE_C_STANDARD 11)
123124

124125
# Set the various defines for config.h.cmake.in
125-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
126+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Android" OR ${FAKE_ANDROID})
127+
set(TARGET_ANDROID YES)
128+
set(ENABLE_ASYNC_PUSH YES)
129+
set(ENABLE_SITNL YES)
130+
set(HAVE_LINUX_TYPES_H 1)
131+
# Wacky workaround as OpenSSL package detection is otherwise broken (https://stackoverflow.com/questions/45958214/android-cmake-could-not-find-openssl)
132+
list(APPEND CMAKE_FIND_ROOT_PATH ${OPENSSL_ROOT_DIR})
133+
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
126134
set(TARGET_LINUX YES)
127135
set(ENABLE_ASYNC_PUSH YES)
128136
set(ENABLE_LINUXDCO YES)

config.h.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ don't. */
432432
/* Are we running WIN32? */
433433
#cmakedefine TARGET_WIN32
434434

435+
/* Are we targeting Android? */
436+
#cmakedefine TARGET_ANDROID
437+
435438
#define TARGET_ALIAS "@CMAKE_SYSTEM_NAME@"
436439

437440
/* Enable GNU extensions on systems that have them. */

0 commit comments

Comments
 (0)