Skip to content

Commit 593ac0f

Browse files
authored
openblas (#12937)
1 parent 3636329 commit 593ac0f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

cmake/external/glog.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ ExternalProject_Add(
6060
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
6161
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
6262
)
63+
IF(WIN32)
64+
IF(NOT EXISTS "${GLOG_INSTALL_DIR}/lib/libglog.lib")
65+
add_custom_command(TARGET extern_glog POST_BUILD
66+
COMMAND cmake -E rename ${GLOG_INSTALL_DIR}/lib/glog.lib ${GLOG_INSTALL_DIR}/lib/libglog.lib
67+
)
68+
ENDIF()
69+
ENDIF(WIN32)
6370

6471
ADD_LIBRARY(glog STATIC IMPORTED GLOBAL)
6572
SET_PROPERTY(TARGET glog PROPERTY IMPORTED_LOCATION ${GLOG_LIBRARIES})

cmake/external/openblas.cmake

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,29 @@ IF(USE_EIGEN_FOR_BLAS)
1717
ENDIF(USE_EIGEN_FOR_BLAS)
1818

1919
INCLUDE(cblas)
20+
# IF(WIN32 AND NOT ${CBLAS_FOUND})
21+
22+
2023

2124
IF(NOT ${CBLAS_FOUND})
25+
2226
INCLUDE(ExternalProject)
2327

2428
SET(CBLAS_SOURCES_DIR ${THIRD_PARTY_PATH}/openblas)
2529
SET(CBLAS_INSTALL_DIR ${THIRD_PARTY_PATH}/install/openblas)
26-
SET(CBLAS_INC_DIR "${CBLAS_INSTALL_DIR}/include" CACHE PATH "openblas include directory." FORCE)
30+
SET(CBLAS_INCLUDE_DIR "${CBLAS_INSTALL_DIR}/include" CACHE PATH "openblas include directory." FORCE)
2731

2832
SET(CBLAS_LIBRARIES
2933
"${CBLAS_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}openblas${CMAKE_STATIC_LIBRARY_SUFFIX}"
3034
CACHE FILEPATH "openblas library." FORCE)
3135

3236
ADD_DEFINITIONS(-DPADDLE_USE_OPENBLAS)
37+
IF (WIN32)
38+
SET(CBLAS_FOUND true)
39+
MESSAGE(WARNING, "In windows, openblas only support msvc build, please build it manually and put it at " ${CBLAS_INSTALL_DIR})
40+
ENDIF(WIN32)
3341

42+
IF (NOT WIN32)
3443
SET(OPENBLAS_CC "${CMAKE_C_COMPILER} -Wno-unused-but-set-variable -Wno-unused-variable")
3544
SET(OPENBLAS_COMMIT "v0.2.20")
3645

@@ -69,7 +78,6 @@ IF(NOT ${CBLAS_FOUND})
6978
ENDIF()
7079

7180
SET(COMMON_ARGS CC=${OPENBLAS_CC} NO_SHARED=1 NO_LAPACK=1 libs)
72-
7381
ExternalProject_Add(
7482
extern_openblas
7583
${EXTERNAL_PROJECT_LOG_ARGS}
@@ -84,9 +92,11 @@ IF(NOT ${CBLAS_FOUND})
8492
UPDATE_COMMAND ""
8593
CONFIGURE_COMMAND ""
8694
)
95+
ELSE()
96+
ENDIF(NOT WIN32)
8797
SET(CBLAS_PROVIDER openblas)
8898
IF(WITH_C_API)
89-
INSTALL(DIRECTORY ${CBLAS_INC_DIR} DESTINATION third_party/openblas)
99+
INSTALL(DIRECTORY ${CBLAS_INCLUDE_DIR} DESTINATION third_party/openblas)
90100
# Because libopenblas.a is a symbolic link of another library, thus need to
91101
# install the whole directory.
92102
IF(ANDROID)
@@ -107,7 +117,8 @@ IF(NOT ${CBLAS_FOUND})
107117
ENDIF(NOT ${CBLAS_FOUND})
108118

109119
MESSAGE(STATUS "BLAS library: ${CBLAS_LIBRARIES}")
110-
INCLUDE_DIRECTORIES(${CBLAS_INC_DIR})
120+
MESSAGE(STATUS "BLAS Include: ${CBLAS_INCLUDE_DIR}")
121+
INCLUDE_DIRECTORIES(${CBLAS_INCLUDE_DIR})
111122

112123
# FIXME(gangliao): generate cblas target to track all high performance
113124
# linear algebra libraries for cc_library(xxx SRCS xxx.c DEPS cblas)

0 commit comments

Comments
 (0)