Repository: pytorch
Issue: build_android.sh
Labels: oncall: mobile

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->
```
liulai@liulai-thinkpad:~/src_compile/pytorch$ ./scripts/build_android.sh -DBUILD_BINARY=ON
Build with ANDROID_ABI[armeabi-v7a with NEON], ANDROID_NATIVE_API_LEVEL[21]
Bash: GNU bash，版本 5.0.17(1)-release (x86_64-pc-linux-gnu)
Python: 3.8.2 (default, Jul 16 2020, 14:00:26) 
[GCC 9.3.0]
Caffe2 path: /home/liulai/src_compile/pytorch
Using Android NDK at /home/liulai/software/ndk/android-ndk-r21b
Android NDK version: 21
-- Check for working CXX compiler: /home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Not forcing any particular BLAS to be found
-- Performing Test CAFFE2_EXCEPTION_PTR_SUPPORTED
-- Performing Test CAFFE2_EXCEPTION_PTR_SUPPORTED - Success
-- std::exception_ptr is supported.
-- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING
-- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING - Success
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS - Failed
-- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_SUPPORTS_RDYNAMIC
-- Performing Test COMPILER_SUPPORTS_RDYNAMIC - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Trying to find preferred BLAS backend of choice: Eigen
CMake Error at cmake/Dependencies.cmake:310 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/pthreadpool

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:313 (set_property):
  set_property could not find TARGET pthreadpool.  Perhaps it has not yet
  been created.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:353 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/cpuinfo

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:358 (set_property):
  set_property could not find TARGET cpuinfo.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


-- The ASM compiler identification is Clang
-- Found assembler: /home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:304 (add_subdirectory):
  add_subdirectory given source
  "/home/liulai/src_compile/pytorch/third_party/cpuinfo/deps/clog" which is
  not an existing directory.


CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:308 (set_property):
  set_property could not find TARGET clog.  Perhaps it has not yet been
  created.


CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:326 (add_subdirectory):
  The binary directory

    /home/liulai/src_compile/pytorch/build_android/confu-deps/cpuinfo

  is already used to build a source directory.  It cannot be used to build
  source directory

    /home/liulai/src_compile/pytorch/third_party/cpuinfo

  Specify a unique binary directory name.


CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:336 (add_subdirectory):
  The binary directory

    /home/liulai/src_compile/pytorch/build_android/confu-deps/pthreadpool

  is already used to build a source directory.  It cannot be used to build
  source directory

    /home/liulai/src_compile/pytorch/third_party/pthreadpool

  Specify a unique binary directory name.


CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:362 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/FXdiv

  does not contain a CMakeLists.txt file.


CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:377 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/psimd

  does not contain a CMakeLists.txt file.


CMake Error at aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt:394 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/FP16

  does not contain a CMakeLists.txt file.


CMake Error at cmake/Dependencies.cmake:441 (set_property):
  set_property could not find TARGET cpuinfo.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


-- Brace yourself, we are building NNPACK
CMake Error at cmake/External/nnpack.cmake:71 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/NNPACK

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  cmake/Dependencies.cmake:471 (include)
  CMakeLists.txt:493 (include)


CMake Error at cmake/External/nnpack.cmake:76 (set_property):
  set_property could not find TARGET nnpack.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  cmake/Dependencies.cmake:471 (include)
  CMakeLists.txt:493 (include)


CMake Error at cmake/External/nnpack.cmake:77 (set_property):
  set_property could not find TARGET pthreadpool.  Perhaps it has not yet
  been created.
Call Stack (most recent call first):
  cmake/Dependencies.cmake:471 (include)
  CMakeLists.txt:493 (include)


CMake Error at cmake/External/nnpack.cmake:78 (set_property):
  set_property could not find TARGET cpuinfo.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  cmake/Dependencies.cmake:471 (include)
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:501 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/XNNPACK

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:505 (set_property):
  set_property could not find TARGET XNNPACK.  Perhaps it has not yet been
  created.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Warning at cmake/Dependencies.cmake:698 (message):
  Turning USE_FAKELOWP off as it depends on USE_FBGEMM.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:833 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/FP16

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


-- Using third party subdirectory Eigen.
-- Could NOT find pybind11 (missing: pybind11_DIR)
-- Could NOT find pybind11 (missing: pybind11_INCLUDE_DIR) 
-- Using third_party/pybind11.
-- pybind11 include dirs: /home/liulai/src_compile/pytorch/cmake/../third_party/pybind11/include
CMake Warning at cmake/Dependencies.cmake:1229 (message):
  Not using CUDA/ROCM, so disabling USE_NCCL.  Suppress this warning with
  -DUSE_NCCL=OFF.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Warning at cmake/Dependencies.cmake:1347 (message):
  Metal is only used in ios builds.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:1734 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/fmt

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


CMake Error at cmake/Dependencies.cmake:1743 (set_target_properties):
  set_target_properties Can not find target to add properties to:
  fmt-header-only
Call Stack (most recent call first):
  CMakeLists.txt:493 (include)


-- Performing Test HAS_WERROR_FORMAT
-- Performing Test HAS_WERROR_FORMAT - Success
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR) 
-- don't use NUMA
-- Using ATen parallel backend: NATIVE
disabling CUDA because USE_CUDA is set false
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Looking for mmap
-- Looking for mmap - found
-- Looking for shm_open
-- Looking for shm_open - not found
-- Looking for shm_unlink
-- Looking for shm_unlink - not found
-- Looking for malloc_usable_size
-- Looking for malloc_usable_size - found
AT_INSTALL_INCLUDE_DIR include/ATen/core
core header install: /home/liulai/src_compile/pytorch/build_android/aten/src/ATen/core/TensorBody.h
CMake Error at caffe2/CMakeLists.txt:105 (add_subdirectory):
  The source directory

    /home/liulai/src_compile/pytorch/third_party/FXdiv

  does not contain a CMakeLists.txt file.


CMake Warning at CMakeLists.txt:770 (message):
  Generated cmake files are only fully tested if one builds with system glog,
  gflags, and protobuf.  Other settings may generate files that are not well
  tested.


CMake Warning at CMakeLists.txt:822 (message):
  Generated cmake files are only available when building shared libs.


-- 
-- ******** Summary ********
-- General:
--   CMake version         : 3.16.3
--   CMake command         : /usr/bin/cmake
--   System                : Android
--   C++ compiler          : /home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
--   C++ compiler id       : Clang
--   C++ compiler version  : 9.0
--   BLAS                  : Eigen
--   CXX flags             : -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -frtti -fexceptions  -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format
--   Build type            : Release
--   Compile definitions   : 
--   CMAKE_PREFIX_PATH     : /usr/lib/python3/dist-packages;/home/liulai/software/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64
--   CMAKE_INSTALL_PREFIX  : /home/liulai/src_compile/pytorch/build_android/install
-- 
--   TORCH_VERSION         : 1.7.0
--   CAFFE2_VERSION        : 1.7.0
--   BUILD_CAFFE2          : ON
--   BUILD_CAFFE2_OPS      : OFF
--   BUILD_CAFFE2_MOBILE   : OFF
--   BUILD_STATIC_RUNTIME_BENCHMARK: OFF
--   BUILD_BINARY          : ON
--   BUILD_CUSTOM_PROTOBUF : OFF
--     Protobuf compiler   : 
--     Protobuf includes   : 
--     Protobuf libraries  : 
--   BUILD_DOCS            : OFF
--   BUILD_PYTHON          : OFF
--   BUILD_SHARED_LIBS     : OFF
--   BUILD_TEST            : OFF
--   BUILD_JNI             : OFF
--   BUILD_MOBILE_AUTOGRAD : OFF
--   INTERN_BUILD_MOBILE   : ON
--   USE_ASAN              : OFF
--   USE_CPP_CODE_COVERAGE : OFF
--   USE_CUDA              : OFF
--   USE_ROCM              : OFF
--   USE_EIGEN_FOR_BLAS    : ON
--   USE_FBGEMM            : OFF
--     USE_FAKELOWP          : OFF
--   USE_FFMPEG            : OFF
--   USE_GFLAGS            : OFF
--   USE_GLOG              : OFF
--   USE_LEVELDB           : OFF
--   USE_LITE_PROTO        : OFF
--   USE_LMDB              : OFF
--   USE_METAL             : OFF
--   USE_MKL               : 
--   USE_MKLDNN            : ON
--   USE_NCCL              : OFF
--   USE_NNPACK            : ON
--   USE_NUMPY             : ON
--   USE_OBSERVERS         : OFF
--   USE_OPENCL            : OFF
--   USE_OPENCV            : OFF
--   USE_OPENMP            : OFF
--   USE_TBB               : OFF
--   USE_VULKAN            : OFF
--   USE_PROF              : OFF
--   USE_QNNPACK           : OFF
--   USE_PYTORCH_QNNPACK   : ON
--   USE_REDIS             : OFF
--   USE_ROCKSDB           : OFF
--   USE_ZMQ               : OFF
--   USE_DISTRIBUTED       : OFF
--   Public Dependencies  : Threads::Threads
--   Private Dependencies : eigen_blas;pthreadpool;cpuinfo;pytorch_qnnpack;XNNPACK;fp16;log;fmt::fmt-header-only;dl
-- Configuring incomplete, errors occurred!
See also "/home/liulai/src_compile/pytorch/build_android/CMakeFiles/CMakeOutput.log".
See also "/home/liulai/src_compile/pytorch/build_android/CMakeFiles/CMakeError.log".
```

## Environment

OS:Ubuntu
cmake version:3.16.3
computer: ThinkPad


## Additional context


[CMakeError.log](https://github.com/pytorch/pytorch/files/5288904/CMakeError.log)
[CMakeOutput.log](https://github.com/pytorch/pytorch/files/5288907/CMakeOutput.log)


<!-- Add any other context about the problem here. -->