浏览代码

ceres-solver: add cuda configs

star9029 1 年之前
父节点
当前提交
061a3ad2f3
共有 1 个文件被更改,包括 17 次插入5 次删除
  1. 17 5
      packages/c/ceres-solver/xmake.lua

+ 17 - 5
packages/c/ceres-solver/xmake.lua

@@ -1,5 +1,4 @@
 package("ceres-solver")
 package("ceres-solver")
-
     set_homepage("http://ceres-solver.org/")
     set_homepage("http://ceres-solver.org/")
     set_description("Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems.")
     set_description("Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems.")
     set_license("BSD-3-Clause")
     set_license("BSD-3-Clause")
@@ -11,25 +10,38 @@ package("ceres-solver")
 
 
     add_patches("2.1.0", "patches/2.1.0/int64.patch", "1df14f30abf1a942204b408c780eabbeac0859ba5a6db3459b55c47479583c57")
     add_patches("2.1.0", "patches/2.1.0/int64.patch", "1df14f30abf1a942204b408c780eabbeac0859ba5a6db3459b55c47479583c57")
 
 
-    add_configs("blas",        {description = "Choose BLAS library to use.", default = "openblas", type = "string", values = {"mkl", "openblas"}})
+    add_configs("blas", {description = "Choose BLAS library to use.", default = "openblas", type = "string", values = {"mkl", "openblas"}})
     add_configs("suitesparse", {description = "Enable SuiteSparse.", default = true, type = "boolean"})
     add_configs("suitesparse", {description = "Enable SuiteSparse.", default = true, type = "boolean"})
+    add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"})
 
 
     add_deps("cmake", "eigen", "glog", "gflags")
     add_deps("cmake", "eigen", "glog", "gflags")
-    on_load("windows", "linux", "macosx", function (package)
+
+    on_load(function (package)
         if package:config("suitesparse") then
         if package:config("suitesparse") then
             package:add("deps", "suitesparse", {configs = {blas = package:config("blas")}})
             package:add("deps", "suitesparse", {configs = {blas = package:config("blas")}})
             package:add("deps", "openmp")
             package:add("deps", "openmp")
         end
         end
+        if package:config("cuda") then
+            package:add("deps", "cuda")
+        end
     end)
     end)
 
 
     on_install("windows|x64", "windows|x86", "linux", "macosx", function (package)
     on_install("windows|x64", "windows|x86", "linux", "macosx", function (package)
-        local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_DOCUMENTATION=OFF", "-DBUILD_EXAMPLES=OFF", "-DBUILD_BENCHMARKS=OFF", "-DCXSPARSE=OFF"}
-        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        local configs = {
+            "-DBUILD_TESTING=OFF",
+            "-DBUILD_DOCUMENTATION=OFF",
+            "-DBUILD_EXAMPLES=OFF",
+            "-DBUILD_BENCHMARKS=OFF",
+            "-DCXSPARSE=OFF"
+        }
+
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         if package:is_plat("windows") then
         if package:is_plat("windows") then
             table.insert(configs, "-DMSVC_USE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
             table.insert(configs, "-DMSVC_USE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
         end
         end
         table.insert(configs, "-DSUITESPARSE=" .. (package:config("suitesparse") and "ON" or "OFF"))
         table.insert(configs, "-DSUITESPARSE=" .. (package:config("suitesparse") and "ON" or "OFF"))
+        table.insert(configs, "-DUSE_CUDA=" .. (package:config("cuda") and "ON" or "OFF"))
         if package:config("suitesparse") then
         if package:config("suitesparse") then
             import("package.tools.cmake").install(package, configs, {packagedeps = {"openmp", "libomp"}})
             import("package.tools.cmake").install(package, configs, {packagedeps = {"openmp", "libomp"}})
         else
         else