Add -D in CMake. Fix close. Add vm cases.