From 3d67c12514e145c53b67346f14a5e6a2f07ae422 Mon Sep 17 00:00:00 2001 From: Joakim Haugen Date: Thu, 2 Nov 2023 13:25:56 +0100 Subject: [PATCH] (#19808) openblas: add version 0.3.24 * openblas: add version 0.3.24 * Fix syntax error in recipe * Add missing entry in config.yml * Remove generated cmake files * Update minimum version for fortran-free compilation as suggested Co-authored-by: Samuel Dowling --------- Co-authored-by: Samuel Dowling --- recipes/openblas/all/conandata.yml | 3 ++ recipes/openblas/all/conanfile.py | 60 ++++++++++++++++++++---------- recipes/openblas/config.yml | 2 + 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/recipes/openblas/all/conandata.yml b/recipes/openblas/all/conandata.yml index 33390fd9116e6..31efef8e95737 100644 --- a/recipes/openblas/all/conandata.yml +++ b/recipes/openblas/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "0.3.24": + url: "https://github.com/xianyi/OpenBLAS/archive/v0.3.24.tar.gz" + sha256: "ceadc5065da97bd92404cac7254da66cc6eb192679cf1002098688978d4d5132" "0.3.20": url: "https://github.com/xianyi/OpenBLAS/archive/v0.3.20.tar.gz" sha256: "8495c9affc536253648e942908e88e097f2ec7753ede55aca52e5dead3029e3c" diff --git a/recipes/openblas/all/conanfile.py b/recipes/openblas/all/conanfile.py index d0b7d2c131bf8..d3f3b247af16a 100644 --- a/recipes/openblas/all/conanfile.py +++ b/recipes/openblas/all/conanfile.py @@ -34,6 +34,14 @@ class OpenblasConan(ConanFile): "dynamic_arch": False, } short_paths = True + package_type = "library" + + @property + def _fortran_compiler(self): + comp_exe = self.conf.get("tools.build:compiler_executables") + if comp_exe and 'fortran' in comp_exe: + return comp_exe["fortran"] + return None def config_options(self): if self.settings.os == "Windows": @@ -75,9 +83,19 @@ def layout(self): def generate(self): tc = CMakeToolchain(self) - if self.options.build_lapack: - self.output.warning("Building with lapack support requires a Fortran compiler.") tc.cache_variables["NOFORTRAN"] = not self.options.build_lapack + # This checks explicit user-specified fortran compiler + if self.options.build_lapack: + if not self._fortran_compiler: + if Version(self.version) < "0.3.24": + self.output.warning( + "Building with LAPACK support requires a Fortran compiler.") + else: + tc.cache_variables["C_LAPACK"] = True + tc.cache_variables["NOFORTRAN"] = True + self.output.info( + "Building LAPACK without Fortran compiler") + tc.cache_variables["BUILD_WITHOUT_LAPACK"] = not self.options.build_lapack tc.cache_variables["DYNAMIC_ARCH"] = self.options.dynamic_arch tc.cache_variables["USE_THREAD"] = self.options.use_thread @@ -85,9 +103,8 @@ def generate(self): # Required for safe concurrent calls to OpenBLAS routines tc.cache_variables["USE_LOCKING"] = not self.options.use_thread - tc.cache_variables[ - "MSVC_STATIC_CRT" - ] = False # don't, may lie to consumer, /MD or /MT is managed by conan + # don't, may lie to consumer, /MD or /MT is managed by conan + tc.cache_variables["MSVC_STATIC_CRT"] = False # This is a workaround to add the libm dependency on linux, # which is required to successfully compile on older gcc versions. @@ -96,14 +113,15 @@ def generate(self): tc.generate() def build(self): - if Version(self.version) >= "0.3.12": - search = """message(STATUS "No Fortran compiler found, can build only BLAS but not LAPACK")""" - replace = ( - """message(FATAL_ERROR "No Fortran compiler found. Cannot build with LAPACK.")""" - ) - else: - search = "enable_language(Fortran)" - replace = """include(CheckLanguage) + if Version(self.version) < "0.3.21": + if Version(self.version) >= "0.3.12": + search = """message(STATUS "No Fortran compiler found, can build only BLAS but not LAPACK")""" + replace = ( + """message(FATAL_ERROR "No Fortran compiler found. Cannot build with LAPACK.")""" + ) + else: + search = "enable_language(Fortran)" + replace = """include(CheckLanguage) check_language(Fortran) if(CMAKE_Fortran_COMPILER) enable_language(Fortran) @@ -113,11 +131,12 @@ def build(self): set (NO_LAPACK 1) endif()""" - replace_in_file(self, - os.path.join(self.source_folder, self.source_folder, "cmake", "f_check.cmake"), - search, - replace, - ) + replace_in_file( + self, + os.path.join(self.source_folder, self.source_folder, "cmake", "f_check.cmake"), + search, + replace, + ) cmake = self._configure_cmake() cmake.build() @@ -125,6 +144,7 @@ def package(self): copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = self._configure_cmake() cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rmdir(self, os.path.join(self.package_folder, "share")) fix_apple_shared_install_name(self) @@ -137,7 +157,9 @@ def package_info(self): self.cpp_info.set_property("cmake_file_name", "OpenBLAS") self.cpp_info.set_property("cmake_target_name", "OpenBLAS::OpenBLAS") self.cpp_info.set_property("pkg_config_name", "openblas") - cmake_component_name = "pthread" if self.options.use_thread else "serial" # TODO: ow to model this in CMakeDeps? + cmake_component_name = "pthread" if self.options.use_thread else "serial" # TODO: how to model this in CMakeDeps? + self.cpp_info.components["openblas_component"].set_property( + "cmake_target_name", "OpenBLAS::" + cmake_component_name) # 'pthread' causes issues without namespace self.cpp_info.components["openblas_component"].set_property("pkg_config_name", "openblas") self.cpp_info.components["openblas_component"].includedirs.append( os.path.join("include", "openblas") diff --git a/recipes/openblas/config.yml b/recipes/openblas/config.yml index 6d0851b7920c3..d12fbd6e7daea 100644 --- a/recipes/openblas/config.yml +++ b/recipes/openblas/config.yml @@ -1,4 +1,6 @@ versions: + "0.3.24": + folder: all "0.3.20": folder: all "0.3.17":