Skip to content

Commit

Permalink
Fix build error mkldnn due to corruptted CMAKE_REQUIRED_LIBRARIES (py…
Browse files Browse the repository at this point in the history
…torch#12195)

Summary:
This is to fix cmake-time compilation error.

 When we change script to build Caffe2 with mkldnn, we run into some cmake-time compilation support check (like in libsleef) failed due to incorrect setting of CMAKE_REQUIRED_LIBRARIES.  It is a global setting which can interfere camke compilation if it is not clean up properly.  FindBLAS.cmake and FindLAPACK.cmake didn't clean this flag, and causes incorrect building of libsleef.so.

yinghai gujinghui
Pull Request resolved: pytorch#12195

Differential Revision: D10159314

Pulled By: yinghai

fbshipit-source-id: 04908738f7d005579605b9c2a58d54f035d3baf4
  • Loading branch information
gujinghui authored and facebook-github-bot committed Oct 4, 2018
1 parent ae7a7fb commit c064f8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/Modules/FindBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ int main() {
ELSE (BLAS_USE_CBLAS_DOT)
SET(BLAS_USE_CBLAS_DOT FALSE)
ENDIF (BLAS_USE_CBLAS_DOT)
SET(CMAKE_REQUIRED_LIBRARIES)
ENDIF(BLAS_LIBRARIES)

# epilogue
Expand Down
5 changes: 5 additions & 0 deletions cmake/Modules/FindLAPACK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "accelerate"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" ACCELERATE_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(ACCELERATE_LAPACK_WORKS)
SET(LAPACK_INFO "accelerate")
else()
Expand All @@ -110,6 +111,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "veclib"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" VECLIB_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(VECLIB_LAPACK_WORKS)
SET(LAPACK_INFO "veclib")
else()
Expand All @@ -121,6 +123,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "open"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" OPEN_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(OPEN_LAPACK_WORKS)
SET(LAPACK_INFO "open")
else()
Expand All @@ -132,6 +135,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "goto"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" GOTO_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(GOTO_LAPACK_WORKS)
SET(LAPACK_INFO "goto")
else()
Expand All @@ -143,6 +147,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "acml"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" ACML_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(ACML_LAPACK_WORKS)
SET(LAPACK_INFO "acml")
else()
Expand Down

0 comments on commit c064f8a

Please sign in to comment.