diff options
| author | Han Hu <huhan8807@gmail.com> | 2017-04-12 10:45:07 +0800 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-04-14 18:30:23 -0700 |
| commit | 6d052e3dc0df2498d7707eea9259acee824200e8 (patch) | |
| tree | 9142b405243656c2f15e4df502f01cc4802a0dd6 | |
| parent | 20397fc845fac398a1aca2ee17ce5b932fc1a83b (diff) | |
| download | vcpkg-6d052e3dc0df2498d7707eea9259acee824200e8.tar.gz vcpkg-6d052e3dc0df2498d7707eea9259acee824200e8.zip | |
Add openblas and only the blas part is compiled. Because no gfortran things is included, openblas is BSD
[openblas] Reduce checked in headers, prefer to install from sources
| -rw-r--r-- | ports/openblas/CONTROL | 3 | ||||
| -rw-r--r-- | ports/openblas/install-openblas.patch | 24 | ||||
| -rw-r--r-- | ports/openblas/openblas_common.h | 72 | ||||
| -rw-r--r-- | ports/openblas/portfile.cmake | 71 |
4 files changed, 170 insertions, 0 deletions
diff --git a/ports/openblas/CONTROL b/ports/openblas/CONTROL new file mode 100644 index 000000000..d6ac6297d --- /dev/null +++ b/ports/openblas/CONTROL @@ -0,0 +1,3 @@ +Source: openblas +Version: v0.2.19 +Description: OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version. diff --git a/ports/openblas/install-openblas.patch b/ports/openblas/install-openblas.patch new file mode 100644 index 000000000..7beb11af9 --- /dev/null +++ b/ports/openblas/install-openblas.patch @@ -0,0 +1,24 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ff42643..1a013ee 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,7 +13,7 @@ enable_language(ASM) + enable_language(C) + + if(MSVC) +-set(OpenBLAS_LIBNAME libopenblas) ++set(OpenBLAS_LIBNAME openblas) + else() + set(OpenBLAS_LIBNAME openblas) + endif() +@@ -174,6 +174,10 @@ set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES + SOVERSION ${OpenBLAS_MAJOR_VERSION} + ) + ++install(TARGETS ${OpenBLAS_LIBNAME} ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib) + + # TODO: Why is the config saved here? Is this necessary with CMake? + #Save the config files for installation diff --git a/ports/openblas/openblas_common.h b/ports/openblas/openblas_common.h new file mode 100644 index 000000000..10b25d4c7 --- /dev/null +++ b/ports/openblas/openblas_common.h @@ -0,0 +1,72 @@ +#pragma once +#include "openblas_config.h" + +#if defined(OPENBLAS_OS_WINNT) || defined(OPENBLAS_OS_CYGWIN_NT) || defined(OPENBLAS_OS_INTERIX) +#define OPENBLAS_WINDOWS_ABI +#define OPENBLAS_OS_WINDOWS + +#ifdef DOUBLE +#define DOUBLE_DEFINED DOUBLE +#undef DOUBLE +#endif +#endif + +#ifdef NEEDBUNDERSCORE +#define BLASFUNC(FUNC) FUNC##_ +#else +#define BLASFUNC(FUNC) FUNC +#endif + + +#ifdef OPENBLAS_QUAD_PRECISION +typedef struct { + unsigned long x[2]; +} xdouble; +#elif defined OPENBLAS_EXPRECISION +#define xdouble long double +#else +#define xdouble double +#endif + +#if defined(OS_WINNT) && defined(__64BIT__) +typedef long long BLASLONG; +typedef unsigned long long BLASULONG; +#else +typedef long BLASLONG; +typedef unsigned long BLASULONG; +#endif + +#ifdef OPENBLAS_USE64BITINT +typedef BLASLONG blasint; +#else +typedef int blasint; +#endif + +#if defined(XDOUBLE) || defined(DOUBLE) +#define FLOATRET FLOAT +#else +#ifdef NEED_F2CCONV +#define FLOATRET double +#else +#define FLOATRET float +#endif +#endif + + +/* Inclusion of a standard header file is needed for definition of __STDC_* + predefined macros with some compilers (e.g. GCC 4.7 on Linux). This occurs + as a side effect of including either <features.h> or <stdc-predef.h>. */ +#include <stdio.h> +#define OPENBLAS_COMPLEX_STRUCT +typedef struct { float real, imag; } openblas_complex_float; +typedef struct { double real, imag; } openblas_complex_double; +typedef struct { xdouble real, imag; } openblas_complex_xdouble; +#define openblas_make_complex_float(real, imag) {(real), (imag)} +#define openblas_make_complex_double(real, imag) {(real), (imag)} +#define openblas_make_complex_xdouble(real, imag) {(real), (imag)} +#define openblas_complex_float_real(z) ((z).real) +#define openblas_complex_float_imag(z) ((z).imag) +#define openblas_complex_double_real(z) ((z).real) +#define openblas_complex_double_imag(z) ((z).imag) +#define openblas_complex_xdouble_real(z) ((z).real) +#define openblas_complex_xdouble_imag(z) ((z).imag) diff --git a/ports/openblas/portfile.cmake b/ports/openblas/portfile.cmake new file mode 100644 index 000000000..63f464405 --- /dev/null +++ b/ports/openblas/portfile.cmake @@ -0,0 +1,71 @@ +# Common Ambient Variables: +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# CURRENT_PORT DIR = ${VCPKG_ROOT_DIR}\ports\${PORT} +# PORT = current port name (zlib, etc) +# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc) +# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic) +# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic) +# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg> +# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm) +# + +include(vcpkg_common_functions) + + +if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + message(FATAL_ERROR "openblas can only be built for x64 currently") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + message(WARNING "openblas only support dynamic link for msvc") + set(VCPKG_LIBRARY_LINKAGE "dynamic") +endif() + +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/openblas-0.2.19) +vcpkg_download_distfile(ARCHIVE + URLS "https://codeload.github.com/xianyi/OpenBLAS/zip/v0.2.19" + FILENAME "openblas-v0.2.19.zip" + SHA512 d95dcd1ca5b3bdc5355969d10c22486f7e32f7dfc3a418b5d0a979d030e9f2ed242d2d78267a5896aa83d27b6041e13ee4c6694f9a589765535011eb22dad9e2 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/install-openblas.patch" +) + +# openblas require perl to generate .def for exports +vcpkg_find_acquire_program(PERL) +get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY) +set(ENV{PATH} "${PERL_EXE_PATH};$ENV{PATH}") + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + OPTIONS -DTARGET=NEHALEM -DBUILD_WITHOUT_LAPACK=ON + # PREFER_NINJA # Disable this option if project cannot be built with Ninja + # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + + +vcpkg_install_cmake() + +# openblas do not make the config file , so I manually made this +# but I think in most case, libraries will not include these files, they define their own used function prototypes +# this is only to quite vcpkg +file(COPY ${CMAKE_CURRENT_LIST_DIR}/openblas_common.h DESTINATION ${CURRENT_PACKAGES_DIR}/include) + +file(COPY ${SOURCE_PATH}/config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include) +file(RENAME ${CURRENT_PACKAGES_DIR}/include/config.h ${CURRENT_PACKAGES_DIR}/include/openblas_config.h) + +file(READ ${SOURCE_PATH}/cblas.h CBLAS_H) +string(REPLACE "#include \"common.h\"" "#include \"openblas_common.h\"" CBLAS_H ${CBLAS_H}) +file(WRITE ${CURRENT_PACKAGES_DIR}/include/cblas.h) + +# openblas is BSD +file(COPY ${CURRENT_BUILDTREES_DIR}/src/OpenBLAS-0.2.19/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/openblas) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/openblas/LICENSE ${CURRENT_PACKAGES_DIR}/share/openblas/copyright) + +vcpkg_copy_pdbs() |
