cmake patches

@patmarion: I successfully build the current master on Ubuntu 10.04