Ported from Makefile to CMake