While it is legal to add a Stock or a Folding Stock to a pistol, doing so will create a SBR which must be engraved and approved using an ATF Form 1 prior to doing so. In fact, having a stock and a pistol in close proximity with the present ability to configure it as an SBR could be constructive possession of an SBR. If you are planning on doing building an SBR, you should keep the stock in a separate location so that you are not charged with possession of an SBR without a valid tax stamp and approval to do so.
While SBRs are legal in many states, they are not legal in all states and you should check to see if possession or manufacturing a SBR is legal in your state.