osqp: add v0.6.3 version (#5226)

* osqp: add v0.6.3 version

* qdldl: fix static build

* fix link order

* add_deps pkg-config

* improve pkg-config

* add fallback

* Revert "add fallback"

This reverts commit b3676efa0e.

* fix pkg-config for subhost windows
pull/5238/head
star9029 2 months ago committed by GitHub
parent 7721db2c3a
commit ce48c8ca4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 88
      packages/o/osqp/patches/0.6.3/cmake.patch
  2. 26
      packages/o/osqp/xmake.lua
  3. 30
      packages/q/qdldl/xmake.lua

@ -0,0 +1,88 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afd7bb94..a8ccb883 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -267,15 +267,18 @@ endif (R_LANG)
# Create Static Library
# ----------------------------------------------
-
+include(GNUInstallDirs)
+include(FindPkgConfig)
+pkg_search_module(qdldl REQUIRED IMPORTED_TARGET qdldl)
# Add linear system solvers cumulative library
add_subdirectory(lin_sys)
+if(NOT BUILD_SHARED_LIBS)
# Static library
add_library (osqpstatic STATIC ${osqp_src} ${osqp_headers} ${linsys_solvers})
# Give same name to static library output
set_target_properties(osqpstatic PROPERTIES OUTPUT_NAME osqp)
-
+target_link_libraries(osqpstatic PkgConfig::qdldl)
# Include directories for linear system solvers
target_include_directories(osqpstatic PRIVATE ${linsys_solvers_includes})
@@ -294,7 +297,7 @@ install(TARGETS osqpstatic
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
-
+endif()
# Install Headers
# ----------------------------------------------
@@ -310,10 +313,11 @@ endif (MATLAB)
# If we are building Python/Matlab/R interface:
# - do not build shared library
# - do not build demo
-if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
+if (BUILD_SHARED_LIBS)
# Create osqp shared library
# NB: Add all the linear system solvers here
add_library (osqp SHARED ${osqp_src} ${osqp_headers} ${linsys_solvers})
+ target_link_libraries(osqp PkgConfig::qdldl)
# Include directories for linear system solvers
target_include_directories(osqp PRIVATE ${linsys_solvers_includes})
@@ -331,10 +335,9 @@ if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
# Create demo executable (linked to static library)
- add_executable (osqp_demo ${PROJECT_SOURCE_DIR}/examples/osqp_demo.c)
- target_link_libraries (osqp_demo osqpstatic)
-endif (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
+
+endif (BUILD_SHARED_LIBS)
# Create CMake packages for the build directory
# ----------------------------------------------
diff --git a/lin_sys/direct/CMakeLists.txt b/lin_sys/direct/CMakeLists.txt
index c36c375a..2942cc9f 100644
--- a/lin_sys/direct/CMakeLists.txt
+++ b/lin_sys/direct/CMakeLists.txt
@@ -6,7 +6,7 @@ add_subdirectory(qdldl)
# Need to add qdldlobject only here because it cannot be
# included in another object library such as linsys_qdldl
-set(direct_linsys_solvers $<TARGET_OBJECTS:linsys_qdldl> $<TARGET_OBJECTS:qdldlobject>)
+set(direct_linsys_solvers $<TARGET_OBJECTS:linsys_qdldl> )
# NB. The second directory is added because we need to include the "qdldl_types.h" file in "qdldl_interface.h"
set(direct_linsys_solvers_includes
diff --git a/lin_sys/direct/qdldl/CMakeLists.txt b/lin_sys/direct/qdldl/CMakeLists.txt
index d78c4a38..b3429a12 100644
--- a/lin_sys/direct/qdldl/CMakeLists.txt
+++ b/lin_sys/direct/qdldl/CMakeLists.txt
@@ -1,5 +1,4 @@
# Add qdldl
-add_subdirectory(qdldl_sources)
if(NOT DEFINED EMBEDDED)
@@ -39,3 +38,4 @@ set(qdldl_interface_src
# Create object library for linear system solver interface
add_library(linsys_qdldl OBJECT ${qdldl_interface_src})
target_include_directories(linsys_qdldl PRIVATE ${qdldl_interface_includes} ${PROJECT_SOURCE_DIR}/include)
+target_link_libraries(linsys_qdldl PkgConfig::qdldl)

@ -1,19 +1,29 @@
package("osqp")
set_homepage("https://osqp.org/")
set_description("The Operator Splitting QP Solver")
set_license("Apache-2.0")
add_urls("https://github.com/oxfordcontrol/osqp.git")
add_versions("v0.6.2", "f9fc23d3436e4b17dd2cb95f70cfa1f37d122c24")
add_urls("https://github.com/osqp/osqp/releases/download/$(version)/osqp-$(version)-src.tar.gz",
"https://github.com/osqp/osqp.git")
add_versions("v0.6.3", "285b2a60f68d113a1090767ec8a9c81a65b3af2d258f8c78a31cc3f98ba58456")
add_patches("0.6.3", "patches/0.6.3/cmake.patch", "ffe3809019eebae7559e8c4016431e9d3e9bc35776d9affe65b83904dd753999")
add_deps("cmake")
on_install("windows", "macosx", "linux", "mingw", function (package)
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
if is_subhost("windows") then
add_deps("pkgconf")
elseif is_host("linux", "macosx", "bsd") then
add_deps("pkg-config")
end
add_deps("qdldl")
on_install(function (package)
local configs = {"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
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"))
if package:config("pic") ~= false then
table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
if package:config("shared") and package:is_plat("windows") then
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
end
import("package.tools.cmake").install(package, configs)
end)

@ -0,0 +1,30 @@
package("qdldl")
set_homepage("https://github.com/osqp/qdldl")
set_description("A free LDL factorisation routine")
set_license("Apache-2.0")
add_urls("https://github.com/osqp/qdldl/archive/refs/tags/$(version).tar.gz",
"https://github.com/osqp/qdldl.git")
add_versions("v0.1.7", "631ae65f367859fa1efade1656e4ba22b7da789c06e010cceb8b29656bf65757")
add_includedirs("include", "include/qdldl")
add_deps("cmake")
on_install(function (package)
if package:config("shared") then
package:add("defines", "QDLDL_SHARED_LIB")
end
local configs = {"-DQDLDL_BUILD_DEMO_EXE=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
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, "-DQDLDL_BUILD_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DQDLDL_BUILD_STATIC_LIB=" .. (package:config("shared") and "OFF" or "ON"))
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("QDLDL_etree", {includes = "qdldl/qdldl.h"}))
end)
Loading…
Cancel
Save