Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22130

CMake - Automatically Parsing Dependencies of Precompiled Header?

$
0
0

As of yet, at least to my knowledge, there is no standard way in CMake to specify the addition of a precompiled header (PCH) to a project in a cross-platform manner because the way PCHs are handled by C++ compilers is very different among vendors. For G++, this is usually this is worked around by simply adding a custom command which takes care of invoking the compiler with the appropriate input and has it generate the PCH.

My current problem is that CMake will not parse the dependencies of the dependencies you specify for the custom command. For instance, assume the following structure:

pch.h
 |- dependA.h
 |- dependB.h
 ...

Only providing pch.h as a dependency will lead to the generation of the appropriate target in the corresponding makefile, which tracks changes to pch.h. However, CMake does not parse the includes insidepch.h and will therefore not recognize changes to dependA.h and dependB.h. This extends furhter if there are dependencies for dependsA.h and so on.

Note: I'm aware that the fact that PCH dependencies can and do change regularly puts the whole process in question. However, this is just the way it is and I can't really do anything about it.

Since the task isn't too hard, there are a couple of obvious ideas that come to mind:

Solution A:

Enter all the dependencies by hand. Obviously this works, but is tedious as hell and doesn't scale at all.

Solution B:

If possible, write a CMake function that automates the process and parse the includes "manually".

Solution C:

Do something similar using a different language, for instance Python, and just provide CMake a list of dependencies to add to the custom command.

Solution D:

Use gcc/g++'s feature to parse and print out the dependency tree of the PCH and parse the output to extract the list of dependencies.

My question is: does anyone know a more convenient and faster way to get this done?


Viewing all articles
Browse latest Browse all 22130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>