[CMake] feed parsed information from source files into compile process

Tyler Roscoe tyler at cryptio.net
Wed Feb 9 12:01:16 EST 2011


On Wed, Feb 09, 2011 at 05:24:28PM +0100, Verweij, Arjen wrote:
> Currently there is a python script that does preprocessing of all
> source, stores information in override.cmake files using
> set_source_file_properties(). This works fine, but makes maintaining
> source more error prone than it was. For instance a developer might
> use the code for an FE element, use it as the basis for a collapsed
> version and inherit specific optimizations which are now ignored.
> 
> I have looked at a way to chain this step using add_custom_command(),
> but I see no possibility to tell the generator about some variable an
> external program will fill in during the build phase.

You can't use add_custom_command() to drive this because the results of
any custom commands will only be available at build time. You need stuff
to happen at CMake configure time.

Hence, I would use execute_process() to run your python script at
configure time. It would deposit its results into a file, which you
could then include() (or file(READ ...)).

hth,
tyler


More information about the CMake mailing list