diff --git a/recipes/openblas/all/CMakeLists.txt b/recipes/openblas/all/CMakeLists.txt new file mode 100644 index 0000000000000..cdeeef45d13c1 --- /dev/null +++ b/recipes/openblas/all/CMakeLists.txt @@ -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") diff --git a/recipes/openblas/all/conandata.yml b/recipes/openblas/all/conandata.yml new file mode 100644 index 0000000000000..0dd590ea07db1 --- /dev/null +++ b/recipes/openblas/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + 0.3.7: + sha256: bde136122cef3dd6efe2de1c6f65c10955bbb0cc01a520c2342f5287c28f9379 + url: https://github.com/xianyi/OpenBLAS/archive/v0.3.7.tar.gz diff --git a/recipes/openblas/all/conanfile.py b/recipes/openblas/all/conanfile.py new file mode 100644 index 0000000000000..5e426733692a4 --- /dev/null +++ b/recipes/openblas/all/conanfile.py @@ -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] + } + 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) + 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" diff --git a/recipes/openblas/all/test_package/CMakeLists.txt b/recipes/openblas/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..56a1bba89a19d --- /dev/null +++ b/recipes/openblas/all/test_package/CMakeLists.txt @@ -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}) diff --git a/recipes/openblas/all/test_package/conanfile.py b/recipes/openblas/all/test_package/conanfile.py new file mode 100644 index 0000000000000..bd7165a553cf4 --- /dev/null +++ b/recipes/openblas/all/test_package/conanfile.py @@ -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) diff --git a/recipes/openblas/all/test_package/test_package.cpp b/recipes/openblas/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..03a0ac6803396 --- /dev/null +++ b/recipes/openblas/all/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include +#include + +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"); +} \ No newline at end of file diff --git a/recipes/openblas/config.yml b/recipes/openblas/config.yml new file mode 100644 index 0000000000000..a8f8151d88fe9 --- /dev/null +++ b/recipes/openblas/config.yml @@ -0,0 +1,3 @@ +versions: + "0.3.7": + folder: all \ No newline at end of file