improve opencv (#460)

pull/461/head
Hoildkv 4 years ago committed by GitHub
parent 6bebad94e2
commit 2f09671386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      packages/o/opencv/xmake.lua

@ -17,7 +17,7 @@ package("opencv")
add_configs("bundled", {description = "Build 3rd-party libraries with OpenCV.", default = true, type = "boolean"}) add_configs("bundled", {description = "Build 3rd-party libraries with OpenCV.", default = true, type = "boolean"})
add_deps("cmake", "python 3.x") add_deps("cmake", "python 3.x", {kind = "binary"})
local features = {"1394", local features = {"1394",
"vtk", "vtk",
@ -65,8 +65,18 @@ package("opencv")
add_syslinks("gdi32", "user32", "glu32", "opengl32", "advapi32", "comdlg32") add_syslinks("gdi32", "user32", "glu32", "opengl32", "advapi32", "comdlg32")
end end
on_load("linux", "macosx", function (package) on_load("linux", "macosx", "windows", function (package)
if package:version():ge("4.0") then if package:is_plat("windows") then
local arch = (package:is_arch("x64") and "x64" or "x86")
local linkdir = (package:config("shared") and "lib" or "staticlib")
local vs = import("core.tool.toolchain").load("msvc"):config("vs")
local vc_ver = "vc13"
if vs == "2015" then vc_ver = "vc14"
elseif vs == "2017" then vc_ver = "vc15"
elseif vs == "2019" then vc_ver = "vc16"
end
package:add("linkdirs", path.join(arch, vc_ver, linkdir))
elseif package:version():ge("4.0") then
package:add("includedirs", "include/opencv4") package:add("includedirs", "include/opencv4")
end end
if package:config("blas") then if package:config("blas") then
@ -77,18 +87,6 @@ package("opencv")
end end
end) end)
on_load("windows", function (package)
local arch = (package:is_arch("x64") and "x64" or "x86")
local linkdir = (package:config("shared") and "lib" or "staticlib")
local vs = import("core.tool.toolchain").load("msvc"):config("vs")
local vc_ver = "vc13"
if vs == "2015" then vc_ver = "vc14"
elseif vs == "2017" then vc_ver = "vc15"
elseif vs == "2019" then vc_ver = "vc16"
end
package:add("linkdirs", path.join(arch, vc_ver, linkdir))
end)
on_install("linux", "macosx", "windows", function (package) on_install("linux", "macosx", "windows", function (package)
io.replace("cmake/OpenCVUtils.cmake", "if(PKG_CONFIG_FOUND OR PkgConfig_FOUND)", "if(NOT WIN32 AND (PKG_CONFIG_FOUND OR PkgConfig_FOUND))", {plain = true}) io.replace("cmake/OpenCVUtils.cmake", "if(PKG_CONFIG_FOUND OR PkgConfig_FOUND)", "if(NOT WIN32 AND (PKG_CONFIG_FOUND OR PkgConfig_FOUND))", {plain = true})
local configs = {"-DCMAKE_OSX_DEPLOYMENT_TARGET=", local configs = {"-DCMAKE_OSX_DEPLOYMENT_TARGET=",
@ -100,7 +98,8 @@ package("opencv")
"-DOPENCV_ENABLE_NONFREE=ON", "-DOPENCV_ENABLE_NONFREE=ON",
"-DOPENCV_GENERATE_PKGCONFIG=ON", "-DOPENCV_GENERATE_PKGCONFIG=ON",
"-DBUILD_opencv_python2=OFF", "-DBUILD_opencv_python2=OFF",
"-DBUILD_opencv_python3=ON"} "-DBUILD_opencv_python3=OFF",
"-DBUILD_JAVA=OFF"}
if package:config("bundled") then if package:config("bundled") then
table.insert(configs, "-DOPENCV_FORCE_3RDPARTY_BUILD=ON") table.insert(configs, "-DOPENCV_FORCE_3RDPARTY_BUILD=ON")
end end

Loading…
Cancel
Save