Export the following modification to your C compiler default commandline- "export CC="diet -Os $CC" where "diet" is the searchable path to the diet libc wrapper for things. (If you've got diet in the search path, nothing else should be needed)
Ensure your CMake environment is at distclean stage (No CMakeFiles or other related cache files from a cmake . or similar present in the build directory)
Run cmake on the project sources for a builddir setup for make to build your code.