Skip to content

Commit

Permalink
Merge pull request #855 from pleroux0/master
Browse files Browse the repository at this point in the history
[openblas] Expose additional options
  • Loading branch information
danimtb authored Mar 2, 2020
2 parents fbcaedb + c905fd8 commit 536cbe6
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions recipes/openblas/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ class OpenBLAS(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_lapack": [True, False]
"build_lapack": [True, False],
"use_thread": [True, False],
"dynamic_arch": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_lapack": False
"build_lapack": False,
"use_thread": True,
"dynamic_arch": False
}
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
Expand All @@ -38,14 +42,20 @@ def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename('OpenBLAS-{}'.format(self.version), self._source_subfolder)

def _configure_cmake(self):
def _create_cmake_helper(self):
cmake = CMake(self)
if self.options.build_lapack:
self.output.warn(
"Building with lapack support requires a Fortran compiler.")

cmake.definitions["NOFORTRAN"] = not self.options.build_lapack
cmake.definitions["BUILD_WITHOUT_LAPACK"] = not self.options.build_lapack
cmake.definitions["DYNAMIC_ARCH"] = self.options.dynamic_arch
cmake.definitions["USE_THREAD"] = self.options.use_thread

if not self.options.use_thread:
# Required for safe concurrent calls to OpenBLAS routines
cmake.definitions["USE_LOCKING"] = True

if self.settings.compiler == "Visual Studio" and not self.options.shared:
cmake.definitions["MSVC_STATIC_CRT"] = True
Expand All @@ -55,28 +65,30 @@ def _configure_cmake(self):
# which is required to successfully compile on older gcc versions.
cmake.definitions["ANDROID"] = True

cmake.configure(build_folder=self._build_subfolder)
return cmake

def build(self):
cmake = self._configure_cmake()
cmake = self._create_cmake_helper()
cmake.configure(build_folder=self._build_subfolder)
cmake.build()

def package(self):
self.copy(
pattern="LICENSE",
dst="licenses",
src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
cmake = self._create_cmake_helper()
cmake.install(build_dir=self._build_subfolder)
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
self.env_info.OpenBLAS_HOME = self.package_folder
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
if self.options.use_thread:
self.cpp_info.system_libs = ["pthread"]

if self.options.build_lapack:
self.cpp_info.system_libs.append("gfortran")
self.cpp_info.names["cmake_find_package"] = "OpenBLAS"
Expand Down

0 comments on commit 536cbe6

Please sign in to comment.