|
|
|
@ -7,62 +7,68 @@ package("openmp") |
|
|
|
|
add_configs("experimental", {description = "Enable experimental OpenMP feature for msvc.", default = true, type = boolean}) |
|
|
|
|
|
|
|
|
|
on_load(function (package) |
|
|
|
|
if package.has_tool then |
|
|
|
|
for _, toolkind in ipairs({"cc", "cxx"}) do |
|
|
|
|
if package:config("runtime") == "default" then |
|
|
|
|
if package:has_tool(toolkind, "clang", "clangxx") then |
|
|
|
|
if package:is_plat("macosx") then |
|
|
|
|
package:add("deps", "libomp") -- need to tell apple clang from llvm clang |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_fetch(function (package) |
|
|
|
|
for _, dep in ipairs(package:orderdeps()) do |
|
|
|
|
if not dep:fetch() then |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
local result = {} |
|
|
|
|
if package.has_tool then |
|
|
|
|
for _, toolkind in ipairs({"cc", "cxx"}) do |
|
|
|
|
local flagname = toolkind == "cxx" and "cxxflags" or "cflags" |
|
|
|
|
if package:has_tool(toolkind, "cl") then |
|
|
|
|
package:add(flagname, (package:config("experimental") and "/openmp:experimental" or "/openmp")) |
|
|
|
|
result[flagname] = (package:config("experimental") and "/openmp:experimental" or "/openmp") |
|
|
|
|
elseif package:has_tool(toolkind, "clang", "clangxx") then |
|
|
|
|
if package:is_plat("macosx") then |
|
|
|
|
package:add(flagname, "-Xpreprocessor -fopenmp") |
|
|
|
|
result[flagname] = "-Xpreprocessor -fopenmp" |
|
|
|
|
else |
|
|
|
|
package:add(flagname, "-fopenmp") |
|
|
|
|
result[flagname] = "-fopenmp" |
|
|
|
|
end |
|
|
|
|
elseif package:has_tool(toolkind, "gcc", "gxx") then |
|
|
|
|
package:add(flagname, "-fopenmp") |
|
|
|
|
result[flagname] = "-fopenmp" |
|
|
|
|
elseif package:has_tool(toolkind, "icc", "icpc") then |
|
|
|
|
package:add(flagname, "-qopenmp") |
|
|
|
|
result[flagname] = "-qopenmp" |
|
|
|
|
elseif package:has_tool(toolkind, "icl") then |
|
|
|
|
package:add(flagname, "-Qopenmp") |
|
|
|
|
result[flagname] = "-Qopenmp" |
|
|
|
|
end |
|
|
|
|
if package:config("runtime") == "default" then |
|
|
|
|
if package:has_tool(toolkind, "cl") then |
|
|
|
|
package:add("ldflags", "/openmp") |
|
|
|
|
result.ldflags = "/openmp" |
|
|
|
|
elseif package:has_tool(toolkind, "clang", "clangxx") then |
|
|
|
|
if package:is_plat("macosx") then |
|
|
|
|
package:add("deps", "libomp") -- need to tell apple clang from llvm clang |
|
|
|
|
else |
|
|
|
|
package:add("ldflags", "-fopenmp") |
|
|
|
|
if not package:is_plat("macosx") then |
|
|
|
|
result.ldflags = "-fopenmp" |
|
|
|
|
end |
|
|
|
|
elseif package:has_tool(toolkind, "gcc", "gxx") then |
|
|
|
|
package:add("ldflags", "-fopenmp") |
|
|
|
|
result.ldflags = "-fopenmp" |
|
|
|
|
elseif package:has_tool(toolkind, "icc", "icpc") then |
|
|
|
|
package:add("ldflags", "-qopenmp") |
|
|
|
|
result.ldflags = "-qopenmp" |
|
|
|
|
elseif package:has_tool(toolkind, "icl") then |
|
|
|
|
package:add("ldflags", "-Qopenmp") |
|
|
|
|
result.ldflags = "-Qopenmp" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if package:config("runtime") == "custom" then |
|
|
|
|
if package:has_tool(toolkind, "cl") then |
|
|
|
|
package:add("ldflags", "/openmp") |
|
|
|
|
package:add("ldflags", "/nodefaultlib:vcomp") |
|
|
|
|
result.ldflags = "/openmp" |
|
|
|
|
result.ldflags = "/nodefaultlib:vcomp" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_fetch(function (package) |
|
|
|
|
for _, dep in ipairs(package:orderdeps()) do |
|
|
|
|
if not dep:fetch() then |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
-- we need fetch the installed flags in on_load |
|
|
|
|
local manifest = package:manifest_load() |
|
|
|
|
if manifest then |
|
|
|
|
return manifest.vars |
|
|
|
|
end |
|
|
|
|
return (result.cflags or result.cxxflags) and result |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_install("linux", "macosx", "windows", function (package) |
|
|
|
|