diff --git a/conan_provider.cmake b/conan_provider.cmake index fbfcd871..19958151 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -19,8 +19,12 @@ function(detect_os OS OS_API_LEVEL OS_SDK OS_SUBSYSTEM OS_VERSION) set(${OS} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Android") - string(REGEX MATCH "[0-9]+" _OS_API_LEVEL ${ANDROID_PLATFORM}) - message(STATUS "CMake-Conan: android_platform=${ANDROID_PLATFORM}") + if(DEFINED ANDROID_PLATFORM) + string(REGEX MATCH "[0-9]+" _OS_API_LEVEL ${ANDROID_PLATFORM}) + elseif(DEFINED CMAKE_SYSTEM_VERSION) + set(_OS_API_LEVEL ${CMAKE_SYSTEM_VERSION}) + endif() + message(STATUS "CMake-Conan: android api level=${_OS_API_LEVEL}") set(${OS_API_LEVEL} ${_OS_API_LEVEL} PARENT_SCOPE) endif() if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS") @@ -133,8 +137,8 @@ endmacro() function(detect_lib_cxx LIB_CXX) if(CMAKE_SYSTEM_NAME STREQUAL "Android") - message(STATUS "CMake-Conan: android_stl=${ANDROID_STL}") - set(${LIB_CXX} ${ANDROID_STL} PARENT_SCOPE) + message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}") + set(${LIB_CXX} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE) return() endif() diff --git a/tests/test_smoke.py b/tests/test_smoke.py index ebafb4f3..a682fc9a 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -485,6 +485,20 @@ def test_android_x86(self, capfd, basic_cmake_project): assert "os.api_level=22" in out assert "tools.android:ndk_path=" in out + def test_android_no_toolchain(self, capfd, basic_cmake_project): + "Building for Android without toolchain" + source_dir, binary_dir = basic_cmake_project + android_ndk_root = os.environ['ANDROID_NDK_ROOT'].replace("\\", "/") + run(f"cmake -S {source_dir} -B {binary_dir} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES={conan_provider} -G Ninja -DCMAKE_BUILD_TYPE=Release " + f"-DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK={android_ndk_root} " + "-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_VERSION=28 -DCMAKE_ANDROID_STL_TYPE=c++_static") + out, _ = capfd.readouterr() + assert "arch=armv8" in out + assert "compiler.libcxx=c++_static" in out + assert "os=Android" in out + assert "os.api_level=28" in out + assert "tools.android:ndk_path=" in out + class TestiOS: @darwin