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

Add libqdldl recipe #15140

Merged
merged 9 commits into from
Jun 7, 2021
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
25 changes: 25 additions & 0 deletions recipes/libqdldl/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
mkdir build
cd build

cmake ^
-G "NMake Makefiles" ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=True ^
-DBUILD_SHARED_LIBS=ON ^
-DBUILD_TESTING=ON ^
-DUNITTESTS=OFF ^
%SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

:: Test
ctest --output-on-failure -C Release
if errorlevel 1 exit 1
18 changes: 18 additions & 0 deletions recipes/libqdldl/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

mkdir build
cd build

cmake ${CMAKE_ARGS} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=True \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=ON \
-DUNITTESTS=ON \
..

cmake --build . --config Release --parallel ${CPU_COUNT}
cmake --build . --config Release --parallel ${CPU_COUNT} --target install
if [[ "${CONDA_BUILD_CROSS_COMPILATION}" != "1" ]]; then
ctest --output-on-failure -C Release
fi
73 changes: 73 additions & 0 deletions recipes/libqdldl/fix_build_shared_libs_and_windows_shared.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From e093889e54bfba4676fe95ce0bbb3eb578ae74b3 Mon Sep 17 00:00:00 2001
From: Silvio Traversaro <[email protected]>
Date: Wed, 2 Jun 2021 23:12:42 +0200
Subject: [PATCH] Respect BUILD_SHARED_LIBS and fix shared library on Windows

---
CMakeLists.txt | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 06c3d9c..e17300a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,26 +101,6 @@ target_include_directories(qdldlobject PRIVATE ${PROJECT_SOURCE_DIR}/include)

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)
-
-# Declare include directories for the cmake exported target
-target_include_directories(qdldlstatic
- PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
- "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/qdldl>")
-
-# Install Static Library
-# ----------------------------------------------
-
-install(TARGETS qdldlstatic
- EXPORT ${PROJECT_NAME}
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
-
-
# Install Headers
# ----------------------------------------------
install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl")
@@ -128,21 +108,28 @@ install(FILES ${qdldl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/qdldl")

# Install Shared Library
# ----------------------------------------------
-# Create qdldl shared library
-add_library (qdldl SHARED ${qdldl_src} ${qdldl_headers})
+# Create qdldl shared or static library, depending on BUILD_SHARED_LIBS
+add_library (qdldl ${qdldl_src} ${qdldl_headers})
+
+if(BUILD_SHARED_LIBS)
+ set_target_properties(qdldl PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+endif()

# Declare include directories for the cmake exported target
target_include_directories(qdldl
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/qdldl>")

-# Install qdldl shared library
+# Install qdldl library
install(TARGETS qdldl
EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

+# Add qdldlstatic alias
+add_library(qdldlstatic ALIAS qdldl)
+
# Create demo executable (linked to static library)
add_executable (qdldl_example ${PROJECT_SOURCE_DIR}/examples/example.c)
target_link_libraries (qdldl_example qdldlstatic)

46 changes: 46 additions & 0 deletions recipes/libqdldl/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% set name = "libqdldl" %}
{% set version = "0.1.5" %}

package:
name: {{ name }}
version: {{ version }}

source:
- url: https://github.com/osqp/qdldl/archive/v{{ version }}.tar.gz
sha256: 2868b0e61b7424174e9adef3cb87478329f8ab2075211ef28fe477f29e0e5c99
patches:
- fix_build_shared_libs_and_windows_shared.patch

build:
number: 0
run_exports:
- {{ pin_subpackage(name, max_pin='x.x.x') }}

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- make # [not win]
- cmake

test:
commands:
- test -f ${PREFIX}/include/qdldl/qdldl.h # [not win]
- test -f ${PREFIX}/lib/libqdldl.so # [linux]
- test -f ${PREFIX}/lib/libqdldl.dylib # [osx]
- test -f ${PREFIX}/lib/cmake/qdldl/qdldl-config.cmake # [not win]
- if not exist %PREFIX%\\Library\\include\\qdldl\\qdldl.h exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\qdldl.lib exit 1 # [win]
- if not exist %PREFIX%\\Library\\bin\\qdldl.dll exit 1 # [win]
- if not exist %PREFIX%\\Library\\lib\\cmake\\qdldl\\qdldl-config.cmake exit 1 # [win]

about:
home: https://github.com/osqp/qdldl
license: Apache-2.0
license_file: LICENSE
summary: A free LDL factorisation routine.

extra:
recipe-maintainers:
- traversaro
- h-vetinari