DaemonSnake / single-header

a rust command line utility to generate portable C/C++ single header file
MIT License
7 stars 0 forks source link

cmake support #1

Closed DaemonSnake closed 7 months ago

DaemonSnake commented 7 months ago

add a --cmake option that takes a cmake build directory as parameter and reads the compile_commands.json file. For the provided file it extracts the arguments listed relevant to the preprocessor and adds them to its list of arguments. To start maybe only the -D, -U, -I, -iquote, -std options

Example:

$>cat build/compile_commands.json 
[{
  "directory": ".../build",
  "command": "/usr/bin/clang++ -I/some/folder  -g -std=gnu++20 -o outputfile.o -c inputfile.cpp",
  "file": ".../inputfile.cpp",
  "output": ".../outputfile.o"
}]

$>single-header --cmake ./build inputfile.cpp

# would be equivalent to

$>single-header inputfile.cpp -- -I/some/folder -std=gnu++20
DaemonSnake commented 7 months ago

first version implemented by https://github.com/DaemonSnake/single-header/commit/9abcf72a45c1dc644cc692f4cebc04f9daa146b5