[CMake] List all "include_directories" for a given project or target

Michael Ellery mellery451 at gmail.com
Mon Nov 21 11:00:49 EST 2016


> On Nov 21, 2016, at 5:04 AM, Michael Jackson <mike.jackson at bluequartz.net> wrote:
> 
> Is there a command or variable or a code snippet from someone that essentially has a list of all the "include_directories" that have been used/created in a given project? Or can I get a list of all the targets(created and imported) and then get the list of "include_directories" from those targets?
> 
> I am messing about with the "VSCode.app" on OS X and their code completion extension. For this to work one needs to get a list of all the include directories possible so that clang knows where to look for the headers.
> 
> Wasn't there a cmake command that would dump all the compile commands to a file or something?
> 
> Thanks
> 
> 


The clang compilation database might give you what you need - it’s what several autocompletion tools already use. To generate this, just pass  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON when running cmake. You would have to extract the -I options from the command entries, I guess.

-Mike






More information about the CMake mailing list