[CMake] Using m4 as a additional preprocessor for C/C++

Denis Scherbakov denis_scherbakov at yahoo.com
Fri Jun 5 10:22:53 EDT 2009



> I wanted to do some looping in macros which are not
> possible in GNU
> CPP. So, I wrote
> macros in m4. I wish to pre-process all my C/C++ code with
> m4 before
> handing it over to
> gcc. I did not find any direct way out for doing this in
> cmake. Any
> ideas how to do it with
> cmake?

Use ADD_CUSTOM_COMMAND to call m4 preprocessor and OUTPUT file.cpp
Then use SET_SOURCE_FILES_PROPERTIES set GENERATED TRUE
and then include file.cpp into a list of sources for compilation.

Denis


      


More information about the CMake mailing list