Open at185190 opened 3 years ago
we set ANDROID_STL
here:
https://github.com/conan-io/conan/blob/3cfeda8766f28052f0523f2ad3b0629fbb118a11/conans/client/build/cmake_flags.py#L267
but we skip it earlier if CMAKE_TOOLCHAIN_FILE
is set:
https://github.com/conan-io/conan/blob/3cfeda8766f28052f0523f2ad3b0629fbb118a11/conans/client/build/cmake_flags.py#L197
AFAIK, it was done to avoid overriding values defined in user's toolchains:
https://github.com/conan-io/conan/pull/1491#discussion_r127616222
I'm not sure its working properly, without toolchain wrong ANDROID_STL is definitely set, it was definitely using static instead of shared that we had set profile, you cannot confuse requiring c++_shared.so vs not requiring it.
And if there is reason for stl not be set with a cmake toolchain, example should imply that it should be set instead of assumption that is being set as conan outputs: -- Conan: C++ stdlib: c++_shared But in the end that is not actually being used, should output that stl is not set and its defaulting to static or w/e is default is in the toolchain.
to be honest, I doubt it will be fixed in 1.x, we're moving towards new CMake
build helper for 2.0. the existing code is too fragile, and there are too many use-cases relying on the current behavior already.
meanwhile, there are several alternative approaches you could try:
ANDROID_STL
and others in addition, as described: https://docs.conan.io/en/latest/integrations/cross_platform/android.html#use-built-in-conan-toolchain
https://docs.conan.io/en/latest/integrations/cross_platform/android.html#using-toolchain-from-android-ndkCONAN_CMAKE_PROGRAM
environment variable), as here:
https://github.com/conan-io/conan-center-index/blob/master/recipes/android-ndk/all/cmake-wrapper.cmd
https://github.com/conan-io/conan-center-index/blob/master/recipes/android-ndk/all/cmake-wrapperFair enough, I got it working now, it just that it caused a day of frustration and confusion.
Updated, actually issue is different than described here before This is happening when cross building for android from windows using android.toolchain.cmake as per recommended way of building android and also when building using existing ndk toolchain : https://docs.conan.io/en/latest/integrations/cross_platform/android.html#using-existing-ndk approach
When building with android.toolchain.cmake ANDROID_STL is not set and examples doesn't specify to set it and profile compiler.libcxx attribute is ignored all together, resulting c++_static ( -static-libstdc++) being used, which is not what is specified in profile.
When building using existing ndk example and not android toolchain compiler.libcxx=c++_shared is also ignored and static flags are used instead.
Even though on both occasions, conan itself outputs: -- Conan: C++ stdlib: c++_shared Yet if I manually output all the flags my self , you'll see this (rest of the flags are truncated) -- Linker flags: -static-libstdc++
And this is snipped from android.toolchain.cmake
There should be no flag used with c++_shared
Here is android documentation just for reference https://developer.android.com/ndk/guides/cmake#android_stl