diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-30 11:53:44 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-30 11:53:44 -0700 |
| commit | bcbb36cd4fee89ba86dc1028b9f4de928d361abe (patch) | |
| tree | b1c45912b99ef7586adbe27a764c582ed3311578 /CMakeLists.txt | |
| parent | f01e2c82f236b405b95adbe517a3cc9b41d17f16 (diff) | |
| download | nng-bcbb36cd4fee89ba86dc1028b9f4de928d361abe.tar.gz nng-bcbb36cd4fee89ba86dc1028b9f4de928d361abe.tar.bz2 nng-bcbb36cd4fee89ba86dc1028b9f4de928d361abe.zip | |
fixes #477 Android NDK build configuration
This enables the software to be built for Android, going back to
at least Android SDK r15 (IceCreamSandwich) and at least up to
SDK r27 (Oreo). Older versions of Android may work, but we have
no way to build them to test.
While here we have changed our CMake configuration to disable
building tools or tests when we detect a cross-compile situation.
Documentation for cross-compilation is updated as well.
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 36ba269f..03116540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,12 +86,22 @@ else () set (NNG_PACKAGE_VERSION "Unknown") endif() + # User-defined options. option(BUILD_SHARED_LIBS "Build shared library" ${BUILD_SHARED_LIBS}) -option (NNG_TESTS "Build and run tests" ON) -option (NNG_TOOLS "Build extra tools" ON) +if (CMAKE_CROSSCOMPILING) + set (NNG_NATIVE_BUILD OFF) +else() + set (NNG_NATIVE_BUILD ON) +endif() + +# We only build command line tools and tests if we are not in a +# cross-compile situation. Cross-compiling users who still want to +# build these must enable them explicitly. +option (NNG_TESTS "Build and run tests" ${NNG_NATIVE_BUILD}) +option (NNG_TOOLS "Build extra tools" ${NNG_NATIVE_BUILD}) option (NNG_ENABLE_NNGCAT "Enable building nngcat utility." ${NNG_TOOLS}) option (NNG_ENABLE_COVERAGE "Enable coverage reporting." OFF) # Enable access to private APIs for our own use. @@ -301,6 +311,13 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") endif() set(NNG_PLATFORM_POSIX ON) +elseif (CMAKE_SYSTEM_NAME MATCHES "Android") + add_definitions (-DNNG_PLATFORM_POSIX) + add_definitions (-DNNG_PLATFORM_LINUX) + add_definitions (-DNNG_PLATFORM_ANDROID) + add_definitions (-DNNG_USE_EVENTFD) + set(NNG_PLATFORM_POSIX ON) + elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") add_definitions (-DNNG_PLATFORM_POSIX) add_definitions (-DNNG_PLATFORM_DARWIN) @@ -404,6 +421,9 @@ else () add_definitions (-D_THREAD_SAFE) add_definitions (-D_POSIX_PTHREAD_SEMANTICS) + nng_check_func (lockf NNG_HAVE_LOCKF) + nng_check_func (flock NNG_HAVE_FLOCK) + nng_check_lib (rt clock_gettime NNG_HAVE_CLOCK_GETTIME) nng_check_lib (pthread sem_wait NNG_HAVE_SEMAPHORE_PTHREAD) nng_check_lib (nsl gethostbyname NNG_HAVE_LIBNSL) @@ -415,7 +435,8 @@ else () nng_check_struct_member(msghdr msg_control sys/socket.h NNG_HAVE_MSG_CONTROL) nng_check_sym (kqueue sys/event.h NNG_HAVE_KQUEUE) nng_check_sym (port_create port.h NNG_HAVE_PORT_CREATE) - nng_check_sym (epoll_wait sys/epoll.h NNG_HAVE_EPOLL) + nng_check_sym (epoll_create sys/epoll.h NNG_HAVE_EPOLL) + nng_check_sym (epoll_create1 sys/epoll.h NNG_HAVE_EPOLL_CREATE1) nng_check_sym (getpeereid unistd.h NNG_HAVE_GETPEEREID) nng_check_sym (SO_PEERCRED sys/socket.h NNG_HAVE_SOPEERCRED) nng_check_sym (LOCAL_PEERCRED sys/un.h NNG_HAVE_LOCALPEERCRED) |
