Generalize build script to be used in CMake based builds.