Skip to content

Commit

Permalink
(conan-io#19808) openblas: add version 0.3.24
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Samuel Dowling <[email protected]>
  • Loading branch information
joakimono and samuel-emrys authored Nov 2, 2023
1 parent 8e994a3 commit 3d67c12
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
3 changes: 3 additions & 0 deletions recipes/openblas/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
60 changes: 41 additions & 19 deletions recipes/openblas/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -75,19 +83,28 @@ 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

# 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.
Expand All @@ -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)
Expand All @@ -113,18 +131,20 @@ 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()

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)
Expand All @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions recipes/openblas/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.3.24":
folder: all
"0.3.20":
folder: all
"0.3.17":
Expand Down

0 comments on commit 3d67c12

Please sign in to comment.