1

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 don't 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 ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
tosif24
  • 93
  • 1
  • 10
  • 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 would assume that modifying the later would solve your problem. But this is not a list, it's space separated. Have you tried something like `string(REPLACE "supc++" "" CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")`? – Florian Feb 06 '17 at 20:39
  • It worked !!! Thanks a lot. But looking at ndk cmake file, how did you come to know ANDROID_STL_STATIC_LIBRARIES is going in CMAKE_CXX_STANDARD_LIBRARIES?? I couldnt find any such reference !! – tosif24 Feb 06 '17 at 21:19
  • You are welcome. In the version I had looked into, that was the case (I've linked the source in my answer). But even if it would be `CMAKE_CXX_STANDARD_LIBRARIES_INIT` it will finally end up in `CMAKE_CXX_STANDARD_LIBRARIES`. – Florian Feb 06 '17 at 21:29

1 Answers1

3

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

Community
  • 1
  • 1
Florian
  • 39,996
  • 9
  • 133
  • 149