xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("ceres-solver")
  2. set_homepage("http://ceres-solver.org/")
  3. set_description("Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems.")
  4. set_license("BSD-3-Clause")
  5. add_urls("http://ceres-solver.org/ceres-solver-$(version).tar.gz")
  6. add_versions("2.0.0", "10298a1d75ca884aa0507d1abb0e0f04800a92871cd400d4c361b56a777a7603")
  7. add_versions("2.1.0", "f7d74eecde0aed75bfc51ec48c91d01fe16a6bf16bce1987a7073286701e2fc6")
  8. add_versions("2.2.0", "48b2302a7986ece172898477c3bcd6deb8fb5cf19b3327bc49969aad4cede82d")
  9. add_patches("2.1.0", "patches/2.1.0/int64.patch", "1df14f30abf1a942204b408c780eabbeac0859ba5a6db3459b55c47479583c57")
  10. add_configs("blas", {description = "Choose BLAS library to use.", default = "openblas", type = "string", values = {"mkl", "openblas"}})
  11. add_configs("suitesparse", {description = "Enable SuiteSparse.", default = true, type = "boolean"})
  12. add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"})
  13. add_deps("cmake", "eigen", "glog", "gflags")
  14. on_load(function (package)
  15. if package:config("suitesparse") then
  16. package:add("deps", "suitesparse", {configs = {blas = package:config("blas")}})
  17. package:add("deps", "openmp")
  18. end
  19. if package:config("cuda") then
  20. package:add("deps", "cuda")
  21. end
  22. end)
  23. on_install("windows|x64", "windows|x86", "linux", "macosx", function (package)
  24. local configs = {
  25. "-DBUILD_TESTING=OFF",
  26. "-DBUILD_DOCUMENTATION=OFF",
  27. "-DBUILD_EXAMPLES=OFF",
  28. "-DBUILD_BENCHMARKS=OFF",
  29. "-DCXSPARSE=OFF"
  30. }
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  33. if package:is_plat("windows") then
  34. table.insert(configs, "-DMSVC_USE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  35. end
  36. table.insert(configs, "-DSUITESPARSE=" .. (package:config("suitesparse") and "ON" or "OFF"))
  37. table.insert(configs, "-DUSE_CUDA=" .. (package:config("cuda") and "ON" or "OFF"))
  38. if package:config("suitesparse") then
  39. import("package.tools.cmake").install(package, configs, {packagedeps = {"openmp", "libomp"}})
  40. else
  41. import("package.tools.cmake").install(package, configs)
  42. end
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cxxtypes("ceres::Problem", {configs = {languages = "c++17"}, includes = "ceres/ceres.h"}))
  46. end)