Cmake modules taken from https://github.com/rpavlik/cmake-modules see also https://stackoverflow.com/q/1435953