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 0.6.2 and 0.6.3 with Ninja generator + osqp build options #23539

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions recipes/osqp/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
"0.6.2":
url: "https://github.com/osqp/osqp/releases/download/v0.6.2/complete_sources.tar.gz"
sha256: "0a7ade2fa19f13e13bc12f6ea0046ef764049023efb4997a4e72a76534f623ec"
patches:
'0.6.2':
- patch_file: patches/0.6.2-add-build-shared-libs-condition.patch

Check warning on line 10 in recipes/osqp/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0.6.2-ad ... ^ (line: 10)
'0.6.3':
- patch_file: patches/0.6.3-add-build-shared-libs-condition.patch

Check warning on line 12 in recipes/osqp/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0.6.3-ad ... ^ (line: 12)
46 changes: 37 additions & 9 deletions recipes/osqp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

from conan import ConanFile
from conan.tools.files import get, copy, rm, rmdir
from conan.tools.files import get, copy, rm, rmdir, apply_conandata_patches, export_conandata_patches
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os
from conan.errors import ConanInvalidConfiguration

required_conan_version = ">=1.53.0"

Expand All @@ -18,16 +20,43 @@ class OsqpConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"printing": [True, False],
"profiling": [True, False],
"interrupt": [True, False],
"dfloat": [True, False],
"dlong": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"printing": True,
"profiling": True,
"interrupt": True,
"dfloat": False,
"dlong": True
}

options_description = {
"shared": "Build shared libraries",
"fPIC": "Build with -fPIC flag (only for static libraries",
"printing": "Enable solver printing",
"profiling": "Enable solver profiling / timing (see https://osqp.org/docs/solver/index.html#rho-step-size)",
"interrupt": "Enable user interrupt (Ctrl-C)",
"dfloat": "Use float numbers instead of doubles",
"dlong": "Use long integers (64bit) for indexing"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

An options_description = {...} field would be nice, since the meaning of the options isn't super obvious.


def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def validate(self):
if self.info.settings.os == "Windows" and self.info.options.shared:
raise ConanInvalidConfiguration("Building ahared OSQP library is not supported on Windows")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
Expand All @@ -44,16 +73,15 @@ def source(self):
def generate(self):
tc = CMakeToolchain(self)
tc.variables['UNITTESTS'] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool)
tc.variables["PRINTING"] = True
tc.variables["PROFILING"] = True
tc.variables["CTRLC"] = True
tc.variables["DFLOAT"] = False
tc.variables["DLONG"] = True
tc.variables["COVERAGE"] = False
tc.variables["ENABLE_MKL_PARDISO"] = True
tc.variables["PRINTING"] = self.options.printing
tc.variables["PROFILING"] = self.options.profiling
tc.variables["CTRLC"] = self.options.interrupt
tc.variables["DFLOAT"] = self.options.dfloat
tc.variables["DLONG"] = self.options.dlong
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64671fc6..b82ede28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -262,6 +262,7 @@ endif (R_LANG)
# 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
@@ -285,7 +286,7 @@ install(TARGETS osqpstatic
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
-
+endif()

# Install Headers
# ----------------------------------------------
@@ -294,14 +295,14 @@ install(FILES ${osqp_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/osqp")



-if (MATLAB)
+if (MATLAB AND NOT BUILD_SHARED_LIBS)
target_link_libraries (osqpstatic ${Matlab_LIBRARIES})
-endif (MATLAB)
+endif (MATLAB AND NOT BUILD_SHARED_LIBS)

# 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 AND NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
# Create osqp shared library
# NB: Add all the linear system solvers here
add_library (osqp SHARED ${osqp_src} ${osqp_headers} ${linsys_solvers})
@@ -321,11 +322,9 @@ if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
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)
+ set(UNITTESTS OFF)

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

# Create CMake packages for the build directory
# ----------------------------------------------
diff --git a/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt b/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
index 06c3d9c..426a7d2 100644
--- a/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
+++ b/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
@@ -99,6 +99,7 @@ target_include_directories(qdldlobject PRIVATE ${PROJECT_SOURCE_DIR}/include)
# Create Static Library
# ----------------------------------------------

+if (NOT BUILD_SHARED_LIBS)
include(GNUInstallDirs)

# Static library
@@ -120,6 +121,7 @@ install(TARGETS qdldlstatic
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

+endif()

# Install Headers
# ----------------------------------------------
@@ -128,6 +130,7 @@ install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl")

# Install Shared Library
# ----------------------------------------------
+if (BUILD_SHARED_LIBS)
# Create qdldl shared library
add_library (qdldl SHARED ${qdldl_src} ${qdldl_headers})

@@ -143,10 +146,9 @@ install(TARGETS qdldl
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

-# Create demo executable (linked to static library)
-add_executable (qdldl_example ${PROJECT_SOURCE_DIR}/examples/example.c)
-target_link_libraries (qdldl_example qdldlstatic)
+set(UNITTESTS OFF)

+endif()

# Create CMake packages for the build directory
# ----------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afd7bb94..b918420d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -271,6 +271,7 @@ endif (R_LANG)
# 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
@@ -294,7 +295,7 @@ install(TARGETS osqpstatic
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
-
+endif()

# Install Headers
# ----------------------------------------------
@@ -303,14 +304,14 @@ install(FILES ${osqp_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/osqp")



-if (MATLAB)
+if (MATLAB AND NOT BUILD_SHARED_LIBS)
target_link_libraries (osqpstatic ${Matlab_LIBRARIES})
-endif (MATLAB)
+endif (MATLAB AND NOT BUILD_SHARED_LIBS)

# 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 AND NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
# Create osqp shared library
# NB: Add all the linear system solvers here
add_library (osqp SHARED ${osqp_src} ${osqp_headers} ${linsys_solvers})
@@ -330,11 +331,9 @@ if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
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)
+ set(UNITTESTS OFF)

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

# Create CMake packages for the build directory
# ----------------------------------------------
diff --git a/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt b/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
index 06c3d9c..426a7d2 100644
--- a/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
+++ b/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
@@ -99,6 +99,7 @@ target_include_directories(qdldlobject PRIVATE ${PROJECT_SOURCE_DIR}/include)
# Create Static Library
# ----------------------------------------------

+if (NOT BUILD_SHARED_LIBS)
include(GNUInstallDirs)

# Static library
@@ -120,6 +121,7 @@ install(TARGETS qdldlstatic
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

+endif()

# Install Headers
# ----------------------------------------------
@@ -128,6 +130,7 @@ install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl")

# Install Shared Library
# ----------------------------------------------
+if (BUILD_SHARED_LIBS)
# Create qdldl shared library
add_library (qdldl SHARED ${qdldl_src} ${qdldl_headers})

@@ -143,10 +146,9 @@ install(TARGETS qdldl
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

-# Create demo executable (linked to static library)
-add_executable (qdldl_example ${PROJECT_SOURCE_DIR}/examples/example.c)
-target_link_libraries (qdldl_example qdldlstatic)
+set(UNITTESTS OFF)

+endif()

# Create CMake packages for the build directory
# ----------------------------------------------
Loading