openblas cmake

pull/1538/head
Hui Zhang 3 years ago
parent 6a32a0bf33
commit 04eb8a285d

@ -26,6 +26,9 @@ set(FETCHCONTENT_BASE_DIR ${fc_patch})
# compiler option
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14 -pthread -fPIC -O0 -Wall -g")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} --std=c++14 -pthread -fPIC -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} --std=c++14 -pthread -fPIC -O3 -Wall")
###############################################################################
# Option Configurations
###############################################################################
@ -134,29 +137,10 @@ set(DEPS ${DEPS}
${EXTERNAL_LIB})
#openblas
set(OpenBLAS_INSTALL_PREFIX ${fc_patch}/openblas-install)
#set(OpenBLAS_INSTALL_PREFIX ${fc_patch}/OpenBLAS)
#set(OpenBLAS_SOURCE_DIR ${fc_patch}/OpenBLAS-src)
#set(OpenBLAS_PREFIX ${fc_patch}/OpenBLAS-prefix)
#ExternalProject_Add(
#OpenBLAS
#GIT_REPOSITORY https://github.com/xianyi/OpenBLAS
#GIT_TAG 1ef97c470ccf23d06d3bb0597c52df4a2e9093b9
#GIT_SHALLOW TRUE
#GIT_PROGRESS TRUE
#PREFIX ${OpenBLAS_PREFIX}
#SOURCE_DIR ${OpenBLAS_SOURCE_DIR}
#BUILD_IN_SOURCE TRUE
#CONFIGURE_COMMAND ""
#BUILD_COMMAND make
#INSTALL_COMMAND make PREFIX=${OpenBLAS_INSTALL_PREFIX} install
#UPDATE_DISCONNECTED TRUE
#)
link_directories(${OpenBLAS_INSTALL_PREFIX}/lib)
include_directories(${OpenBLAS_INSTALL_PREFIX}/include)
# gfortan dir in the docker.
link_directories(/usr/local/gcc-8.2/lib64)
include(openblas)
# openblas need, gfortan dir in the docker.
#link_directories(/usr/local/gcc-8.2/lib64)
###############################################################################
# Add local library

@ -16,11 +16,12 @@ if [ ! -d ${boost_SOURCE_DIR} ]; then wget -c https://boostorg.jfrog.io/artifact
echo -e "\n"
fi
rm -rf build
mkdir -p build
cd build
cmake .. -DBOOST_ROOT:STRING=${boost_SOURCE_DIR} --target clean
cmake .. -DBOOST_ROOT:STRING=${boost_SOURCE_DIR}
make
make -j
cd -

@ -1,5 +1,10 @@
include(FetchContent)
set(BUILD_SHARED_LIBS OFF) # up to you
set(BUILD_TESTING OFF) # to disable abseil test, or gtest will fail.
set(ABSL_ENABLE_INSTALL ON) # now you can enable install rules even in subproject...
FetchContent_Declare(
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"

@ -5,4 +5,5 @@ FetchContent_Declare(
URL_HASH SHA256=94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91
)
FetchContent_MakeAvailable(gtest)
include_directories(${gtest_BINARY_DIR} ${gtest_SOURCE_DIR}/src)

@ -0,0 +1,53 @@
include(FetchContent)
# set(OpenBLAS_INSTALL_PREFIX ${fc_patch}/openblas-install)
# set(OpenBLAS_INSTALL_PREFIX ${fc_patch}/OpenBLAS)
set(OpenBLAS_SOURCE_DIR ${fc_patch}/OpenBLAS-src)
set(OpenBLAS_PREFIX ${fc_patch}/OpenBLAS-prefix)
# ExternalProject_Add(
# OpenBLAS
# GIT_REPOSITORY https://github.com/xianyi/OpenBLAS
# GIT_TAG 1ef97c470ccf23d06d3bb0597c52df4a2e9093b9
# GIT_SHALLOW TRUE
# GIT_PROGRESS TRUE
# PREFIX ${OpenBLAS_PREFIX}
# SOURCE_DIR ${OpenBLAS_SOURCE_DIR}
# BUILD_IN_SOURCE TRUE
# CONFIGURE_COMMAND ""
# BUILD_COMMAND make
# INSTALL_COMMAND make PREFIX=${OpenBLAS_INSTALL_PREFIX} install
# UPDATE_DISCONNECTED TRUE
# )
# ######################################################################################################################
# OPENBLAS https://github.com/lattice/quda/blob/develop/CMakeLists.txt#L575
# ######################################################################################################################
enable_language(Fortran)
#TODO: switch to CPM
include(GNUInstallDirs)
ExternalProject_Add(
OPENBLAS
GIT_REPOSITORY https://github.com/xianyi/OpenBLAS.git
GIT_TAG v0.3.10
GIT_SHALLOW YES
PREFIX ${OpenBLAS_PREFIX}
SOURCE_DIR ${OpenBLAS_SOURCE_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
CMAKE_GENERATOR "Unix Makefiles")
# https://cmake.org/cmake/help/latest/module/ExternalProject.html?highlight=externalproject_get_property#external-project-definition
ExternalProject_Get_Property(OPENBLAS INSTALL_DIR)
set(OpenBLAS_INSTALL_PREFIX ${INSTALL_DIR})
add_library(openblas STATIC IMPORTED)
add_dependencies(openblas OPENBLAS)
set_target_properties(openblas PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES Fortran)
# ${CMAKE_INSTALL_LIBDIR} lib
set_target_properties(openblas PROPERTIES IMPORTED_LOCATION ${OpenBLAS_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libopenblas.a)
# https://cmake.org/cmake/help/latest/command/install.html?highlight=cmake_install_libdir#installing-targets
# ${CMAKE_INSTALL_LIBDIR} lib
# ${CMAKE_INSTALL_INCLUDEDIR} include
link_directories(${OpenBLAS_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
include_directories(${OpenBLAS_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
Loading…
Cancel
Save