Jelajahi Sumber

add ceres-solver (#767)

Hoildkv 3 tahun lalu
induk
melakukan
76f7b09c64

+ 33 - 0
packages/c/ceres-solver/xmake.lua

@@ -0,0 +1,33 @@
+package("ceres-solver")
+
+    set_homepage("http://ceres-solver.org/")
+    set_description("Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems.")
+    
+    add_urls("http://ceres-solver.org/ceres-solver-$(version).tar.gz")
+    add_versions("2.0.0", "10298a1d75ca884aa0507d1abb0e0f04800a92871cd400d4c361b56a777a7603")
+
+    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_deps("cmake", "eigen", "glog", "gflags")
+    on_load("windows", "linux", "macosx", function (package)
+        if package:config("suitesparse") then
+            package:add("deps", "suitesparse", {configs = {blas = package:config("blas")}})
+        end
+    end)
+
+    on_install("windows", "linux", "macosx", function (package)
+        local configs = {"-DBUILD_TESTING=OFF", "-DBUILD_DOCUMENTATION=OFF", "-DBUILD_EXAMPLES=OFF", "-DBUILD_BENCHMARKS=OFF"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        if package:is_plat("windows") then
+            table.insert(configs, "-DMSVC_USE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
+        end
+        table.insert(configs, "-DSUITESPARSE=" .. (package:config("suitesparse") and "ON" or "OFF"))
+        table.insert(configs, "-DCXSPARSE=" .. (package:config("suitesparse") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cxxtypes("ceres::Problem", {configs = {languages = "c++14"}, includes = "ceres/ceres.h"}))
+    end)

+ 1 - 1
packages/o/openblas/xmake.lua

@@ -28,7 +28,7 @@ package("openblas")
         add_versions("0.3.18", "1632c1e8cca62d8bed064b37747e331a1796fc46f688626337362bf0d16aeadb")
 
         add_configs("fortran", {description = "Compile with fortran enabled.", default = is_plat("linux"), type = "boolean"})
-        add_configs("openmp",  {description = "Compile with OpenMP enabled.", default = true, type = "boolean"})
+        add_configs("openmp",  {description = "Compile with OpenMP enabled.", default = not is_plat("macosx"), type = "boolean"})
     end
 
     if is_plat("linux") then

+ 10 - 10
packages/s/suitesparse/port/xmake.lua

@@ -70,7 +70,7 @@ rule_end()
 
 add_rules("c.def_gen", {override = true})
 
-target("SuiteSparse_config")
+target("suitesparseconfig")
     set_kind("$(kind)")
     add_files("SuiteSparse_config/SuiteSparse_config.c")
     add_headerfiles("SuiteSparse_config/SuiteSparse_config.h")
@@ -80,7 +80,7 @@ target_end()
 for _, libname in ipairs({"AMD", "BTF", "CAMD", "CCOLAMD", "COLAMD"}) do
 target(libname)
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_files(libname .. "/Source/*.c", {prod_defs = {"none", "DLONG"}})
     add_includedirs(libname .. "/Include", {public = true})
     add_headerfiles(libname .. "/Include/*.h")
@@ -89,7 +89,7 @@ end
 
 target("CHOLMOD")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_deps("AMD", "CAMD", "COLAMD", "CCOLAMD")
     for _, module in ipairs({"Core", "Check", "Cholesky", "MatrixOps", "Partition", "Modify", "Supernodal"}) do
         add_files("CHOLMOD/" .. module .. "/cholmod*.c", {prod_defs = {"none", "DLONG"}})
@@ -107,7 +107,7 @@ target_end()
 
 target("CXSparse")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_files("CXSparse/Source/*.c|cs_convert.c", {prod_defs = {"none", "CS_LONG"}})
     add_includedirs("CXSparse/Include", {public = true})
     add_headerfiles("CXSparse/Include/*.h")
@@ -115,7 +115,7 @@ target_end()
 
 target("KLU")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_deps("AMD", "COLAMD", "BTF")
     add_files("KLU/Source/*.c", {prod_defs = {"none", "DLONG"}})
     add_includedirs("KLU/Include", {public = true})
@@ -124,7 +124,7 @@ target_end()
 
 target("LDL")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_files("LDL/Source/*.c", {prod_defs = {"none", "LDL_LONG"}})
     add_includedirs("LDL/Include", {public = true})
     add_headerfiles("LDL/Include/*.h")
@@ -132,7 +132,7 @@ target_end()
 
 target("UMFPACK")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_deps("AMD", "CHOLMOD")
     add_files("UMFPACK/Source/umfpack_timer.c", "UMFPACK/Source/umfpack_tictoc.c")
     local doubledefs = {"umf_analyze.c", "umf_apply_order.c", "umf_cholmod.c", "umf_colamd.c", "umf_free.c", "umf_fsize.c", "umf_is_permutation.c", "umf_malloc.c", "umf_realloc.c", "umf_report_perm.c", "umf_singletons.c"}
@@ -147,7 +147,7 @@ target_end()
 
 target("SPQR")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_deps("CHOLMOD")
     add_files("SPQR/Source/*.cpp")
     add_includedirs("SPQR/Include", {public = true})
@@ -172,7 +172,7 @@ end
 if has_config("with_cuda") then
 target("SuiteSparse_GPURuntime")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config")
+    add_deps("suitesparseconfig")
     add_packages("cuda")
     add_files("SuiteSparse_GPURuntime/Source/*.cpp")
     add_includedirs("SuiteSparse_GPURuntime/Include", {public = true})
@@ -181,7 +181,7 @@ target_end()
 
 target("GPUQREngine")
     set_kind("$(kind)")
-    add_deps("SuiteSparse_config", "SuiteSparse_GPURuntime")
+    add_deps("suitesparseconfig", "SuiteSparse_GPURuntime")
     add_files("GPUQREngine/Source/**.cpp", "GPUQREngine/Source/*.cu")
     add_includedirs("GPUQREngine/Include", {public = true})
     add_headerfiles("GPUQREngine/Include/(**.hpp)", "GPUQREngine/Include/(**.cu)")

+ 1 - 1
packages/s/suitesparse/xmake.lua

@@ -27,7 +27,7 @@ package("suitesparse")
             package:add("links", "GraphBLAS")
         end
         package:add("deps", package:config("blas"))
-        for _, lib in ipairs({"SPQR", "UMFPACK", "LDL", "KLU", "CXSparse", "CHOLMOD", "COLAMD", "CCOLAMD", "CAMD", "BTF", "AMD", "SuiteSparse_config"}) do
+        for _, lib in ipairs({"SPQR", "UMFPACK", "LDL", "KLU", "CXSparse", "CHOLMOD", "COLAMD", "CCOLAMD", "CAMD", "BTF", "AMD", "suitesparseconfig"}) do
             package:add("links", lib)
         end
     end)