Cmake - Want to see intermediate .i files

匆匆过客 提交于 2020-01-13 13:50:50

问题


I want to know how to make Cmake give me a target that will allow me to save the .i files from my C program with the macro expansion, etc completed.

Will I need to make a custom target to do this?


回答1:


If your are using the Makefile generator, then there are already targets for .i files. Type make help, and you will see all the targets, including those suffixed by .i, .s, and .o.




回答2:


If you don't want to manually run the make targets and filter for .i extensions, you could do it like this:

for subdir in */
do 
    (cd $subdir && make $(make help |& grep \\.i$ | cut -c4-))
done

Alternatively, I sometimes used compile_command.json with npm's command line tool for json:

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON # ... 
json < compile_commands.json -ga "command" | sed 's/.cpp.o -c/.cpp.ii -E/' | sh -

Note however that there might be edge cases (like target directories that have not been created yet).



来源:https://stackoverflow.com/questions/21027266/cmake-want-to-see-intermediate-i-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!