change handwritten Makefile to CMake tool