conan-io / wishlist

This repo is to propose libraries, frameworks, and code in general that users would like to have in conan
MIT License
49 stars 5 forks source link

Ceres Solver #215

Closed Janos95 closed 4 years ago

Janos95 commented 5 years ago

From their homepage: Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It can be used to solve Non-linear Least Squares problems with bounds constraints and general unconstrained optimization problems. It is a mature, feature rich, and performant library that has been used in production at Google since 2010

uilianries commented 5 years ago

http://ceres-solver.org/

kylemacfarlan commented 5 years ago

I looked at this at one point. It depends on SuiteSparse (technically, it's optional, but I wouldn't want to use it without it). I have a suitesparse conan package here (https://github.com/kylemacfarlan/conan-suitesparse), which supports different options for the blas/lapack backend. But I've had some trouble getting it to work in CI (something with fortran libs, iirc), though it works on my machines with my local install of MKL.

mabrowning commented 5 years ago

This is what I came up with. You should be able to make your suitesparse recipe an optional requirement and it'll automatically pick it up.

from conans import ConanFile, CMake, tools
from conans.tools import download, unzip

class CeresSolverConan(ConanFile):
    name = "ceres-solver"
    version = "1.14.0"
    license = "New BSD"
    url = "https://github.com/ceres-solver/ceres-solver/"
    settings = "os", "compiler", "build_type", "arch"
    generators = "cmake_paths"
    requires = "eigen/3.3.7@conan/stable", "glog/0.3.5@bincrafters/stable", "gflags/2.2.1@bincrafters/stable"

    def source(self):
        zip_name = self.version+".zip"
        download("https://github.com/ceres-solver/ceres-solver/archive/"+self.version+".zip", zip_name)
        unzip(zip_name)

    def build(self):
        cmake = CMake(self)
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = "conan_paths.cmake" #generated by cmake_path generator
        cmake.definitions["BUILD_TESTING"] = False
        cmake.definitions["BUILD_EXAMPLES"] = False

        cmake.configure( source_folder=self.build_folder+'/ceres-solver-'+self.version )
        cmake.build()
        cmake.install()

    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)
        if not self.cpp_info.libs:
            raise Exception("No libs collected")
uilianries commented 5 years ago

@mabrowning did you create a project for your recipe? We could help you to promote it in Conan Center, or even push to Bincrafters.

mabrowning commented 5 years ago

Not a public one, just on our company's internal Conan remote. As always, a bit crunched for time, but I figured I'd at least put it where others might find it :)

Edit: It does at least work on VS2017 release/debug (Windows 10) & apple-clang 10 release/debug (macOS 10.13.6). Other platforms/settings untested.

Croydon commented 4 years ago

WIP: https://github.com/conan-io/conan-center-index/pull/588

Croydon commented 4 years ago

Done!