diff options
author | Benoit Jacob <benoitjacob@google.com> | 2015-04-07 14:03:21 -0400 |
---|---|---|
committer | Benoit Jacob <benoitjacob@google.com> | 2015-04-07 14:03:21 -0400 |
commit | 0e9753c8dfffd8e20a445d3f150b8180c0815419 (patch) | |
tree | 10dc5d8b29aaeea875ec8089f61b4f7c1170f17e /CMakeLists.txt | |
parent | 1de49ef4c2d96acc1c96628fa52e2330cf54dc19 (diff) |
Fix compiler flags on Android/ARM:
- generate position-independent code (PIE), a requirement to run binaries on Android 5.0+ devices;
- correctly handle EIGEN_TEST_FMA + EIGEN_TEST_NEON to pass -mfpu=neon-vfpv4.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1ae428e..a28ad07d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,11 @@ if(NOT MSVC) else() ei_add_cxx_compiler_flag("-ansi") endif() + + if(ANDROID_NDK) + ei_add_cxx_compiler_flag("-pie") + ei_add_cxx_compiler_flag("-fPIE") + endif() set(CMAKE_REQUIRED_FLAGS "") @@ -208,7 +213,7 @@ if(NOT MSVC) endif() option(EIGEN_TEST_FMA "Enable/Disable FMA in tests/examples" OFF) - if(EIGEN_TEST_FMA) + if(EIGEN_TEST_FMA AND NOT EIGEN_TEST_NEON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma") message(STATUS "Enabling FMA in tests/examples") endif() @@ -227,7 +232,12 @@ if(NOT MSVC) option(EIGEN_TEST_NEON "Enable/Disable Neon in tests/examples" OFF) if(EIGEN_TEST_NEON) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -mfloat-abi=softfp") + if(EIGEN_TEST_FMA) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon-vfpv4") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=softfp") message(STATUS "Enabling NEON in tests/examples") endif() |