diff --git a/conan/tools/cmake/toolchain/blocks.py b/conan/tools/cmake/toolchain/blocks.py index fca65c2fc85..1f0d0a1982e 100644 --- a/conan/tools/cmake/toolchain/blocks.py +++ b/conan/tools/cmake/toolchain/blocks.py @@ -286,7 +286,9 @@ class AndroidSystemBlock(Block): template = textwrap.dedent(""" # New toolchain things set(ANDROID_PLATFORM {{ android_platform }}) + {% if android_stl %} set(ANDROID_STL {{ android_stl }}) + {% endif %} set(ANDROID_ABI {{ android_abi }}) include({{ android_ndk_path }}/build/cmake/android.toolchain.cmake) """) @@ -303,7 +305,7 @@ def context(self): # TODO: only 'c++_shared' y 'c++_static' supported? # https://developer.android.com/ndk/guides/cpp-support - libcxx_str = str(self._conanfile.settings.compiler.libcxx) + libcxx_str = self._conanfile.settings.get_safe("compiler.libcxx") android_ndk_path = self._conanfile.conf.get("tools.android:ndk_path") if not android_ndk_path: diff --git a/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py b/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py index 967329a5de5..a4f7f09c6d9 100644 --- a/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py +++ b/conans/test/integration/toolchains/cmake/test_cmaketoolchain.py @@ -473,3 +473,20 @@ def generate(self): assert cache_variables["CMAKE_SH"] == "THIS VALUE HAS PRIORITY" assert cache_variables["CMAKE_POLICY_DEFAULT_CMP0091"] == "THIS VALUE HAS PRIORITY" assert cache_variables["CMAKE_MAKE_PROGRAM"] == "MyMake" + + +def test_android_c_library(): + client = TestClient() + conanfile = textwrap.dedent(""" + from conans import ConanFile + + class Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain" + + def configure(self): + del self.settings.compiler.libcxx + + """) + client.save({"conanfile.py": conanfile}) + client.run("create . foo/1.0@ -s os=Android -s os.api_level=23 -c tools.android:ndk_path=/foo")