Merged CMake checks from Nido

I also tried to make the CMakeLists.txt file script compatible
with Paul's cmake.