call find_package(OpenMP) only when USE_OPENMP=ON (#30223)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30223

I ran into find_package(OpenMP) failure in some linux environment when
USE_OPENMP=OFF. Figured this workaround to unblock - not sure how hard
to find & fix the root cause of find_package() failure.

Test:
- works in my case;
- will check CI;

Test Plan: Imported from OSS

Differential Revision: D18640309

Pulled By: ljk53

fbshipit-source-id: b5b30623f5da4edbe59574a8b35286b74c3225d3
This commit is contained in:
Jiakai Liu
2019-11-21 10:30:29 -08:00
committed by Facebook Github Bot
parent 7d3afc4186
commit d934cf484b

View File

@ -821,7 +821,9 @@ if (NOT NO_API)
endif()
find_package(OpenMP QUIET)
if(USE_OPENMP)
find_package(OpenMP QUIET)
endif()
if(USE_OPENMP AND OPENMP_FOUND)
message(STATUS "pytorch is compiling with OpenMP. \n"
"OpenMP CXX_FLAGS: ${OpenMP_CXX_FLAGS}. \n"