-
-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make openmp a package #1865
Comments
可以是可以,比较繁琐,交叉编译没法适配 得加个 package:has_flags() 或者 package:compiler()才能适配package的内部工具链 |
最好是加 add_cxflags 这种到 package 实现 flags 自动check追加,然后搭配 package:compiler/package:linker 此类接口,会更好些 on_load(function (package)
if package:compiler("cxx"):is("gcc", "clang") then
package:add("cxflags", "-fopenmp")
end
end) 然后 has_flags 也可以放到 target 里面也可以加此类接口,方便编译器判断 |
我改进过了,其实 package 定义,原本就支持 add_cxflags 此类,直接对外导出 flags,并且支持自动检测 我现在对 target/package 加了个 package:has_tool("cc", "clang", "gcc") 的接口,方便判断各种编译器 现在可以简化为 add_requires("libomp", {optional = true})
target("hello")
set_kind("binary")
add_files("src/*.c")
add_packages("libomp") 不过需要同时更新下库和xmake |
这样写不行,openmp是一个标准,libomp是openmp的llvm实现,还有很多别的实现比如gnu的libgomp,intel的libiomp,微软的microsoft openmp,应该加一个通用的openmp包(使用该编译器的默认实现),然后对不同的特殊实现包处理特殊实现的情况 |
那你搞个pr 过来吧,参考刚 添加 flags 的方式 |
改过了 add_requires("openmp")
target("hello")
set_kind("binary")
add_files("src/*.c")
add_packages("openmp") |
你在什么场景下需要该功能?
现在openmp 是以rule的形式引进的
add_rules("c.openmp")
,但这种方式不够灵活,无法很容易的检测编译器是否有openmp支持,同时需要使用openmp的package也无法直接用add_deps("openmp")
来引入。描述可能的解决方案
把openmp做成fetch-only的package,然后用package来取代之前的rule
其他信息
在on_fetch中探测编译器feature的best practice是怎样的?
import("core.tool.compiler").has_flags("-fopenmp")
这样正确吗?The text was updated successfully, but these errors were encountered: