Skip to content
Merged
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
57 changes: 25 additions & 32 deletions .github/workflows/matlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,15 @@ jobs:
fail-fast: false
matrix:
build_type: [Release]
os: [ubuntu-22.04, windows-2019, macos-latest]
matlab_version: [R2020a, R2020b, R2021a, latest]
exclude:
# R2020* is not supported on Windows on GitHub Actions
- os: windows-2019
matlab_version: R2020a
build_type: Release
- os: windows-2019
matlab_version: R2020b
build_type: Release
os: [ubuntu-24.04, windows-latest]
matlab_version: [R2023b, R2024a, latest]

steps:
- uses: actions/checkout@v2

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
channels: conda-forge,robotology

Expand All @@ -47,35 +39,21 @@ jobs:
with:
release: ${{ matrix.matlab_version }}

# workaround for https://github.com/robotology/robotology-superbuild/issues/64
- name: Do not use MATLAB's stdc++ to avoid incompatibilities with other libraries
if: contains(matrix.os, 'ubuntu')
run:
echo 'LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6' >> $GITHUB_ENV

- name: Dependencies
run: |
# Workaround for https://github.com/conda-incubator/setup-miniconda/issues/186
conda config --remove channels defaults
# Compilation related dependencies
mamba install cmake compilers make ninja pkg-config
conda install cmake cxx-compiler make ninja pkg-config
# Actual dependencies
mamba install osqp
conda install libosqp
# Just a trick to make sure that the relevant installation path are on MATLABPATH
mamba install -c conda-forge -c robotology idyntree-matlab-bindings

# Additional dependencies useful only on Windows
- name: Dependencies [Conda/Windows]
if: contains(matrix.os, 'windows')
run: |
# Additional dependencies only useful on Windows
# See https://github.com/robotology/robotology-superbuild/issues/477
mamba install vs2019_win-64
conda install -c conda-forge -c robotology idyntree-matlab-bindings

- name: Print used environment [Conda]
shell: bash -l {0}
run: |
mamba list
conda list
env

- name: Configure [Conda - Linux or macOS]
Expand All @@ -87,12 +65,21 @@ jobs:

- name: Configure [Conda - Windows]
if: contains(matrix.os, 'windows')
shell: cmd /C CALL {0}
run: |
mkdir build
cd build
cmake -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX}/Library -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTING:BOOL=ON ..
cmake -GNinja -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBUILD_TESTING:BOOL=ON ..

- name: Build [Conda - Linux or macOS]
if: contains(matrix.os, 'macos') || contains(matrix.os, 'ubuntu')
run: |
cd build
cmake --build . --config ${{ matrix.build_type }}

- name: Build
- name: Build [Conda - Windows]
if: contains(matrix.os, 'windows')
shell: cmd /C CALL {0}
run: |
cd build
cmake --build . --config ${{ matrix.build_type }}
Expand All @@ -102,6 +89,12 @@ jobs:
cd build
cmake --install . --config ${{ matrix.build_type }}

# workaround for https://github.com/robotology/robotology-superbuild/issues/64
- name: Do not use MATLAB's stdc++ to avoid incompatibilities with other libraries
if: contains(matrix.os, 'ubuntu')
run:
echo 'LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6' >> $GITHUB_ENV

- name: Test
run: |
cd build
Expand Down
29 changes: 21 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

cmake_minimum_required(VERSION 3.16)

