From ff1309b94958ff22d90c84e41b6a6cefb035717e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 6 Dec 2023 20:54:04 +0200 Subject: [PATCH 01/14] sundials: add v6.6.2, v5.8.0 --- recipes/sundials/all/conandata.yml | 6 ++++ recipes/sundials/all/conanfile.py | 29 +++---------------- .../sundials/all/test_package/CMakeLists.txt | 6 +++- .../{test_package.c => test_package_v5.c} | 2 +- .../all/test_package/test_package_v6.c | 18 ++++++++++++ recipes/sundials/config.yml | 4 +++ 6 files changed, 38 insertions(+), 27 deletions(-) rename recipes/sundials/all/test_package/{test_package.c => test_package_v5.c} (91%) create mode 100644 recipes/sundials/all/test_package/test_package_v6.c diff --git a/recipes/sundials/all/conandata.yml b/recipes/sundials/all/conandata.yml index d7e3f7fdd5714..a1aa9364fdf1f 100644 --- a/recipes/sundials/all/conandata.yml +++ b/recipes/sundials/all/conandata.yml @@ -1,4 +1,10 @@ sources: + "6.6.2": + url: "https://github.com/LLNL/sundials/releases/download/v6.6.2/sundials-6.6.2.tar.gz" + sha256: "08f8223a5561327e44c072e46faa7f665c0c0bc8cd7e45d23f486c3d24c65009" + "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" diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index c431e2317a534..56b21f57ad04c 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -103,40 +103,19 @@ def package_info(self): 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"] + + if self.settings.os in ["Linux", "FreeBSD"]: + for _, component in self.cpp_info.components.items(): + component.system_libs.append("m") diff --git a/recipes/sundials/all/test_package/CMakeLists.txt b/recipes/sundials/all/test_package/CMakeLists.txt index cf2fd2bc5a19e..f8551cfcb676c 100644 --- a/recipes/sundials/all/test_package/CMakeLists.txt +++ b/recipes/sundials/all/test_package/CMakeLists.txt @@ -3,5 +3,9 @@ project(test_package LANGUAGES C) find_package(sundials REQUIRED CONFIG) -add_executable(${PROJECT_NAME} test_package.c) +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) diff --git a/recipes/sundials/all/test_package/test_package.c b/recipes/sundials/all/test_package/test_package_v5.c similarity index 91% rename from recipes/sundials/all/test_package/test_package.c rename to recipes/sundials/all/test_package/test_package_v5.c index c0379d1c10628..b333950b72e0d 100644 --- a/recipes/sundials/all/test_package/test_package.c +++ b/recipes/sundials/all/test_package/test_package_v5.c @@ -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; } diff --git a/recipes/sundials/all/test_package/test_package_v6.c b/recipes/sundials/all/test_package/test_package_v6.c new file mode 100644 index 0000000000000..d2640e2713572 --- /dev/null +++ b/recipes/sundials/all/test_package/test_package_v6.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include + +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; +} diff --git a/recipes/sundials/config.yml b/recipes/sundials/config.yml index a42ad917d8584..969d01913ad7f 100644 --- a/recipes/sundials/config.yml +++ b/recipes/sundials/config.yml @@ -1,4 +1,8 @@ versions: + "6.6.2": + folder: all + "5.8.0": + folder: all "5.4.0": folder: all "5.3.0": From 48f7e3731d0cab417c4066d1e0443aa59d4c8b8b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 6 Dec 2023 21:01:25 +0200 Subject: [PATCH 02/14] sundials: add new lib, rmdir lib/cmake --- recipes/sundials/all/conanfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 56b21f57ad04c..f7e2c83f7e1ff 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import copy, get, mkdir +from conan.tools.files import copy, get, mkdir, rmdir +from conan.tools.scm import Version import glob import os import shutil @@ -85,6 +86,7 @@ def package(self): 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")) def package_info(self): self.cpp_info.components["sundials_nvecmanyvector"].libs = ["sundials_nvecmanyvector"] @@ -103,6 +105,8 @@ def package_info(self): 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 Version(self.version) >= "5.8.0": + self.cpp_info.components["sundials_generic"].libs = ["sundials_generic"] if self.options.build_arkode: self.cpp_info.components["sundials_arkode"].libs = ["sundials_arkode"] if self.options.build_cvode: From c46c1054830d9979b3ebb7a34fa749f5418b603f Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 21 Dec 2023 22:38:10 +0200 Subject: [PATCH 03/14] sundials: bump to v6.7.0 --- recipes/sundials/all/conandata.yml | 6 +++--- recipes/sundials/config.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/sundials/all/conandata.yml b/recipes/sundials/all/conandata.yml index a1aa9364fdf1f..5d9c8a06c19cc 100644 --- a/recipes/sundials/all/conandata.yml +++ b/recipes/sundials/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "6.6.2": - url: "https://github.com/LLNL/sundials/releases/download/v6.6.2/sundials-6.6.2.tar.gz" - sha256: "08f8223a5561327e44c072e46faa7f665c0c0bc8cd7e45d23f486c3d24c65009" + "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" diff --git a/recipes/sundials/config.yml b/recipes/sundials/config.yml index 969d01913ad7f..7d3b00211c0a1 100644 --- a/recipes/sundials/config.yml +++ b/recipes/sundials/config.yml @@ -1,5 +1,5 @@ versions: - "6.6.2": + "6.7.0": folder: all "5.8.0": folder: all From fe66f128588ec4b75d58bad6e36b1ff805827811 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 7 Jan 2024 11:31:09 +0200 Subject: [PATCH 04/14] sundials: fix_apple_shared_install_name() --- recipes/sundials/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index f7e2c83f7e1ff..5dc39bc9b6fe8 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -1,4 +1,5 @@ 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, rmdir from conan.tools.scm import Version @@ -87,6 +88,7 @@ def package(self): 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"] From bae21db86bd0bd37673824dae9e49ca5032ba312 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 31 Jul 2024 11:55:27 +0300 Subject: [PATCH 05/14] sundials: set CMP0077 for older versions --- recipes/sundials/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 5dc39bc9b6fe8..89de0501a6eeb 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -72,6 +72,8 @@ def generate(self): 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() def build(self): From 0b0047c746e12856e3061b44d3e3efd2a1f89b98 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 31 Jul 2024 11:57:20 +0300 Subject: [PATCH 06/14] sundials: add a comment for the v5 v6 test split --- recipes/sundials/all/test_package/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/sundials/all/test_package/CMakeLists.txt b/recipes/sundials/all/test_package/CMakeLists.txt index f8551cfcb676c..899d0326c36f1 100644 --- a/recipes/sundials/all/test_package/CMakeLists.txt +++ b/recipes/sundials/all/test_package/CMakeLists.txt @@ -3,6 +3,8 @@ project(test_package LANGUAGES C) find_package(sundials REQUIRED CONFIG) +# 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() From 07ba8e55da8e4e0f7b6581e5310cf41b8b985265 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 31 Jul 2024 13:42:52 +0300 Subject: [PATCH 07/14] sundials: add v7.1.1 --- recipes/sundials/all/conandata.yml | 3 +++ recipes/sundials/all/conanfile.py | 34 ++++++++++++++++++++++++++++-- recipes/sundials/config.yml | 2 ++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/recipes/sundials/all/conandata.yml b/recipes/sundials/all/conandata.yml index 5d9c8a06c19cc..8de8663cf93f9 100644 --- a/recipes/sundials/all/conandata.yml +++ b/recipes/sundials/all/conandata.yml @@ -1,4 +1,7 @@ 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" diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 89de0501a6eeb..13c258a7efd5a 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -1,6 +1,7 @@ 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.env import VirtualBuildEnv from conan.tools.files import copy, get, mkdir, rmdir from conan.tools.scm import Version import glob @@ -58,6 +59,25 @@ def configure(self): 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) @@ -75,6 +95,7 @@ def generate(self): 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) @@ -109,8 +130,6 @@ def package_info(self): 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 Version(self.version) >= "5.8.0": - self.cpp_info.components["sundials_generic"].libs = ["sundials_generic"] if self.options.build_arkode: self.cpp_info.components["sundials_arkode"].libs = ["sundials_arkode"] if self.options.build_cvode: @@ -124,6 +143,17 @@ def package_info(self): if self.options.build_kinsol: self.cpp_info.components["sundials_kinsol"].libs = ["sundials_kinsol"] + 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(): + 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") diff --git a/recipes/sundials/config.yml b/recipes/sundials/config.yml index 7d3b00211c0a1..6571ca3ade556 100644 --- a/recipes/sundials/config.yml +++ b/recipes/sundials/config.yml @@ -1,4 +1,6 @@ versions: + "7.1.1": + folder: all "6.7.0": folder: all "5.8.0": From a753224306a0801703561b15e9e07746dc0c541d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 7 Aug 2024 21:00:18 +0300 Subject: [PATCH 08/14] sundials: add lib suffix on v7 on Windows --- recipes/sundials/all/conanfile.py | 49 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 13c258a7efd5a..144d377a9788f 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -114,34 +114,37 @@ def package(self): fix_apple_shared_install_name(self) def package_info(self): - self.cpp_info.components["sundials_nvecmanyvector"].libs = ["sundials_nvecmanyvector"] - self.cpp_info.components["sundials_nvecserial"].libs = ["sundials_nvecserial"] - self.cpp_info.components["sundials_sunlinsolband"].libs = ["sundials_sunlinsolband"] - self.cpp_info.components["sundials_sunlinsolband"].requires = ["sundials_sunmatrixband"] - self.cpp_info.components["sundials_sunlinsoldense"].libs = ["sundials_sunlinsoldense"] - self.cpp_info.components["sundials_sunlinsoldense"].requires = ["sundials_sunmatrixdense"] - self.cpp_info.components["sundials_sunlinsolpcg"].libs = ["sundials_sunlinsolpcg"] - self.cpp_info.components["sundials_sunlinsolspbcgs"].libs = ["sundials_sunlinsolspbcgs"] - self.cpp_info.components["sundials_sunlinsolspfgmr"].libs = ["sundials_sunlinsolspfgmr"] - self.cpp_info.components["sundials_sunlinsolspgmr"].libs = ["sundials_sunlinsolspgmr"] - self.cpp_info.components["sundials_sunlinsolsptfqmr"].libs = ["sundials_sunlinsolsptfqmr"] - self.cpp_info.components["sundials_sunmatrixband"].libs = ["sundials_sunmatrixband"] - self.cpp_info.components["sundials_sunmatrixdense"].libs = ["sundials_sunmatrixdense"] - 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"] + suffix = "" + if Version(self.version) >= "7.0" and self.settings.os == "Windows": + suffix = "_shared" if self.options.shared else "_static" + self.cpp_info.components["sundials_nvecmanyvector"].libs = ["sundials_nvecmanyvector" + suffix] + self.cpp_info.components["sundials_nvecserial"].libs = ["sundials_nvecserial" + suffix] + self.cpp_info.components["sundials_sunlinsolband"].libs = ["sundials_sunlinsolband" + suffix] + self.cpp_info.components["sundials_sunlinsolband"].requires = ["sundials_sunmatrixband" + suffix] + self.cpp_info.components["sundials_sunlinsoldense"].libs = ["sundials_sunlinsoldense" + suffix] + self.cpp_info.components["sundials_sunlinsoldense"].requires = ["sundials_sunmatrixdense" + suffix] + self.cpp_info.components["sundials_sunlinsolpcg"].libs = ["sundials_sunlinsolpcg" + suffix] + self.cpp_info.components["sundials_sunlinsolspbcgs"].libs = ["sundials_sunlinsolspbcgs" + suffix] + self.cpp_info.components["sundials_sunlinsolspfgmr"].libs = ["sundials_sunlinsolspfgmr" + suffix] + self.cpp_info.components["sundials_sunlinsolspgmr"].libs = ["sundials_sunlinsolspgmr" + suffix] + self.cpp_info.components["sundials_sunlinsolsptfqmr"].libs = ["sundials_sunlinsolsptfqmr" + suffix] + self.cpp_info.components["sundials_sunmatrixband"].libs = ["sundials_sunmatrixband" + suffix] + self.cpp_info.components["sundials_sunmatrixdense"].libs = ["sundials_sunmatrixdense" + suffix] + self.cpp_info.components["sundials_sunmatrixsparse"].libs = ["sundials_sunmatrixsparse" + suffix] + self.cpp_info.components["sundials_sunnonlinsolfixedpoint"].libs = ["sundials_sunnonlinsolfixedpoint" + suffix] + self.cpp_info.components["sundials_sunnonlinsolnewton"].libs = ["sundials_sunnonlinsolnewton" + suffix] if self.options.build_arkode: - self.cpp_info.components["sundials_arkode"].libs = ["sundials_arkode"] + self.cpp_info.components["sundials_arkode"].libs = ["sundials_arkode" + suffix] if self.options.build_cvode: - self.cpp_info.components["sundials_cvode"].libs = ["sundials_cvode"] + self.cpp_info.components["sundials_cvode"].libs = ["sundials_cvode" + suffix] if self.options.build_cvodes: - self.cpp_info.components["sundials_cvodes"].libs = ["sundials_cvodes"] + self.cpp_info.components["sundials_cvodes"].libs = ["sundials_cvodes" + suffix] if self.options.build_ida: - self.cpp_info.components["sundials_ida"].libs = ["sundials_ida"] + self.cpp_info.components["sundials_ida"].libs = ["sundials_ida" + suffix] if self.options.build_idas: - self.cpp_info.components["sundials_idas"].libs = ["sundials_idas"] + self.cpp_info.components["sundials_idas"].libs = ["sundials_idas" + suffix] if self.options.build_kinsol: - self.cpp_info.components["sundials_kinsol"].libs = ["sundials_kinsol"] + self.cpp_info.components["sundials_kinsol"].libs = ["sundials_kinsol" + suffix] core_lib = None if Version(self.version) >= "7.0": @@ -152,7 +155,7 @@ def package_info(self): if core_lib: for name, component in self.cpp_info.components.items(): component.requires.append(core_lib) - self.cpp_info.components[core_lib].libs = [core_lib] + self.cpp_info.components[core_lib].libs = [core_lib + suffix] if self.settings.os in ["Linux", "FreeBSD"]: for _, component in self.cpp_info.components.items(): From 7059af49b43ae0d869859c7d359b34b9a09b5995 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 11 Sep 2024 15:37:12 +0300 Subject: [PATCH 09/14] sundials: add optional deps, improve components --- recipes/sundials/all/conan-cuda-support.cmake | 9 + recipes/sundials/all/conanfile.py | 292 ++++++++++++++---- .../sundials/all/test_package/CMakeLists.txt | 6 +- .../all/test_package/test_package_v6.c | 2 +- 4 files changed, 241 insertions(+), 68 deletions(-) create mode 100644 recipes/sundials/all/conan-cuda-support.cmake diff --git a/recipes/sundials/all/conan-cuda-support.cmake b/recipes/sundials/all/conan-cuda-support.cmake new file mode 100644 index 0000000000000..7af30312d86a9 --- /dev/null +++ b/recipes/sundials/all/conan-cuda-support.cmake @@ -0,0 +1,9 @@ +find_dependency(CUDAToolkit REQUIRED) + +target_link_libraries(SUNDIALS::nveccuda INTERFACE CUDA::cudart) +if(TARGET SUNDIALS::sunmatrixcusparse) + target_link_libraries(SUNDIALS::sunmatrixcusparse INTERFACE CUDA::cusparse) +endif() +if(TARGET SUNDIALS::sunlinsolcusolversp) + target_link_libraries(SUNDIALS::sunlinsolcusolversp INTERFACE CUDA::cusolver) +endif() diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 144d377a9788f..be987b91a8d2a 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -1,12 +1,15 @@ +import glob +import os +import shutil + 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.build import stdcpp_library +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, get, mkdir, rmdir +from conan.tools.files import copy, get, mkdir, rmdir, replace_in_file, save from conan.tools.scm import Version -import glob -import os -import shutil +from conans.errors import ConanInvalidConfiguration required_conan_version = ">=1.53.0" @@ -14,11 +17,9 @@ class SundialsConan(ConanFile): name = "sundials" license = "BSD-3-Clause" - description = ("SUNDIALS is a family of software packages implemented" - " with the goal of providing robust time integrators " - "and nonlinear solvers that can easily be incorporated" - "into existing simulation codes.") - topics = ("integrators", "ode", "non-linear solvers") + description = ("SUNDIALS is a family of software packages implemented with the goal of providing robust time integrators" + " and nonlinear solvers that can easily be incorporated into existing simulation codes.") + topics = ("integrators", "ode", "non-linear-solvers") homepage = "https://github.com/LLNL/sundials" url = "https://github.com/conan-io/conan-center-index" package_type = "library" @@ -32,6 +33,14 @@ class SundialsConan(ConanFile): "build_ida": [True, False], "build_idas": [True, False], "build_kinsol": [True, False], + "with_cuda": [True, False], + "with_ginkgo": [True, False], + "with_klu": [True, False], + "with_lapack": [True, False], + "with_mpi": [True, False], + "with_openmp": [True, False], + "index_size": [32, 64], + "precision": ["single", "double", "extended"], } default_options = { "shared": False, @@ -42,10 +51,21 @@ class SundialsConan(ConanFile): "build_ida": True, "build_idas": True, "build_kinsol": True, + "with_cuda": False, + "with_ginkgo": False, + "with_klu": False, + "with_lapack": True, + "with_mpi": False, + "with_openmp": False, + "index_size": 64, + "precision": "double", } short_paths = True + def export_sources(self): + copy(self, "*.cmake", self.recipe_folder, self.export_sources_folder) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -53,26 +73,58 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - self.settings.rm_safe("compiler.cppstd") - self.settings.rm_safe("compiler.libcxx") + if Version(self.version) < "5.5.0": + del self.options.with_cuda + del self.options.with_ginkgo + del self.options.with_klu + del self.options.with_lapack + del self.options.with_mpi + del self.options.with_openmp + elif Version(self.version) < "6.0": + del self.options.with_ginkgo + if not self.options.get_safe("with_cuda"): + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + if self.options.get_safe("with_mpi"): + self.options["openmpi"].enable_cxx = True + + def package_id(self): + # Ginkgo is only used in an INTERFACE component + self.info.options.rm_safe("with_ginkgo") 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 + # Used in public headers: + # - caliper: sundials/sundials_profiler.h + # - cuda: sunmemory/sunmemory_cuda.h, nvector/nvector_cuda.h + # - ginkgo: sunmatrix/sunmatrix_ginkgo.hpp, sunlinsol/sunlinsol_ginkgo.hpp + # - klu: sunlinsol/sunlinsol_klu.h + # - mpi: sundials/sundials_types.h, sundials/priv/sundials_mpi_errors_impl.h + if self.options.get_safe("with_ginkgo"): + self.requires("ginkgo/1.8.0", transitive_headers=True, transitive_libs=True) + if self.options.get_safe("with_klu"): + self.requires("suitesparse-klu/2.3.4", transitive_headers=True, transitive_libs=True) + if self.options.get_safe("with_lapack"): + self.requires("openblas/0.3.27") + if self.options.get_safe("with_mpi"): + self.requires("openmpi/4.1.6", transitive_headers=True, transitive_libs=True) + if self.options.get_safe("with_openmp"): + self.requires("openmp/system") + + def validate(self): + if self.options.get_safe("with_klu") and self.options.precision != "double": + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/tpl/SundialsKLU.cmake#L40 + raise ConanInvalidConfiguration("-o sundials/*:with_klu=True is only compatible with -o sundials/*:precision=double") + if self.options.precision == "extended": + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/tpl/SundialsGinkgo.cmake#L57 + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/tpl/SundialsLapack.cmake#L40 + for opt in ["with_cuda", "with_ginkgo", "with_lapack"]: + if self.options.get_safe(opt): + raise ConanInvalidConfiguration(f"-o sundials/*:{opt}=True is not compatible with -o sundials/*:precision=extended") + if self.options.get_safe("with_mpi") and not self.dependencies["openmpi"].options.get_safe("enable_cxx"): + raise ConanInvalidConfiguration("-o openmpi/*:enable_cxx=True is required for -o sundials/*:with_mpi=True") def build_requirements(self): if Version(self.version) >= "7.0": @@ -81,23 +133,87 @@ def build_requirements(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + @property + def _ginkgo_backends(self): + if not self.options.get_safe("with_ginkgo"): + return [] + backends = ["REF"] + if self.dependencies["ginkgo"].options.cuda: + backends.append("CUDA") + if self.dependencies["ginkgo"].options.openmp: + backends.append("OMP") + return backends + def generate(self): + VirtualBuildEnv(self).generate() + tc = CMakeToolchain(self) + tc.variables["EXAMPLES_ENABLE_C"] = False + tc.variables["EXAMPLES_ENABLE_CXX"] = False + tc.variables["EXAMPLES_INSTALL"] = False + tc.variables["BUILD_BENCHMARKS"] = False + tc.variables["SUNDIALS_TEST_UNITTESTS"] = False + if Version(self.version) <= "5.4.0": + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type) + + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SundialsBuildOptionsPre.cmake tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared + tc.variables["SUNDIALS_INDEX_SIZE"] = self.options.index_size + tc.variables["SUNDIALS_PRECISION"] = str(self.options.precision).upper() tc.variables["BUILD_ARKODE"] = self.options.build_arkode tc.variables["BUILD_CVODE"] = self.options.build_cvode tc.variables["BUILD_CVODES"] = self.options.build_cvodes tc.variables["BUILD_IDA"] = self.options.build_ida tc.variables["BUILD_IDAS"] = self.options.build_idas 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" + + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SundialsTPLOptions.cmake + tc.variables["ENABLE_MPI"] = self.options.get_safe("with_mpi", False) + tc.variables["ENABLE_OPENMP"] = self.options.get_safe("with_openmp", False) + tc.variables["ENABLE_CUDA"] = self.options.get_safe("with_cuda", False) + tc.variables["ENABLE_HIP"] = False + tc.variables["ENABLE_SYCL"] = False + tc.variables["ENABLE_LAPACK"] = self.options.get_safe("with_lapack", False) + tc.variables["ENABLE_GINKGO"] = self.options.get_safe("with_ginkgo", False) + tc.variables["SUNDIALS_GINKGO_BACKENDS"] = ";".join(self._ginkgo_backends) + tc.variables["GINKGO_WORKS"] = True + tc.variables["ENABLE_MAGMA"] = False + tc.variables["ENABLE_SUPERLUDIST"] = False + tc.variables["ENABLE_SUPERLUMT"] = False + tc.variables["ENABLE_KLU"] = self.options.get_safe("with_klu", False) + tc.variables["KLU_WORKS"] = True + tc.variables["ENABLE_HYPRE"] = False + tc.variables["ENABLE_PETSC"] = False + tc.variables["ENABLE_RAJA"] = False + tc.variables["ENABLE_TRILINOS"] = False + tc.variables["ENABLE_XBRAID"] = False + tc.variables["ENABLE_ONEMKL"] = False + tc.variables["ENABLE_CALIPER"] = False + tc.variables["ENABLE_ADIAK"] = False + tc.variables["ENABLE_KOKKOS"] = False + + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SundialsBuildOptionsPost.cmake + tc.variables["BUILD_SUNMATRIX_CUSPARSE"] = self.options.get_safe("with_cuda", False) and self.options.index_size == 32 + tc.variables["BUILD_SUNLINSOL_CUSOLVERSP"] = self.options.get_safe("with_cuda", False) and self.options.index_size == 32 + tc.generate() - VirtualBuildEnv(self).generate() + + deps = CMakeDeps(self) + deps.set_property("suitesparse-klu", "cmake_target_name", "SUNDIALS::KLU") + deps.generate() + + def _patch_sources(self): + save(self, os.path.join(self.source_folder, "examples", "CMakeLists.txt"), "") + if self.options.get_safe("with_ginkgo"): + replace_in_file(self, os.path.join(self.source_folder, "cmake", "tpl", "SundialsGinkgo.cmake"), + "NO_DEFAULT_PATH", "") + if self.options.get_safe("with_mpi"): + replace_in_file(self, os.path.join(self.source_folder, "cmake", "tpl", "SundialsMPI.cmake"), + "find_package(MPI 2.0.0 REQUIRED)", "find_package(MPI REQUIRED)") def build(self): + self._patch_sources() cmake = CMake(self) cmake.configure() cmake.build() @@ -112,51 +228,99 @@ def package(self): 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) + if self.options.get_safe("with_cuda"): + copy(self, "conan-cuda-support.cmake", self.export_sources_folder, os.path.join(self.package_folder, "lib", "cmake", "sundials")) def package_info(self): + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SUNDIALSConfig.cmake.in + self.cpp_info.set_property("cmake_file_name", "SUNDIALS") + suffix = "" if Version(self.version) >= "7.0" and self.settings.os == "Windows": suffix = "_shared" if self.options.shared else "_static" - self.cpp_info.components["sundials_nvecmanyvector"].libs = ["sundials_nvecmanyvector" + suffix] - self.cpp_info.components["sundials_nvecserial"].libs = ["sundials_nvecserial" + suffix] - self.cpp_info.components["sundials_sunlinsolband"].libs = ["sundials_sunlinsolband" + suffix] - self.cpp_info.components["sundials_sunlinsolband"].requires = ["sundials_sunmatrixband" + suffix] - self.cpp_info.components["sundials_sunlinsoldense"].libs = ["sundials_sunlinsoldense" + suffix] - self.cpp_info.components["sundials_sunlinsoldense"].requires = ["sundials_sunmatrixdense" + suffix] - self.cpp_info.components["sundials_sunlinsolpcg"].libs = ["sundials_sunlinsolpcg" + suffix] - self.cpp_info.components["sundials_sunlinsolspbcgs"].libs = ["sundials_sunlinsolspbcgs" + suffix] - self.cpp_info.components["sundials_sunlinsolspfgmr"].libs = ["sundials_sunlinsolspfgmr" + suffix] - self.cpp_info.components["sundials_sunlinsolspgmr"].libs = ["sundials_sunlinsolspgmr" + suffix] - self.cpp_info.components["sundials_sunlinsolsptfqmr"].libs = ["sundials_sunlinsolsptfqmr" + suffix] - self.cpp_info.components["sundials_sunmatrixband"].libs = ["sundials_sunmatrixband" + suffix] - self.cpp_info.components["sundials_sunmatrixdense"].libs = ["sundials_sunmatrixdense" + suffix] - self.cpp_info.components["sundials_sunmatrixsparse"].libs = ["sundials_sunmatrixsparse" + suffix] - self.cpp_info.components["sundials_sunnonlinsolfixedpoint"].libs = ["sundials_sunnonlinsolfixedpoint" + suffix] - self.cpp_info.components["sundials_sunnonlinsolnewton"].libs = ["sundials_sunnonlinsolnewton" + suffix] + + core_lib = None + if Version(self.version) >= "7.0": + core_lib = "core" + elif Version(self.version) >= "5.8.0": + core_lib = "generic" + + def _add_lib(name, requires=None, system_libs=None, interface=False): + component = self.cpp_info.components[name] + component.set_property("cmake_target_name", f"SUNDIALS::{name}") + component.set_property("cmake_target_aliases", [f"SUNDIALS::{name}_{'shared' if self.options.shared else 'static'}"]) + if not interface: + component.libs = [f"sundials_{name}{suffix}"] + component.requires = requires or [] + component.system_libs = system_libs or [] + if core_lib and name != core_lib: + component.requires.append(core_lib) + if self.settings.os in ["Linux", "FreeBSD"]: + component.system_libs.append("m") + + if core_lib: + _add_lib(core_lib) + if self.options.get_safe("with_mpi"): + self.cpp_info.components[core_lib].requires.append("openmpi::openmpi") + if self.options.build_arkode: - self.cpp_info.components["sundials_arkode"].libs = ["sundials_arkode" + suffix] + _add_lib("arkode") if self.options.build_cvode: - self.cpp_info.components["sundials_cvode"].libs = ["sundials_cvode" + suffix] + _add_lib("cvode") if self.options.build_cvodes: - self.cpp_info.components["sundials_cvodes"].libs = ["sundials_cvodes" + suffix] + _add_lib("cvodes") if self.options.build_ida: - self.cpp_info.components["sundials_ida"].libs = ["sundials_ida" + suffix] + _add_lib("ida") if self.options.build_idas: - self.cpp_info.components["sundials_idas"].libs = ["sundials_idas" + suffix] + _add_lib("idas") if self.options.build_kinsol: - self.cpp_info.components["sundials_kinsol"].libs = ["sundials_kinsol" + suffix] + _add_lib("kinsol") - core_lib = None - if Version(self.version) >= "7.0": - core_lib = "sundials_core" - elif Version(self.version) >= "5.8.0": - core_lib = "sundials_generic" + _add_lib("nvecserial") + if self.options.get_safe("with_mpi"): + _add_lib("nvecmanyvector", requires=["openmpi::openmpi"]) + if self.options.get_safe("with_openmp"): + _add_lib("nvecopenmp", requires=["openmp::openmp"]) - if core_lib: - for name, component in self.cpp_info.components.items(): - component.requires.append(core_lib) - self.cpp_info.components[core_lib].libs = [core_lib + suffix] + _add_lib("sunmatrixband") + _add_lib("sunmatrixdense") + _add_lib("sunmatrixsparse") + if self.options.get_safe("with_ginkgo"): + _add_lib("sunmatrixginkgo", interface=True, requires=["ginkgo::ginkgo"]) - if self.settings.os in ["Linux", "FreeBSD"]: - for _, component in self.cpp_info.components.items(): - component.system_libs.append("m") + _add_lib("sunlinsolband", requires=["sunmatrixband"]) + _add_lib("sunlinsoldense", requires=["sunmatrixdense"]) + _add_lib("sunlinsolpcg") + _add_lib("sunlinsolspbcgs") + _add_lib("sunlinsolspfgmr") + _add_lib("sunlinsolspgmr") + _add_lib("sunlinsolsptfqmr") + if self.options.get_safe("with_ginkgo"): + _add_lib("sunmatrixginkgo", interface=True, requires=["ginkgo::ginkgo"]) + _add_lib("sunlinsolginkgo", interface=True, requires=["ginkgo::ginkgo"]) + if self.options.get_safe("with_klu"): + _add_lib("sunlinsolklu", requires=["sunmatrixsparse", "suitesparse-klu::suitesparse-klu"]) + if self.options.get_safe("with_lapack"): + _add_lib("sunlinsollapackband", requires=["sunmatrixband", "openblas::openblas"]) + _add_lib("sunlinsollapackdense", requires=["sunmatrixdense", "openblas::openblas"]) + + _add_lib("sunnonlinsolfixedpoint") + _add_lib("sunnonlinsolnewton") + + if self.options.get_safe("with_cuda"): + system_libs = [] + if self.settings.os in ["Linux", "FreeBSD"]: + system_libs.extend(["rt", "pthread", "dl"]) + if stdcpp_library(self): + system_libs.append(stdcpp_library(self)) + + _add_lib("nveccuda", system_libs=system_libs) + if self.options.index_size == 32: + _add_lib("sunmatrixcusparse", system_libs=system_libs) # + cusparse + _add_lib("sunlinsolcusolversp", requires=["sunmatrixcusparse"], system_libs=system_libs) # + cusolver + + self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "sundials")) + cmake_module = os.path.join("lib", "cmake", "sundials", "conan-cuda-support.cmake") + self.cpp_info.set_property("cmake_build_modules", [cmake_module]) + self.cpp_info.build_modules["cmake_find_package"] = [cmake_module] + self.cpp_info.build_modules["cmake_find_package_multi"] = [cmake_module] diff --git a/recipes/sundials/all/test_package/CMakeLists.txt b/recipes/sundials/all/test_package/CMakeLists.txt index 899d0326c36f1..322515404851e 100644 --- a/recipes/sundials/all/test_package/CMakeLists.txt +++ b/recipes/sundials/all/test_package/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES C) -find_package(sundials REQUIRED CONFIG) +find_package(SUNDIALS REQUIRED CONFIG) # 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) +if(SUNDIALS_VERSION GREATER_EQUAL 6) add_executable(${PROJECT_NAME} test_package_v6.c) else() add_executable(${PROJECT_NAME} test_package_v5.c) diff --git a/recipes/sundials/all/test_package/test_package_v6.c b/recipes/sundials/all/test_package/test_package_v6.c index d2640e2713572..e3566a546dcd4 100644 --- a/recipes/sundials/all/test_package/test_package_v6.c +++ b/recipes/sundials/all/test_package/test_package_v6.c @@ -6,7 +6,7 @@ int main() { SUNContext sunctx; - SUNContext_Create(NULL, &sunctx); + SUNContext_Create(0, &sunctx); N_Vector y = N_VNew_Serial(1, sunctx); NV_DATA_S(y)[0] = 2.0; SUNMatrix A = SUNDenseMatrix(1, 1, sunctx); From c9beef8f9d9ff40b252a5d003ae944950d33e4ed Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 11 Sep 2024 15:51:44 +0300 Subject: [PATCH 10/14] sundials: restore old component names in < v5.8.0 --- recipes/sundials/all/conanfile.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index be987b91a8d2a..637097320b069 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -233,7 +233,8 @@ def package(self): def package_info(self): # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SUNDIALSConfig.cmake.in - self.cpp_info.set_property("cmake_file_name", "SUNDIALS") + if Version(self.version) >= "5.8.0": + self.cpp_info.set_property("cmake_file_name", "SUNDIALS") suffix = "" if Version(self.version) >= "7.0" and self.settings.os == "Windows": @@ -246,9 +247,14 @@ def package_info(self): core_lib = "generic" def _add_lib(name, requires=None, system_libs=None, interface=False): - component = self.cpp_info.components[name] - component.set_property("cmake_target_name", f"SUNDIALS::{name}") - component.set_property("cmake_target_aliases", [f"SUNDIALS::{name}_{'shared' if self.options.shared else 'static'}"]) + if Version(self.version) >= "5.8.0": + component = self.cpp_info.components[name] + component.set_property("cmake_target_name", f"SUNDIALS::{name}") + component.set_property("cmake_target_aliases", [f"SUNDIALS::{name}_{'shared' if self.options.shared else 'static'}"]) + else: + # For backward compatibility with old recipe versions + component = self.cpp_info.components[f"sundials_{name}"] + requires = [f"sundials_{r}" if "::" not in r else r for r in requires or []] if not interface: component.libs = [f"sundials_{name}{suffix}"] component.requires = requires or [] From cb213843360c46e1c61be780f2a78c2af8468233 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 11 Sep 2024 15:58:31 +0300 Subject: [PATCH 11/14] sundials: fix import --- recipes/sundials/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 637097320b069..488e66a498a7c 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -3,13 +3,13 @@ import shutil from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.apple import fix_apple_shared_install_name from conan.tools.build import stdcpp_library from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get, mkdir, rmdir, replace_in_file, save from conan.tools.scm import Version -from conans.errors import ConanInvalidConfiguration required_conan_version = ">=1.53.0" From 8aea036e3bc08a3a0aba2ee4faf965318c0a835b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 16 Sep 2024 16:47:09 +0300 Subject: [PATCH 12/14] sundials: avoid a Fortran compiler requirement --- recipes/sundials/all/conanfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 488e66a498a7c..2028582b89fd9 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -197,6 +197,12 @@ def generate(self): tc.variables["BUILD_SUNMATRIX_CUSPARSE"] = self.options.get_safe("with_cuda", False) and self.options.index_size == 32 tc.variables["BUILD_SUNLINSOL_CUSOLVERSP"] = self.options.get_safe("with_cuda", False) and self.options.index_size == 32 + # Configure default LAPACK naming conventions for OpenBLAS. + # Needed to avoid a Fortran compiler requirement to detect the correct name mangling scheme. + # https://github.com/LLNL/sundials/blob/v7.1.1/cmake/SundialsSetupCompilers.cmake#L269-L360 + tc.variables["SUNDIALS_LAPACK_CASE"] = "lower" + tc.variables["SUNDIALS_LAPACK_UNDERSCORES"] = "one" + tc.generate() deps = CMakeDeps(self) From 6dfb7bacf25670a81164405bb74c9b7249439ca4 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 16 Oct 2024 18:48:32 +0300 Subject: [PATCH 13/14] sunidals: fix cross-compilation --- recipes/sundials/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 2028582b89fd9..9b6d379c1c434 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -148,6 +148,7 @@ def generate(self): VirtualBuildEnv(self).generate() tc = CMakeToolchain(self) + tc.variables["CMAKE_Fortran_COMPILER"] = "" tc.variables["EXAMPLES_ENABLE_C"] = False tc.variables["EXAMPLES_ENABLE_CXX"] = False tc.variables["EXAMPLES_INSTALL"] = False @@ -175,6 +176,7 @@ def generate(self): tc.variables["ENABLE_HIP"] = False tc.variables["ENABLE_SYCL"] = False tc.variables["ENABLE_LAPACK"] = self.options.get_safe("with_lapack", False) + tc.variables["LAPACK_WORKS"] = True tc.variables["ENABLE_GINKGO"] = self.options.get_safe("with_ginkgo", False) tc.variables["SUNDIALS_GINKGO_BACKENDS"] = ";".join(self._ginkgo_backends) tc.variables["GINKGO_WORKS"] = True From 7514a1090f24cae593410fb08115372d6c6f6570 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 11 Nov 2024 18:37:36 +0200 Subject: [PATCH 14/14] Use openblas/0.3.28 for cross-compilation support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Version 0.3.27 fails to cross-compile with lapack-netlib/SRC/spstrf.c:830:43: error: passing argument 1 of ‘dmaxloc_’ from incompatible pointer type [-Wincompatible-pointer-types] --- recipes/sundials/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/sundials/all/conanfile.py b/recipes/sundials/all/conanfile.py index 9b6d379c1c434..2a17d36440096 100644 --- a/recipes/sundials/all/conanfile.py +++ b/recipes/sundials/all/conanfile.py @@ -107,7 +107,7 @@ def requirements(self): if self.options.get_safe("with_klu"): self.requires("suitesparse-klu/2.3.4", transitive_headers=True, transitive_libs=True) if self.options.get_safe("with_lapack"): - self.requires("openblas/0.3.27") + self.requires("openblas/0.3.28") if self.options.get_safe("with_mpi"): self.requires("openmpi/4.1.6", transitive_headers=True, transitive_libs=True) if self.options.get_safe("with_openmp"):