The new toolchain file requires Android NDK r12b and above. Default to use 'arm-linux-androideabi-clang' toolchain and LLVM libc++ STL runtime.
Align all the compiler and linker flags according to new ndk-build configuration in Android NDK r12b, i.e. no more '-f[no-]strict-aliasing' and '-f[no-]omit-frame-pointer', but more stringent warnings check.
Improve over the old toolchain file where most of the options are now changeable after the initial configuration. The exceptions are ANDROID_NDK and ANDROID_TOOLCHAIN_NAME due to limitation of CMake.
Close#1441.
Other changes in this commit includes:
- Fix Android sample launcher app to support shared C++ STL runtime library.
- Remove temporary fix in FindUrho3D module as it is not required anymore with our new toolchain file.
- Fix Log::WriteRaw() method to pass the parameters correctly to __android_log_print() function.
- Fix enable_pch() macro to emit -fPIC compiler flags correctly based on target's POSITION_INDEPENDENT_CODE property.
- Fix linker flags for ld.bfd where it needs help to find the location of the rooted shared libraries. The flags are not required for ld.gold but they do no harm for gold linker.
- Enhance the CheckCompilerToolchain module to auto-detect if the NEON SIMD is enabled or not for Android build (based on the chosen ANDROID_ABI).
When in try_compile() mode, quickly obtain the previously cached values stored in the (inner scope) environment variables and bypass all the checks (which are already done when the toolchain file is being processed at the start of CMake run).
Due to the CMake try_compile() limitation, initial build option values (i.e. not env-vars) were not visible to all the CMake checks during inital configuration, preventing the build option from functioning as expected.
After using CMAKE_SYSROOT in the android.toolchain.cmake module, CMake will only find Doxygen when CMAKE_FIND_ROOT_PATH_MODE_PROGRAM is set to to NEVER. It is actually weird why it was working before when it was set to ONLY previously.
Use CMAKE_SYSROOT to manage the sysroot automatically when cross-compiling instead of adding the '--sysroot' flag manually everywhere. We only need to add it manually in places where CMake does not, like in our custom GCC/Clang response file for PCH.
Differentiate between setting up header search path for system headers and for application headers so that GCC/Clang may suppress compilation warnings from the former, if any.
Some cross-compiling build tree configuration needs native compiler toolchain for host tool building via ExternalProject_Add(). This additional check ensures the native compiler toolchain is available up front before the build tree is even generated. Close#1300.
Remove hardcoding of indirect dependency libraries list in the FindUrho3D.cmake module. Instead we now rely on the linker to find those indirect dependencies automatically with our hint via "-runpath-link" linker flag, especially when cross-compiling.
Also setup GLESv2 (and GLESv1_CM) for Raspberry-Pi in the same manner as generic ARM and Android platforms.
When cross-compiling we have already defined '--sysroot' to find the direct library dependencies. However when a shared library has its own dependencies (DT_NEEDED) then we need to supply extra linker flags to help the linker to find those indirect library dependecies in the sysroot.
Actually we also had this problem for 32-bit ARM cross-compiling, but we cheated in the earlier CI build jobs by using Linaro/Raspbian compiler toolchain. Somehow the Raspbian's linker simply "ignores" those indirect library dependencies or it uses other mean to locate them (but I doubt that), and so it does not have linker issues with libreadline.so (depends on tinfo), libGLESv2.so (depends on glapi), etc. The other ARM compiler toolchains from Linaro seem to be more strict in this regard. Most likely the raspbian's linker is a gold linker.
This commit could also potentially fix a known issue in our FindUrho3D.cmake module where we have to hardcode the library dependencies that libUrho3D.so in turn depends on (to be investigated later).
This will be the last time we modify this toolchain file for Urho3D project. We are forced to touch it one last time because we need to bump the NDK version in urho3d/android-ndk repository.
- Fix the regex to get the shared library soname correctly.
- Use the GCC_ATOMIC and CLOCK_GETTIME whenever they are available.
- Reorganize the if-else block in the SDL CMakeLists.txt to prevent Unix-like platforms (e.g. Android) from entering the block meant for genuine Unix/Linux.
- and more.
Determine the Emscripten's emcc version and use it to determine whether ccache could be enabled without caveat.
The changes for adding new '--use-metadata' option for Emscripten' file-packager.py has just been submitted to Emscripten upstream as PR (https://github.com/kripken/emscripten/pull/3410) today. Not sure how long it will take to be reviewed and merged (if at all). Tentatively assume it will be in incoming 1.31.4. With the immutable jsoutput file, the linker does not retriggered unnecessarily after changing the resource dirs content.