Skip to content

Commit

Permalink
Fix/android toolchain c library (#11586)
Browse files Browse the repository at this point in the history
* Do not crush if the conanfile is a txt

* Fix CMakeToolchain for Android with pure C library
  • Loading branch information
lasote committed Jul 8, 2022
1 parent b20b72b commit 597f146
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conan/tools/cmake/toolchain/blocks.py
Expand Up @@ -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)
""")
Expand All @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions conans/test/integration/toolchains/cmake/test_cmaketoolchain.py
Expand Up @@ -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")

0 comments on commit 597f146

Please sign in to comment.