diff --git a/recipes/qpoases/all/CMakeLists.txt b/recipes/qpoases/all/CMakeLists.txt new file mode 100644 index 0000000000000..bd3083b512cb9 --- /dev/null +++ b/recipes/qpoases/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/qpoases/all/conandata.yml b/recipes/qpoases/all/conandata.yml new file mode 100644 index 0000000000000..84a9b6ebffb36 --- /dev/null +++ b/recipes/qpoases/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.2.1": + url: "https://github.com/coin-or/qpOASES/archive/releases/3.2.1.tar.gz" + sha256: "a7d153b4e23ee66bd50cdb6e84291d0084d9967a9c788a4d873440a6b10ca13b" diff --git a/recipes/qpoases/all/conanfile.py b/recipes/qpoases/all/conanfile.py new file mode 100644 index 0000000000000..1b1c363f97808 --- /dev/null +++ b/recipes/qpoases/all/conanfile.py @@ -0,0 +1,59 @@ +import os +from conans import ConanFile, CMake, tools + + +class ConanRecipe(ConanFile): + name = "qpoases" + + description = "Open-source C++ implementation of the recently proposed online active set strategy." + topics = ("conan", "container", "parametric", "quadratic", "programming") + + homepage = "https://github.com/coin-or/qpOASES" + url = "https://github.com/conan-io/conan-center-index" + + license = "LGPL-2.1" + + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + + settings = "os", "arch", "compiler", "build_type" + options = {"fPIC": [True, False]} + default_options = {"fPIC": True} + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = "qpOASES-releases-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["QPOASES_BUILD_EXAMPLES"] = False + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "qpOASES" + self.cpp_info.names["cmake_find_package_multi"] = "qpOASES" + + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/qpoases/all/test_package/CMakeLists.txt b/recipes/qpoases/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8ed5cd5c3e757 --- /dev/null +++ b/recipes/qpoases/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +set(CMAKE_CXX_STANDARD 11) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(qpOASES REQUIRED) + +add_executable(test_package test_package.cpp) + +target_link_libraries(test_package PRIVATE qpOASES::qpOASES) diff --git a/recipes/qpoases/all/test_package/conanfile.py b/recipes/qpoases/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1df900244a291 --- /dev/null +++ b/recipes/qpoases/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/qpoases/all/test_package/test_package.cpp b/recipes/qpoases/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4cc35c7cad9d1 --- /dev/null +++ b/recipes/qpoases/all/test_package/test_package.cpp @@ -0,0 +1,62 @@ +// from: https://github.com/coin-or/qpOASES/blob/master/examples/example1.cpp + +#include + + +/** Example for qpOASES main function using the QProblem class. */ +int main( ) +{ + USING_NAMESPACE_QPOASES + + /* Setup data of first QP. */ + real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; + real_t A[1*2] = { 1.0, 1.0 }; + real_t g[2] = { 1.5, 1.0 }; + real_t lb[2] = { 0.5, -2.0 }; + real_t ub[2] = { 5.0, 2.0 }; + real_t lbA[1] = { -1.0 }; + real_t ubA[1] = { 2.0 }; + + /* Setup data of second QP. */ + real_t g_new[2] = { 1.0, 1.5 }; + real_t lb_new[2] = { 0.0, -1.0 }; + real_t ub_new[2] = { 5.0, -0.5 }; + real_t lbA_new[1] = { -2.0 }; + real_t ubA_new[1] = { 1.0 }; + + + /* Setting up QProblem object. */ + QProblem example( 2,1 ); + + Options options; + example.setOptions( options ); + + /* Solve first QP. */ + int_t nWSR = 10; + example.init( H,g,A,lb,ub,lbA,ubA, nWSR ); + + /* Get and print solution of first QP. */ + real_t xOpt[2]; + real_t yOpt[2+1]; + example.getPrimalSolution( xOpt ); + example.getDualSolution( yOpt ); + printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", + xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() ); + + /* Solve second QP. */ + nWSR = 10; + example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR ); + + /* Get and print solution of second QP. */ + example.getPrimalSolution( xOpt ); + example.getDualSolution( yOpt ); + printf( "\nxOpt = [ %e, %e ]; yOpt = [ %e, %e, %e ]; objVal = %e\n\n", + xOpt[0],xOpt[1],yOpt[0],yOpt[1],yOpt[2],example.getObjVal() ); + + example.printOptions(); + /*example.printProperties();*/ + + /*getGlobalMessageHandler()->listAllMessages();*/ + + return 0; +} diff --git a/recipes/qpoases/config.yml b/recipes/qpoases/config.yml new file mode 100644 index 0000000000000..c09805f11822d --- /dev/null +++ b/recipes/qpoases/config.yml @@ -0,0 +1,3 @@ +versions: + "3.2.1": + folder: all