Skip to content

Commit bb516f0

Browse files
authored
add note android build
1 parent 30ef969 commit bb516f0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

runtime/Cpp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH
102102
if (NOT (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0))
103103
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 5.0 or greater.")
104104
endif ()
105+
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ANDROID)
106+
# Need -Os cflag and cxxflags here to work with exception handling on armeabi.
107+
# see https://github.com/android-ndk/ndk/issues/573
108+
# and without -stdlib=libc++ cxxflags
105109
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND APPLE)
106110
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
107111
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_SYSTEM_NAME MATCHES "Linux")

runtime/Cpp/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The C++ target has been the work of the following people:
2525

2626
## Project Status
2727

28-
* Building on OS X, Windows, and Linux
28+
* Building on OS X, Windows, Android and Linux
2929
* No errors and warnings
3030
* Library linking
3131
* Some unit tests in the OSX project, for important base classes with almost 100% code coverage.
@@ -47,6 +47,9 @@ Simply open the VS solution (VS 2013+) and build it.
4747
#### Compiling on OSX
4848
Either open the included XCode project and build that or use the cmake compilation as described for linux.
4949

50+
#### Compiling on Android
51+
Try run cmake -DCMAKE_ANDROID_NDK=/folder/of/android_ndkr17_and_above -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=14 -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_BUILD_TYPE=Release /folder/antlr4_src_dir -G Ninja.
52+
5053
#### Compiling on Linux
5154
- cd <antlr4-dir>/runtime/Cpp (this is where this readme is located)
5255
- mkdir build && mkdir run && cd build

0 commit comments

Comments
 (0)