-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
20397fc
commit 6d052e3
Showing
4 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Source: openblas | ||
Version: v0.2.19 | ||
Description: OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |