Fix static build on Windows (#15989)

Summary:
Tested locally. It could be now be started by running `set EXTRA_CAFFE2_CMAKE_FLAGS= -DTORCH_STATIC=1` before build. If we want to make sure it works, then maybe we should add it into CI.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15989

Differential Revision: D13649935

Pulled By: soumith

fbshipit-source-id: 956945ed572819d8cf0bc9bd48df3ea9bc6f4a8a
diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt
index 309fcd4..72f3431 100644
--- a/torch/CMakeLists.txt
+++ b/torch/CMakeLists.txt
@@ -258,8 +258,8 @@
 
 
 if (TORCH_STATIC)
-  target_compile_definitions(torch PUBLIC TORCH_BUILD_STATIC_LIBS)
   add_library(torch STATIC ${TORCH_SRCS})
+  target_compile_definitions(torch PUBLIC TORCH_BUILD_STATIC_LIBS)
 else()
   add_library(torch SHARED ${TORCH_SRCS})
 endif()