-
我试图用xmake导入libtorch,因此我仿照可以跑通的CMakeLists.txt写了一段程序: import("lib.detect.find_package")
local package = find_packages("cmake::Torch", {envs = {CMAKE_PREFIX_PATH = "/home/peter-233/Downloads/libtorch-cxx11-abi-shared-with-deps-1.10.0+cpu/libtorch"}})
target("TorchTest")
add_cxxflags("${TORCH_CXX_FLAGS}")
add_packages("Torch")
add_files("*.cpp")
add_rules("mode.release", "mode.debug")
set_kind("binary") 但是,当我运行xmake后,他显示了如下错误: error: ./xmake.lua:2: attempt to call global 'import' (a nil value)
stack traceback:
[./xmake.lua:2]: in main chunk
checking for platform ... linux
checking for architecture ... x86_64
error: ./xmake.lua:2: attempt to call global 'import' (a nil value)
stack traceback:
[./xmake.lua:2]: in main chunk 请问我该如何解决? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 19 replies
-
关于这块,之前文档写的不明确,find_package 目前只能在脚本域使用,虽然也可以集成包,但是用法比较繁琐 现在不管是远程包,还是本地包,还是系统库,都是统一走 add_requires 集成,用法更加简单一致 关于 add_requires 对于第三方库的安装集成,可以看文档:https://xmake.io/#/zh-cn/package/remote_package?id=%e7%ac%ac%e4%b8%89%e6%96%b9%e4%be%9d%e8%b5%96%e5%8c%85%e5%ae%89%e8%a3%85 而 cmake 包,2.6.1 线上版本,add_requires 对它的处理还不是很好,不支持透传 configs ,但基础的集成也是可以用的。 如果你的 cmake::xxx 包用到了一些组件, envs 配置什么的,需要更新到 xmake 的 dev 版本, 用法见: https://xmake.io/#/zh-cn/package/local_package?id=%e6%8c%87%e5%ae%9a%e7%bb%84%e4%bb%b6 关于这块的相关 issues 见:#1632 (comment) |
Beta Was this translation helpful? Give feedback.
关于这块,之前文档写的不明确,find_package 目前只能在脚本域使用,虽然也可以集成包,但是用法比较繁琐
现在不管是远程包,还是本地包,还是系统库,都是统一走 add_requires 集成,用法更加简单一致
关于 add_requires 对于第三方库的安装集成,可以看文档:https://xmake.io/#/zh-cn/package/remote_package?id=%e7%ac%ac%e4%b8%89%e6%96%b9%e4%be%9d%e8%b5%96%e5%8c%85%e5%ae%89%e8%a3%85
而 cmake 包,2.6.1 线上版本,add_requires 对它的处理还不是很好,不支持透传 configs ,但基础的集成也是可以用的。
我更新下了下文档,看下 https://xmake.io/#/zh-cn/package/local_package?id=%e5%9c%a8%e9%a1%b9%e7%9b%ae%e4%b8%ad%e9%9b%86%e6%88%90%e5%8c%85
如果你的 cmake::xxx 包用到了一些组件, envs 配置什么的,需要更新到 xmake 的 dev 版本,
xmake update -s dev
才能支持上用法见: https://xmake.io/#/zh-cn/package/local_package?id=%e6%8c%87%e5%ae%9a%e7%bb%84%e4%bb%b6
关于这块的相关 issues 见:#1632 (comment)