Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[osqp-eigen, osqp] Add new port #41676

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ports/osqp-eigen/osqp-eigen.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8406ab9..24c6328 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,6 +144,7 @@ install_basic_package_files(${PROJECT_NAME}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
DEPENDENCIES ${OSQP_EIGEN_EXPORTED_DEPENDENCIES})

+if(0)
# Install package.xml to share
install(FILES package.xml DESTINATION share/cmake/osqp-eigen)

@@ -152,3 +153,4 @@ include(AddOsqpEigenUnitTest)
add_subdirectory(tests)

include(AddUninstallTarget)
+endif()
18 changes: 18 additions & 0 deletions ports/osqp-eigen/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO "robotology/osqp-eigen"
REF v${VERSION}
SHA512 92a801892ce11d3167e3f1eb98cd988e7be7cbc3caa070b1628977b7d881b34c1207d9c1443ba381d88be4133bda6d3e9195c931f9554537c86832841f1e61fb
PATCHES osqp-eigen.patch
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "osqpeigen" CONFIG_PATH "lib/cmake/OsqpEigen")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
22 changes: 22 additions & 0 deletions ports/osqp-eigen/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "osqp-eigen",
"version": "0.7.0",
"port-version": 2,
"description": "Simple C++ wrapper for the osqp library",
"homepage": "https://robotology.github.io/osqp-eigen/",
"dependencies": [
"eigen3",
{
"name": "osqp",
"version>=": "0.6.2"
},
aboelens marked this conversation as resolved.
Show resolved Hide resolved
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
45 changes: 45 additions & 0 deletions ports/osqp/osqp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64671fc6..4cf113c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -265,7 +265,7 @@ add_subdirectory(lin_sys)
# 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)
+set_target_properties(osqpstatic PROPERTIES OUTPUT_NAME osqp EXPORT_NAME osqp)

# Include directories for linear system solvers
target_include_directories(osqpstatic PRIVATE ${linsys_solvers_includes})
@@ -298,6 +298,7 @@ if (MATLAB)
target_link_libraries (osqpstatic ${Matlab_LIBRARIES})
endif (MATLAB)

+if(0)
# If we are building Python/Matlab/R interface:
# - do not build shared library
# - do not build demo
@@ -326,6 +327,7 @@ if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
target_link_libraries (osqp_demo osqpstatic)

endif (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
+endif()

# Create CMake packages for the build directory
# ----------------------------------------------
@@ -355,6 +357,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/osqp-config.cmake



+if(0)
# Add uninstall command
# ----------------------------------------------
if(NOT TARGET uninstall)
@@ -366,6 +369,7 @@ if(NOT TARGET uninstall)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
+endif()



52 changes: 52 additions & 0 deletions ports/osqp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO "osqp/osqp"
REF v0.6.2
SHA512 1e3e1e06891ba862d982f9f37503580268709bf1ea5008daab95393501c85aa69c79d321c45bc87dc53000274dd120c148b90c1797156e340fe361929ff2e324
PATCHES osqp.patch
)

vcpkg_download_distfile(
QDLDL
URLS "https://github.com/osqp/qdldl/archive/refs/tags/v0.1.5.tar.gz"
FILENAME "qdldl-0.1.5.tar.gz"
SHA512 3a224767708484d6728e4b0801210c5e7d4e906564c0855c7987876316cde7349c2717a169b4a6680495b0c71415be383e3e5c6826873fb92d7e93258a7a03a8
)
Comment on lines +13 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a candidate for a separate port?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is currently loaded as a git sub module, which is why I took this approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fyi I opened an issue on this upstream some time ago: osqp/osqp#85 . If I recall correctly the critical point is that osqp package also has some code-generation functionalities, and so at least for those they need access to qdldl source code, but I guess there is nothing preventing using an external qdldl for all other uses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And apparently I forgot that eventually we devendored qdldl in conda-forge, see https://github.com/conda-forge/libosqp-feedstock/blob/main/recipe/patches/0002-build-qdldl-interface-as-part-of-osqp.patch and conda-forge/libosqp-feedstock#8 .

fyi @h-vetinari as he is the author of the patch, so I guess he need to be onboard for the patch to be used here unless the copyright info of the conda-forge feedstock needs to be added here somehow.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feedstock is under bsd-3 license so the patch can be used freely. If properly attributed, even better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally got around to looking at the patch. It seems that the patch is not for compiling osqp against a separate installation of qdldl. Instead it pulls in the relevant code of qdldl and compiles it as part of osqp.

Copy link
Contributor

@traversaro traversaro Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally got around to looking at the patch. It seems that the patch is not for compiling osqp against a separate installation of qdldl. Instead it pulls in the relevant code of qdldl and compiles it as part of osqp.

Where did you get that impression? The patch explicitly removed the add_subdirectory of the submodule, and substitute it with a find_package(qdldl), see https://github.com/conda-forge/libosqp-feedstock/blob/a60a9fc6866820657fe71a112f35d99fe19a5978/recipe/patches/0002-build-qdldl-interface-as-part-of-osqp.patch#L64 . Are you sure you are not confusing qdldl itself with the qdldl_interface.h/qdldl_interface.c files that are instead the osqp files used to interface with qdldl ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I misread? "Since we were not building the MKL pardiso bindings correctly anyway we can just ignore the whole ./lin_sys folder, or rather: just take out what we need and put it in the sources directly, rather than muck around with trying to build a separate library."

Copy link
Contributor

@traversaro traversaro Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see why it is misleading. The folder contains both qdldl_interface.h and qdldl_interface.c, and the qdldl submodules, see https://github.com/osqp/osqp/tree/v0.6.3/lin_sys/direct/qdldl . If you check what the patch is actually doing, it takes the non-qdldl files and move them to the osqp library, while using the qdldl external library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks for the explanation.


vcpkg_extract_source_archive(
QDLDL_SOURCE_PATH
ARCHIVE "${QDLDL}"
PATCHES qdldl.patch
)

vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} -E copy_directory "${QDLDL_SOURCE_PATH}" "${SOURCE_PATH}/lin_sys/direct/qdldl/qdldl_sources/"
WORKING_DIRECTORY "${SOURCE_PATH}"
LOGNAME copy
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DPYTHON=OFF
-DMATLAB=OFF
-DR_LANG=OFF
-DUNITTESTS=OFF
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(
CONFIG_PATH "lib/cmake/osqp"
)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

