CMake: Fixed a macro for generating and build code