introduce CMake build and split code into files