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

Add OpenBLAS/0.3.7 #705

Merged
merged 16 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions recipes/openblas/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
else()
include(conanbuildinfo.cmake)
endif()
conan_basic_setup()

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/openblas/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
0.3.7:
sha256: bde136122cef3dd6efe2de1c6f65c10955bbb0cc01a520c2342f5287c28f9379
url: https://github.com/xianyi/OpenBLAS/archive/v0.3.7.tar.gz
84 changes: 84 additions & 0 deletions recipes/openblas/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from conans import ConanFile, CMake, tools
import sys
import os


class OpenBLAS(ConanFile):
name = "openblas"
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.openblas.net"
description = "An optimized BLAS library based on GotoBLAS2 1.13 BSD version"
topics = (
"openblas",
"blas",
"lapack"
)
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_lapack": [True, False]
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
}
default_options = {
"shared": False,
"fPIC": True,
"build_lapack": False
}
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename('OpenBLAS-{}'.format(self.version), self._source_subfolder)

def _configure_cmake(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

if self.settings.compiler == "Visual Studio" and not self.options.shared:
cmake.definitions["MSVC_STATIC_CRT"] = True

if self.settings.os == "Linux":
# This is a workaround to add the libm dependency on linux,
# 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.build()

def package(self):
self.copy(
pattern="LICENSE",
dst="licenses",
src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
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)
bmanga marked this conversation as resolved.
Show resolved Hide resolved
if self.settings.os == "Linux":
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"
self.cpp_info.names["cmake_find_package_multi"] = "OpenBLAS"
self.cpp_info.names['pkg_config'] = "OpenBLAS"
10 changes: 10 additions & 0 deletions recipes/openblas/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/openblas/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
15 changes: 15 additions & 0 deletions recipes/openblas/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <openblas/cblas.h>
#include <stdio.h>

int main()
{
int i=0;
double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);

for(i=0; i<9; i++)
printf("%lf ", C[i]);
printf("\n");
}
3 changes: 3 additions & 0 deletions recipes/openblas/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.3.7":
folder: all