[CMake] How to create preprocess-only file rule

Alexander Neundorf a.neundorf-work at gmx.net
Fri Apr 24 13:20:00 EDT 2009


On Friday 24 April 2009, Nikolay Mitev wrote:
> Hi
>
> I'm trying to create a rule which will only run the C++ preprocessor on a
> file, without compiling it. I know about the make file.i rule, but if
> file.cpp is not a dependency of some target it does not get generated.
> Setting header_file property doesn't work either. Adding a custom rule
> works, but I have to manually assemble the include paths, defines, etc...
> I found the CMAKE_CXX_CREATE_PREPROCESSED_SOURCE rule in the modules dir,
> but I guess it can't be used directly in a cmake file. So, is there a way
> to generate a *.i target without the cpp file being included in any target?

What do you want to do ?

You could add the cpp file to a static dummy library which is 
EXCLUDE_FROM_ALL, so it is not built by default. The rule should be generated 
nevertheless.

Does this help ?


Alex


More information about the CMake mailing list