set(OSQP_MATLAB_UPSTREAM_VERSION 0.6.2)
set(OSQP_MATLAB_CMAKE_REVISION 4)
# osqp-matlab 0.9.0 does not exists, but we use it as osqp-matlab 1.0.0 was never released
set(OSQP_MATLAB_UPSTREAM_VERSION 0.9.0)
set(OSQP_MATLAB_CMAKE_REVISION 0)
set(OSQP_MATLAB_CMAKE_VERSION "${OSQP_MATLAB_UPSTREAM_VERSION}.${OSQP_MATLAB_CMAKE_REVISION}")
project(osqp-matlab-cmake-buildsystem
LANGUAGES C CXX
Expand Down Expand Up @@ -60,12 +61,15 @@ find_package(osqp REQUIRED)
## To use with some the osqp-matlab source coming from some other source, comment out
# the FetchContent* commands and set manually osqp-matlab_SOURCE_DIR
include(FetchContent)
# Temporary pointing to a fork, see https://github.com/oxfordcontrol/osqp-matlab/pull/34
# Temporary pointing to a commit as osqp-matlab v1.0.0 was never released
# furthermore we need also the fixes:
# * https://github.com/osqp/osqp-matlab/pull/61, to avoid that a buffer allocate by the system allocator (inside osqp) is delete by the matlab allocator (inside osqp-matlab)
# * https://github.com/osqp/osqp-matlab/pull/62
FetchContent_Declare(
osqp-matlab
GIT_REPOSITORY https://github.com/traversaro/osqp-matlab
# GIT_TAG v${OSQP_MATLAB_UPSTREAM_VERSION}
GIT_TAG 09faf01f42f7a73fac0b03332e6b0f6976a943c8
GIT_TAG f41846a2a461839bd4e76c3ed93bfcf0459b0d69
)

FetchContent_MakeAvailable(osqp-matlab)
Expand All @@ -74,8 +78,17 @@ FetchContent_MakeAvailable(osqp-matlab)
file(DOWNLOAD "https://raw.githubusercontent.com/oxfordcontrol/osqp/v${OSQP_MATLAB_UPSTREAM_VERSION}/lin_sys/direct/qdldl/qdldl_interface.h" ${CMAKE_CURRENT_BINARY_DIR}/workaround_include/qdldl_interface.h)

# Common source files
set(M_FILES ${osqp-matlab_SOURCE_DIR}/osqp.m)
set(MEX_FILES ${osqp-matlab_SOURCE_DIR}/osqp_mex.hpp ${osqp-matlab_SOURCE_DIR}/osqp_mex.cpp)
file(GLOB MEX_FILES
"${osqp-matlab_SOURCE_DIR}/c_sources/*.h"
"${osqp-matlab_SOURCE_DIR}/c_sources/*.c"
"${osqp-matlab_SOURCE_DIR}/c_sources/*.hpp"
"${osqp-matlab_SOURCE_DIR}/c_sources/*.cpp"
)

# The interrupt_matlab.c is used to customize the osqp library to support
# being interrupted from matlab, that we can't do here as we do not recompile osqp
list(REMOVE_ITEM MEX_FILES
"${osqp-matlab_SOURCE_DIR}/c_sources/interrupt_matlab.c")

if(OSQP_MATLAB_USES_MATLAB)
find_package(Matlab REQUIRED)
Expand All @@ -100,7 +113,7 @@ if(OSQP_MATLAB_USES_MATLAB)
EXPORT ${PROJECT_NAME}
DESTINATION ${OSQP_MATLAB_INSTALL_MATLAB_LIBDIR})
install(
FILES ${M_FILES}
DIRECTORY ${osqp-matlab_SOURCE_DIR}/@osqp
DESTINATION ${OSQP_MATLAB_INSTALL_MATLAB_MFILESDIR})

# Enable tests
Expand Down Expand Up @@ -136,7 +149,7 @@ if(OSQP_MATLAB_USES_OCTAVE)
EXPORT ${PROJECT_NAME}
DESTINATION ${OSQP_MATLAB_INSTALL_OCTAVE_LIBDIR})
install(
FILES ${M_FILES}
DIRECTORY ${osqp-matlab_SOURCE_DIR}/@osqp
DESTINATION ${OSQP_MATLAB_INSTALL_OCTAVE_MFILESDIR})
endif()

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ Materials in this repository are distributed under the following license:

The version of this `CMake` project is chosen in accordance of the original project, plus a fourth version that describes if several CMake buildsystem
versions were released, for example the version `x.y.z.t` is the one corresponding to the `x.y.z` version of osqp-matlab, while `t` is the number that can be
increased if changes are done to the CMake buildsystem.
increased if changes are done to the CMake buildsystem. An exeception was done for `osqp` 1.0.0, that was initially released without a corresponding `osqp-matlab` version,
so a `osqp` 1.0.0-compatible version was released under the `0.9.*` version number.
Loading