tosif24 tosif24 - 4 years ago 159
Android Question

Override android.toolchain.cmake in andorid cmake build

The cmake bundled with NDK is the one which gets used by default, but it defines so many options. One of them is -

elseif(ANDROID_STL STREQUAL gnustl_shared)
set(ANDROID_STL_STATIC_LIBRARIES
supc++)
set(ANDROID_STL_SHARED_LIBRARIES
gnustl_shared)


Now, I want gnustl_shared to used, but no supc++, and I cannot find anyway to do it. Removing it manually from android.toolchain.cmake works for me.
But I dont want to edit ndk toolchain cmake file on every machine.
In my app's cmakelists.txt, I have tried

list(FILTER ANDROID_STL_STATIC_LIBRARIES EXCLUDE REGEX ".*supc.*")
list(FILTER CMAKE_CXX_STANDARD_LIBRARIES_INIT EXCLUDE REGEX ".*supc.*")


But every time, in the generated build.ninja file, I see libsupc++.a in LINK_LIBRARIES.

Is there a clean way for me to exclude this lib while linking ?

Answer Source

Turning my comment into an answer

When I look into android.toolchain.cmake I see that ANDROID_STL_STATIC_LIBRARIES is transferred to ANDROID_CXX_STANDARD_LIBRARIES which is used for CMAKE_CXX_STANDARD_LIBRARIES.

So I modifying the later should solve your problem. But this is not a list, it's space separated and you should do:

string(REPLACE "supc++" "" CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")

References

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download