0

I've been using a header-only library, but it has actually separated it out into header (*.h) and source (*.c) files.

SQLite creates a single file—primarily for other reasons related to optimisation—so I was wondering if there's an automated way of generated one header amalgamation from multiple header and source files.

(I've tried manually by running SUBSTRING in my CMakeLists.txt)

The advantage is skipping a target_link_library step is in build speed, distribution, and simpler help text.

I could probably write something with LLVM's LibTooling or LibClang… but this seems like a common use case that others have solved expertly.

How do I automatically generate one amalgamated header from multiple header and source files?

Samuel Marks
  • 1,611
  • 1
  • 20
  • 25
  • PS: Here's my `SUBSTRING` attempt: https://github.com/microsoft/vcpkg/pull/17343#issuecomment-822283204 – Samuel Marks Apr 19 '21 at 11:46
  • SQLite uses a Tcl script [mksqlite3.c.tcl](https://sqlite.org/src/file?name=tool/mksqlite3c.tcl&ci=trunk) to do that. Most of the projects I've worked on or seen use a scripting language for file pre-processing like this. – Mark Benningfield Apr 19 '21 at 12:03

0 Answers0