Skip to content

Commit

Permalink
osqp: fix building with ninja
Browse files Browse the repository at this point in the history
  • Loading branch information
tkhyn committed Apr 14, 2024
1 parent 5220af6 commit 448250d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
4 changes: 4 additions & 0 deletions recipes/osqp/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ sources:
"0.6.2":
url: "https://github.com/osqp/osqp/releases/download/v0.6.2/complete_sources.tar.gz"
sha256: "0a7ade2fa19f13e13bc12f6ea0046ef764049023efb4997a4e72a76534f623ec"
patches:
'0.6.3':
- patch_file: patches/0.6.3-Change-libraries-output-paths
base_path: source_subfolder
6 changes: 5 additions & 1 deletion recipes/osqp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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

Expand All @@ -24,6 +24,9 @@ class OsqpConan(ConanFile):
"fPIC": True,
}

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand Down Expand Up @@ -54,6 +57,7 @@ def generate(self):
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand Down
44 changes: 44 additions & 0 deletions recipes/osqp/all/patches/0.6.3-Change-libraries-output-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afd7bb94..89bc2a57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -274,7 +274,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 ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/static)

# Include directories for linear system solvers
target_include_directories(osqpstatic PRIVATE ${linsys_solvers_includes})
@@ -314,6 +314,7 @@ if (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})
+ set_target_properties(osqp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/shared)

# Include directories for linear system solvers
target_include_directories(osqp PRIVATE ${linsys_solvers_includes})

diff --git a/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt b/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
index 06c3d9c..7f106a6 100644
--- a/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
+++ b/lin_sys/direct/qdldl/qdldl_sources/CMakeLists.txt
@@ -104,7 +104,7 @@ include(GNUInstallDirs)
# Static library
add_library (qdldlstatic STATIC ${qdldl_src} ${qdldl_headers})
# Give same name to static library output
-set_target_properties(qdldlstatic PROPERTIES OUTPUT_NAME qdldl)
+set_target_properties(qdldlstatic PROPERTIES OUTPUT_NAME qdldl ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/static)

# Declare include directories for the cmake exported target
target_include_directories(qdldlstatic
@@ -143,6 +143,8 @@ install(TARGETS qdldl
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

+set_target_properties(qdldl PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/shared)
+
# Create demo executable (linked to static library)
add_executable (qdldl_example ${PROJECT_SOURCE_DIR}/examples/example.c)
target_link_libraries (qdldl_example qdldlstatic)

0 comments on commit 448250d

Please sign in to comment.