How to build with custom utility source files?

I’m struggling with building pytorch, with additional c++ source code. Because it is about code instrumentation, I’m not considering c++ extensions.
So I tried to locate my .h and .cpp files in torch/csrc/utils/, but it seems like additional treatment is needed to build properly with additional source files. If it is true, where is the place that I should add the information about my additional sources?

Current state:

torch/csrc/utils/instrument.h:

int foo();

torch/csrc/utils/instrument.cpp:

#include <torch/csrc/utils/instrument.h>

int foo() {
  return 42;
}

When foo() is invoked by other (existing) source code, pytorch is built without error, but fails to be imported in python with undefined symbol error.

Solved.

By entirely reinstalling pytorch,(that is, python setup.py clean followed by python setup.py install) it works. Guess compile commands for new source files are added by cmake, which remains unchanged when only python setup.py install invoked :sweat_smile: