Repository: pytorch
Issue: "make install" skips some required libraries for static build
Labels: module: build,triaged

## 🐛 Bug

I'm using the cmake setup that's included with PyTorch to do a custom build. In particular I'm passing `-DBUILD_SHARED_LIBS=OFF` and a number of other `-D` to skip components I don't need (e.g. `-DBUILD_PYTHON=OFF`, `-DUSE_DISTRIBUTED=OFF`, etc.). I run `cmake` and then `make install`. The install copies most, but not all, of the `.a` files that were built into the `lib` sub-directory of `-DCMAKE_INSTALL_PREFIX`. For example, the following were _not_ installed:

```
libCaffe2_perfkernels_avx2.a
libCaffe2_perfkernels_avx512.a
libCaffe2_perfkernels_avx.a
libfmt.a
libfoxi_loader.a
libonnx.a
libonnx_proto.a
```

And then trying to use these libraries fails due to missing symbols. Manually copying them from the `lib` directory in the build to the install directory fixes the issue.

This is with the 1.7.1 release of PyTorch.

## To Reproduce

Steps to reproduce the behavior:

1. Run `cmake -DBUILD_SHARED_LIBS=OFF` with perhaps some other `-D...=OFF` to limit the build
1. Run `make install`

The exact flags I'm passing to `cmake` seem like they're probably not relevant but in case it helps:

```
-DBUILD_TEST=OFF -DGLOO_INSTALL=OFF -DBUILD_PYTHON=OFF
-DCPUINFO_LIBRARY_TYPE=static -DUSE_GLOO=OFF -DUSE_GFLAGS=OFF
-DUSE_FFMPEG=OFF -DUSE_CUDNN=OFF -DUSE_DISTRIBUTED=OFF
-DUSE_GFLAGS=OFF -DUSE_NATIVE_ARCH=OFF -DUSE_OPENCV=OFF
-DUSE_OPENMP=OFF -DBUILD_SHARED_LIBS=OFF
-DUSE_FBGEMM=OFF -DUSE_QNNPACK=OFF -DUSE_PYTORCH_QNNPACK=OFF -DUSE_XNNPACK=OFF
-DUSE_NNPACK=OFF -DUSE_ZSTD=OFF -DONXX_ML=OFF -DUSE_TENSORRT=OFF
-DUSE_TBB=OFF -DUSE_MKLDNN=OFF -DUSE_METAL=OFF
-DUSE_FAKELOWP=OFF -DUSE_NUMA=OFF -DUSE_CUDA=OFF -DUSE_NCCL=OFF
-DONNX_ML=OFF
-DCMAKE_CXX_STANDARD=14
-DBUILD_CAFFE2_OPS=OFF
-DUSE_GLOG=ON
-DPYTHON_EXECUTABLE=${python_exe}
-DUSE_SYSTEM_EIGEN_INSTALL=ON
-DBLAS=OpenBLAS
-DOpenBLAS_INCLUDE_DIR=${out_base}/openblas/include
-DOpenBLAS_LIB=${out_base}/openblas/lib/libopenblas.a
-DBUILD_CUSTOM_PROTOBUF=OFF -DUSE_LITE_PROTO=OFF
-DPROTOBUF_PROTOC_EXECUTABLE=${out_base}/protobuf/bin/protoc
-DPROTOBUF_INCLUDE_DIRS=${out_base}/protobuf/include
-DPROTOBUF_LIBRARY=${out_base}/protobuf/lib/libprotobuf.a
-DGLIBCXX_USE_CXX11_ABI=ON"
```

## Expected behavior

`make install` should install all the libraries that are needed to link against PyTorch.

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

PyTorch version: 1.7.1
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 10 (buster) (x86_64)
GCC version: (Debian 8.3.0-6) 8.3.0
Clang version: 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
CMake version: version 3.13.4

Python version: 3.7 (64-bit runtime)
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: Quadro P520
Nvidia driver version: 460.32.03
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip] Could not collect
[conda] Could not collect


cc @malfet @seemethere @walterddr