file(
INSTALL "${SOURCE_PATH}/LICENSE"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
RENAME copyright
)
36 changes: 36 additions & 0 deletions ports/osqp/qdldl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 06c3d9c..6720029 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,6 +126,7 @@ install(TARGETS qdldlstatic
install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl")


+if(0)
# Install Shared Library
# ----------------------------------------------
# Create qdldl shared library
@@ -146,6 +147,7 @@ install(TARGETS qdldl
# Create demo executable (linked to static library)
add_executable (qdldl_example ${PROJECT_SOURCE_DIR}/examples/example.c)
target_link_libraries (qdldl_example qdldlstatic)
+endif()


# Create CMake packages for the build directory
@@ -176,6 +178,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qdldl-config.cmake



+if(0)
# Add uninstall command
# ----------------------------------------------
if(NOT TARGET uninstall)
@@ -187,6 +190,7 @@ if(NOT TARGET uninstall)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
+endif()



16 changes: 16 additions & 0 deletions ports/osqp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "osqp",
"version": "0.6.2",
"description": "The Operator Splitting QP Solver",
"homepage": "https://osqp.org/",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
8 changes: 8 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6832,6 +6832,14 @@
"baseline": "4.6.1",
"port-version": 0
},
"osqp": {
"baseline": "0.6.2",
"port-version": 0
},
"osqp-eigen": {
"baseline": "0.7.0",
"port-version": 2
},
"otl": {
"baseline": "4.0.478",
"port-version": 0
Expand Down
19 changes: 19 additions & 0 deletions versions/o-/osqp-eigen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"versions": [
{
"git-tree": "22e7cc81d95db7211121a9102764f38bbe0a58c4",
"version": "0.7.0",
"port-version": 2
},
{
"git-tree": "e7ea18207927577f82e9c0d9354355d5aa4fe278",
"version": "0.7.0",
"port-version": 1
},
{
"git-tree": "5ce5aa1c304bd2ceee4bfbc25e3b25be6408e0c2",
"version": "0.7.0",
"port-version": 0
}
]
}
9 changes: 9 additions & 0 deletions versions/o-/osqp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "ec510c3dc408a6286bad2dcb0e23b1275a2660dc",
"version": "0.6.2",
"port-version": 0
}
]
}
Loading