1

Is there a tool that generates a single header out of a header-only C++ library consisting of .h and .tcc (headers for template function definitions) files?

It should perform partial pre-processing, for example replace #include's of the headers belonging to the same source code tree, but leave #include's of external headers.

For example Catch (unit testing framework) uses a Python script (https://github.com/philsquared/Catch/tree/master/scripts) which seems to be custom written.

Is there a reusable tool for this? For example a CMake plugin, etc.

  • 1
    You should be able to run the file(s) through the g++ compiler with the -E flag, (you may need to create a stub cpp file that just does the includes), to do a lot of the work for you. You may even discover a flag for don't pre-process system Most C++ compilers give the option of just pre-processing. – Steve Barnes Dec 12 '16 at 20:07
  • I don't think you'll find a tool like that. Why would you even need it? Also, 'Catch' doesn't seem to properly parse C++, I'm guessing it's more of a glorified copy-paste mechanism. I also don't find it that significant to avoid having multiple include files. – einpoklum - reinstate Monica Dec 14 '16 at 15:30
0

Have a look Quom:

Quom is a single header generator for C/C++ libraries.

As input, it expects the main header file, which has to include all your sources (directly or indirectly). In the output, it inlined all local includes (#include "...") but not the system includes (#include <...>).

Its README file has an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.