What are the treatises on how to build mechanical computers?
This is a very broad question, with a different answer for each kind of device.
The computers before modern times did NOT use logic gates.

For example the January 2004 Scientific American article "The Curious History of the First Pocket Calculator" covers how Curta calculators work, in addition to the history.

The Antikythera mechanism used gear reductions (gears with differing teeth counts) to implement the ratios of times of various periodic events to predict positions. Given the [known even then] frequencies, it is straightforward to compute the required gear ratios. http://www.cs.virginia.edu/~robins/Decoding_an_Ancient_Computer.pdf

In addition (as mentioned in a comment above) there were many many different flavors of analog computers, that a quick google search should be able to find explanations for many of them.