How to pick a cam

I've heard lots of times that choosing a cam is the hardest and most important choice you make when building an engine, but I've never heard how to pick the right cam for your engine based on the parts that are installed or the expected power output. How do you do this???