Fix build error mkldnn due to corruptted CMAKE_REQUIRED_LIBRARIES (#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: https://github.com/pytorch/pytorch/pull/12195

Differential Revision: D10159314

Pulled By: yinghai

fbshipit-source-id: 04908738f7d005579605b9c2a58d54f035d3baf4
This commit is contained in:
Gu, Jinghui 2018-10-04 11:44:21 -07:00 committed by Facebook Github Bot
parent ae7a7fb398
commit c064f8a89d
2 changed files with 6 additions and 0 deletions

View File

@ -290,6 +290,7 @@ int main() {
ELSE (BLAS_USE_CBLAS_DOT) ELSE (BLAS_USE_CBLAS_DOT)
SET(BLAS_USE_CBLAS_DOT FALSE) SET(BLAS_USE_CBLAS_DOT FALSE)
ENDIF (BLAS_USE_CBLAS_DOT) ENDIF (BLAS_USE_CBLAS_DOT)
SET(CMAKE_REQUIRED_LIBRARIES)
ENDIF(BLAS_LIBRARIES) ENDIF(BLAS_LIBRARIES)
# epilogue # epilogue

View File

@ -99,6 +99,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "accelerate")) IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "accelerate"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES}) SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" ACCELERATE_LAPACK_WORKS) check_function_exists("cheev_" ACCELERATE_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(ACCELERATE_LAPACK_WORKS) if(ACCELERATE_LAPACK_WORKS)
SET(LAPACK_INFO "accelerate") SET(LAPACK_INFO "accelerate")
else() else()
@ -110,6 +111,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "veclib")) IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "veclib"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES}) SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" VECLIB_LAPACK_WORKS) check_function_exists("cheev_" VECLIB_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(VECLIB_LAPACK_WORKS) if(VECLIB_LAPACK_WORKS)
SET(LAPACK_INFO "veclib") SET(LAPACK_INFO "veclib")
else() else()
@ -121,6 +123,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "open")) IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "open"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES}) SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" OPEN_LAPACK_WORKS) check_function_exists("cheev_" OPEN_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(OPEN_LAPACK_WORKS) if(OPEN_LAPACK_WORKS)
SET(LAPACK_INFO "open") SET(LAPACK_INFO "open")
else() else()
@ -132,6 +135,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "goto")) IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "goto"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES}) SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" GOTO_LAPACK_WORKS) check_function_exists("cheev_" GOTO_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(GOTO_LAPACK_WORKS) if(GOTO_LAPACK_WORKS)
SET(LAPACK_INFO "goto") SET(LAPACK_INFO "goto")
else() else()
@ -143,6 +147,7 @@ if(BLAS_FOUND)
IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "acml")) IF((NOT LAPACK_INFO) AND (BLAS_INFO STREQUAL "acml"))
SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES}) SET(CMAKE_REQUIRED_LIBRARIES ${BLAS_LIBRARIES})
check_function_exists("cheev_" ACML_LAPACK_WORKS) check_function_exists("cheev_" ACML_LAPACK_WORKS)
set(CMAKE_REQUIRED_LIBRARIES)
if(ACML_LAPACK_WORKS) if(ACML_LAPACK_WORKS)
SET(LAPACK_INFO "acml") SET(LAPACK_INFO "acml")
else() else()