[12407] minor CMake cleanup

- execute the CMake version check as the first thing in CMakeLists.txt
- simplify check for out of source build
- removed some unused and commented code