OpenCV4 + XMake
This commit is contained in:
122
xmake.lua
Normal file
122
xmake.lua
Normal file
@@ -0,0 +1,122 @@
|
||||
-- 设置项目信息
|
||||
set_project("SJTU-RM-CV")
|
||||
set_version("1.0.0")
|
||||
set_languages("c++17")
|
||||
|
||||
-- 设置构建模式
|
||||
set_rules("mode.release")
|
||||
set_optimize("fastest")
|
||||
|
||||
--导出构建指令
|
||||
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
|
||||
|
||||
-- 定义宏
|
||||
add_defines('PATH=\"$(projectdir)\"')
|
||||
add_defines("Linux")
|
||||
|
||||
-- 检查是否存在 config.h
|
||||
if os.isfile("others/include/config/config.h") or os.isfile("others/include/config.h") then
|
||||
add_defines("WITH_CONFIG")
|
||||
print("Found config.h")
|
||||
end
|
||||
|
||||
-- 添加依赖
|
||||
add_requires("eigen", {system = false})
|
||||
add_requires("pthread")
|
||||
|
||||
--- OpenCV 4.6.0 配置(启用 ffmpeg 和 contrib)
|
||||
add_requires("opencv", {
|
||||
system = false,
|
||||
configs = {
|
||||
ffmpeg = false,
|
||||
eigen = true,
|
||||
png = true,
|
||||
jpeg = true,
|
||||
webp = false,
|
||||
tiff = false,
|
||||
quirc = false,
|
||||
opengl = false,
|
||||
protobuf = false,
|
||||
bundled = true,
|
||||
gtk = true
|
||||
}
|
||||
})
|
||||
|
||||
-- 目标配置
|
||||
target("run")
|
||||
set_kind("binary")
|
||||
|
||||
-- 添加源文件
|
||||
add_files("main.cpp")
|
||||
add_files("others/src/*.cpp")
|
||||
add_files("others/src/camera/*.cpp")
|
||||
add_files("energy/src/energy/*.cpp")
|
||||
add_files("energy/src/energy/*/*.cpp")
|
||||
add_files("armor/src/armor_finder/*.cpp")
|
||||
add_files("armor/src/armor_finder/*/*.cpp")
|
||||
add_files("armor/src/show_images/*.cpp")
|
||||
|
||||
-- 添加头文件搜索路径
|
||||
add_includedirs("others/include")
|
||||
add_includedirs("others/include/camera")
|
||||
add_includedirs("others/include/config")
|
||||
add_includedirs("energy/include")
|
||||
add_includedirs("energy/include/energy")
|
||||
add_includedirs("armor/include")
|
||||
add_includedirs("armor/include/armor_finder")
|
||||
add_includedirs("armor/include/armor_finder/classifier")
|
||||
add_includedirs("armor/include/show_images")
|
||||
|
||||
-- 添加依赖包
|
||||
add_packages("pthread", "eigen", "opencv")
|
||||
|
||||
-- 添加链接目录
|
||||
add_linkdirs("others")
|
||||
|
||||
-- 根据平台链接相机 SDK
|
||||
if is_plat("linux") then
|
||||
add_links("MVSDK")
|
||||
print("current platform: Linux")
|
||||
elseif is_plat("windows") then
|
||||
add_links("MVCAMSDK_X64")
|
||||
print("current platform: Windows")
|
||||
elseif is_plat("macosx") then
|
||||
add_links("mvsdk")
|
||||
print("current platform: Mac")
|
||||
else
|
||||
print("Unsupported platform")
|
||||
end
|
||||
|
||||
-- 设置目标目录
|
||||
set_targetdir("$(builddir)")
|
||||
|
||||
-- 添加编译选项
|
||||
add_cxxflags("-O3")
|
||||
|
||||
-- 自定义任务:create-startup
|
||||
task("create-startup")
|
||||
set_category("action")
|
||||
on_run(function ()
|
||||
os.exec("$(projectdir)/tools/create-startup.sh $(projectdir) $(builddir)")
|
||||
end)
|
||||
set_menu {
|
||||
usage = "xmake create-startup",
|
||||
description = "Create startup script",
|
||||
options = {}
|
||||
}
|
||||
|
||||
-- 自定义任务:train-cnn
|
||||
task("train-cnn")
|
||||
set_category("action")
|
||||
on_run(function ()
|
||||
if os.host() == "linux" then
|
||||
os.exec("gnome-terminal -- bash -c \"$(projectdir)/tools/TrainCNN/backward.py\"")
|
||||
else
|
||||
print("train-cnn only supported on Linux with gnome-terminal")
|
||||
end
|
||||
end)
|
||||
set_menu {
|
||||
usage = "xmake train-cnn",
|
||||
description = "Train CNN model",
|
||||
options = {}
|
||||
}
|
||||
Reference in New Issue
Block a user