Caffe2 cmake exports INTERFACE_COMPILE_OPTIONS when building from source

(ondrej-smola) #1

I am having trouble creating libtorch binary distribution to be exactly the same as the one downloadable from Pytorch website (windows 10, pytorch master, VS2017, cmake 3.14, python 3.7, c++ 17, cuda 10, cudnn 7.6) - need to compile with protobuf 3.7.1 due to https://github.com/pytorch/pytorch/issues/14573

python tools/build_libtorch.py
python setup.py sdist --format=zip

Everything compiles OK but caffe2 cmake module Caffe2Targets.cmake exports

set_target_properties(caffe2 PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "_THP_CORE;AT_PARALLEL_OPENMP=1"
  INTERFACE_COMPILE_OPTIONS "/Z7;/EHa;/DNOMINMAX;/wd4267;/wd4251;/wd4522;/wd4522;/wd4838;/wd4305;/wd4244;/wd4190;/wd4101;/wd4996;/wd4275;/bigobj;-openmp"
  INTERFACE_INCLUDE_DIRECTORIES "C:/Program Files/NVIDIA Corporation/NvToolsExt/include;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "protobuf::libprotobuf;c10;Threads::Threads"
)

they come from setup.py

but these options are not present in the downloadable libtorch archive. Only

set_target_properties(caffe2 PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "protobuf::libprotobuf;c10;Threads::Threads;caffe2::mkl"
)

Resulting in multiple
cl : Command line warning D9025 : overriding '/EHs' with '/EHa'.
warnings during my source compilation

I am fairly new to c++ and cmake so maybe I am just missing some simple part.

Thank you