Yes, the cost of building the house is factored in, but you don't necessarily have capital gain, it could be taxed as ordinary income.
If you're building a house to sell, the IRS views it as a business activity rather than an ordinary investment. You won't pay capital gains, the $150,000 will be taxed as ordinary income, plus self-employment/payroll tax depending on your business structure.
If you build a house, live in it then sell, the cost of constructing the house is a capital improvement which adds to the basis of the house for capital gains purposes. As your primary residence you can get some exclusion on the capital gain if you lived there for 2 years, and in some cases a pro-rated exclusion even if you lived in it fewer than 2 years.
If you buy land or a house, do nothing to improve it, don't live in it, and re-sell it for more, you have capital gains.
There are a number of other considerations for determining when real-estate transactions are taxed as ordinary income instead of capital gains, you'd want to consult an accountant to understand the specifics of your situation fully, but in general building to sell is a business activity in the eyes of the IRS. Given short-term capital gain rates being the same as ordinary income tax rates, the importance is whether or not self-employment tax is also due. The best tax-advantaged building/flipping scenario is living in the house for 2 years before moving to the next.