summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools/cmake.lua
diff options
context:
space:
mode:
authorJérôme Leclercq <[email protected]>2024-04-01 14:55:26 +0200
committerGitHub <[email protected]>2024-04-01 14:55:26 +0200
commitf090ddfa1f10abed04fae6085df73f70f696d5ff (patch)
tree7268857a845a324ce427983b1c8806a72673f58d /xmake/modules/package/tools/cmake.lua
parent0a6b4953c793011f5a786214eb8f510ee0aad6aa (diff)
package.tools.cmake: Use newer Android toolchain and support runtimes
Diffstat (limited to 'xmake/modules/package/tools/cmake.lua')
-rw-r--r--xmake/modules/package/tools/cmake.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index a566e4cb6..96353371a 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -419,15 +419,26 @@ function _get_configs_for_android(package, configs, opt)
local ndk = get_config("ndk")
if ndk and os.isdir(ndk) then
local ndk_sdkver = get_config("ndk_sdkver")
- local ndk_cxxstl = get_config("ndk_cxxstl")
table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. path.join(ndk, "build/cmake/android.toolchain.cmake"))
+ table.insert(configs, "-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF")
table.insert(configs, "-DANDROID_ABI=" .. package:arch())
if ndk_sdkver then
table.insert(configs, "-DANDROID_PLATFORM=android-" .. ndk_sdkver)
table.insert(configs, "-DANDROID_NATIVE_API_LEVEL=" .. ndk_sdkver)
end
- if ndk_cxxstl then
- table.insert(configs, "-DANDROID_STL=" .. ndk_cxxstl)
+ -- https://cmake.org/cmake/help/latest/variable/CMAKE_ANDROID_STL_TYPE.html
+ local supported_runtimes = {
+ "none", "system",
+ "gabi++_static", "gabi++_shared",
+ "gnustl_static", "gnustl_shared",
+ "c++_static", "c++_shared",
+ "stlport_static", "stlport_shared"
+ }
+ for _, runtime in ipairs(supported_runtimes) do
+ if package:has_runtime(runtime) then
+ table.insert(configs, "-DCMAKE_ANDROID_STL_TYPE=" .. runtime)
+ break
+ end
end
if is_host("windows") and opt.cmake_generator ~= "Ninja" then
local make = path.join(ndk, "prebuilt", "windows-x86_64", "bin", "make.exe")