cmake - How to use clang to generate all ast files for a project with makefile or cmakelist? -


i have developed static analyze tool based on clang reads ast files generated clang -emit-ast option , analysis on them.

when testing tool, it's convenient generate ast files multiple c or cpp files. can use command 1 one:

clang -emit-ast test.c -o test.ast 

but when comes large project build make or cmake, don't know how can generate ast files. there convenient way manage that?

you can use add_custom_target cmake.

something this:

add_custom_target(ast) foreach(sourcefile ${sourcefiles}) add_custom_command(target ast pre_build                  command clang -emit-ast ${sourcefile} -o ${cmake_binary_dir}/${sourcefile}.ast) 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -