summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools/cmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-06-25 00:25:16 +0800
committerruki <[email protected]>2022-06-25 00:25:16 +0800
commite8989f3392bb4670d9206a697b692aa15bc0f6a3 (patch)
treefcd82741e57ec39d72ccf201d6915518bd8d0d06 /xmake/modules/package/tools/cmake.lua
parent1503a42877b4b5504bef27c7d93798c050de03aa (diff)
improve tools.cmake to support wasm
Diffstat (limited to 'xmake/modules/package/tools/cmake.lua')
-rw-r--r--xmake/modules/package/tools/cmake.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 0e78ce352..00f0c937e 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -413,6 +413,20 @@ function _get_configs_for_mingw(package, configs, opt)
end
end
+-- get configs for wasm
+function _get_configs_for_wasm(package, configs, opt)
+ local emsdk = os.getenv("EMSDK")
+ local emscripten_cmakefile
+ if emsdk and os.isdir(emsdk) then
+ emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk, "*", "emscripten/cmake/Modules/Platform"))
+ end
+ if emscripten_cmakefile then
+ table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile)
+ end
+ assert(emscripten_cmakefile, "Emscripten.cmake not found!")
+ _get_configs_for_generic(package, configs, opt)
+end
+
-- get configs for cross
function _get_configs_for_cross(package, configs, opt)
opt = opt or {}
@@ -552,6 +566,8 @@ function _get_configs(package, configs, opt)
_get_configs_for_appleos(package, configs, opt)
elseif package:is_plat("mingw") then
_get_configs_for_mingw(package, configs, opt)
+ elseif package:is_plat("wasm") then
+ _get_configs_for_wasm(package, configs, opt)
elseif not package:is_plat(os.subhost()) or
package:config("toolchains") then -- we need pass toolchains
_get_configs_for_cross(package, configs, opt)