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

sundials: add v7.1.1, v6.7.0, v5.8.0, add optional deps, fix CMake names #21664

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
9 changes: 9 additions & 0 deletions recipes/sundials/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
sources:
"7.1.1":
url: "https://github.com/LLNL/sundials/releases/download/v7.1.1/sundials-7.1.1.tar.gz"
sha256: "ea7d6edfb52448ddfdc1ec48f89a721fe6c0a259c10f8ef56f60fcded87a94bb"
"6.7.0":
url: "https://github.com/LLNL/sundials/releases/download/v6.7.0/sundials-6.7.0.tar.gz"
sha256: "5f113a1564a9d2d98ff95249f4871a4c815a05dbb9b8866a82b13ab158c37adb"
"5.8.0":
url: "https://github.com/LLNL/sundials/releases/download/v5.8.0/sundials-5.8.0.tar.gz"
sha256: "d4ed403351f72434d347df592da6c91a69452071860525385b3339c824e8a213"
"5.4.0":
url: "https://github.com/LLNL/sundials/releases/download/v5.4.0/sundials-5.4.0.tar.gz"
sha256: "a60ba8155ca12261cf7623efcf9fd4232e95bcfefe480993ef71324176cb395b"
Expand Down
69 changes: 43 additions & 26 deletions recipes/sundials/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, mkdir
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, mkdir, rmdir
from conan.tools.scm import Version
import glob
import os
import shutil
Expand Down Expand Up @@ -56,6 +59,25 @@
def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
# https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SUNDIALSConfig.cmake.in
# TODO: add support for optional dependencies:
# - openmp #22360
# - openmpi #18980
# - suitesparse-klu #23547
# - cuda
# - adiak
# - caliper
# - ginkgo
# - kokkos
# - mkl
# - raja
pass

def build_requirements(self):
if Version(self.version) >= "7.0":
self.tool_requires("cmake/[>=3.18 <4]")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

Expand All @@ -70,7 +92,10 @@
tc.variables["BUILD_KINSOL"] = self.options.build_kinsol
tc.variables["EXAMPLES_ENABLE_C"] = False
tc.variables["EXAMPLES_INSTALL"] = False
if Version(self.version) <= "5.4.0":
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
VirtualBuildEnv(self).generate()

def build(self):
cmake = CMake(self)
Expand All @@ -85,6 +110,8 @@
mkdir(self, os.path.join(self.package_folder, "bin"))
for dll_path in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")):
shutil.move(dll_path, os.path.join(self.package_folder, "bin", os.path.basename(dll_path)))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.components["sundials_nvecmanyvector"].libs = ["sundials_nvecmanyvector"]
Expand All @@ -103,40 +130,30 @@
self.cpp_info.components["sundials_sunmatrixsparse"].libs = ["sundials_sunmatrixsparse"]
self.cpp_info.components["sundials_sunnonlinsolfixedpoint"].libs = ["sundials_sunnonlinsolfixedpoint"]
self.cpp_info.components["sundials_sunnonlinsolnewton"].libs = ["sundials_sunnonlinsolnewton"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_nvecmanyvector"].system_libs = ["m"]
self.cpp_info.components["sundials_nvecserial"].system_libs = ["m"]
self.cpp_info.components["sundials_sunlinsolpcg"].system_libs = ["m"]
self.cpp_info.components["sundials_sunlinsolspbcgs"].system_libs = ["m"]
self.cpp_info.components["sundials_sunlinsolspfgmr"].system_libs = ["m"]
self.cpp_info.components["sundials_sunlinsolspgmr"].system_libs = ["m"]
self.cpp_info.components["sundials_sunlinsolsptfqmr"].system_libs = ["m"]
self.cpp_info.components["sundials_sunmatrixband"].system_libs = ["m"]
self.cpp_info.components["sundials_sunmatrixdense"].system_libs = ["m"]
self.cpp_info.components["sundials_sunmatrixsparse"].system_libs = ["m"]
self.cpp_info.components["sundials_sunnonlinsolfixedpoint"].system_libs = ["m"]
self.cpp_info.components["sundials_sunnonlinsolnewton"].system_libs = ["m"]
if self.options.build_arkode:
self.cpp_info.components["sundials_arkode"].libs = ["sundials_arkode"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_arkode"].system_libs = ["m"]
if self.options.build_cvode:
self.cpp_info.components["sundials_cvode"].libs = ["sundials_cvode"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_cvode"].system_libs = ["m"]
if self.options.build_cvodes:
self.cpp_info.components["sundials_cvodes"].libs = ["sundials_cvodes"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_cvodes"].system_libs = ["m"]
if self.options.build_ida:
self.cpp_info.components["sundials_ida"].libs = ["sundials_ida"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_ida"].system_libs = ["m"]
if self.options.build_idas:
self.cpp_info.components["sundials_idas"].libs = ["sundials_idas"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_idas"].system_libs = ["m"]
if self.options.build_kinsol:
self.cpp_info.components["sundials_kinsol"].libs = ["sundials_kinsol"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["sundials_kinsol"].system_libs = ["m"]

core_lib = None
if Version(self.version) >= "7.0":
core_lib = "sundials_core"
elif Version(self.version) >= "5.8.0":
core_lib = "sundials_generic"

if core_lib:
for name, component in self.cpp_info.components.items():

Check warning on line 153 in recipes/sundials/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused variable 'name'
component.requires.append(core_lib)
self.cpp_info.components[core_lib].libs = [core_lib]

if self.settings.os in ["Linux", "FreeBSD"]:
for _, component in self.cpp_info.components.items():
component.system_libs.append("m")
8 changes: 7 additions & 1 deletion recipes/sundials/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ project(test_package LANGUAGES C)

find_package(sundials REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
# SUNDIALS v6.0.0 introduced a new SUNContext object on which all other SUNDIALS objects depend
# and is not backwards compatible.
if(sundials_VERSION GREATER_EQUAL 6)
add_executable(${PROJECT_NAME} test_package_v6.c)
else()
add_executable(${PROJECT_NAME} test_package_v5.c)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE sundials::sundials)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main()
SUNMatrix A = SUNDenseMatrix(1, 1);
SUNLinearSolver LS = SUNLinSol_Dense(y, A);

N_Vector v = N_VNew_Serial(1);;
N_Vector v = N_VNew_Serial(1);
N_VScale(2.0, y, v);
return 0;
}
18 changes: 18 additions & 0 deletions recipes/sundials/all/test_package/test_package_v6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <nvector/nvector_serial.h>
perseoGI marked this conversation as resolved.
Show resolved Hide resolved
#include <sunmatrix/sunmatrix_dense.h>
#include <sunlinsol/sunlinsol_dense.h>
#include <sundials/sundials_types.h>

int main()
{
SUNContext sunctx;
SUNContext_Create(NULL, &sunctx);
N_Vector y = N_VNew_Serial(1, sunctx);
NV_DATA_S(y)[0] = 2.0;
SUNMatrix A = SUNDenseMatrix(1, 1, sunctx);
SUNLinearSolver LS = SUNLinSol_Dense(y, A, sunctx);

N_Vector v = N_VNew_Serial(1, sunctx);
N_VScale(2.0, y, v);
return 0;
}
6 changes: 6 additions & 0 deletions recipes/sundials/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
versions:
"7.1.1":
folder: all
"6.7.0":
folder: all
"5.8.0":
folder: all
"5.4.0":
folder: all
"5.3.0":
Expand Down
Loading