MantisBT - CMake
View Issue Details
0015724CMakeCMakepublic2015-09-02 19:412016-02-01 09:10
Jeremie Delaitre 
Bill Hoffman 
normalminoralways
closedno change required 
linuxfedora22
CMake 3.3 
 
0015724: Unable to specify iwyu options
I am trying the new include-what-you-use support of CMake (3.3.0).
It is working fine when I just run iwyu, but I'd like to specify some additional options (most importantly "-Xiwyu --mapping-file=...").

I could not find a way to make it work. I tried to specify the options with: set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "/usr/bin/iwyu -Xiwyu --mapping-file=...") without success (I tried other iwyu options too).

The command line generated looks like:

FAILED: /usr/bin/cmake -E __run_iwyu --iwyu="/usr/bin/include-what-you-use -Xiwyu --mapping_file=<path-to-mapping-file>" -- <path-to-compiler>/g++ --sysroot=<path-to-sysroot> <other compiler options> <file to compile>
Error running '/usr/bin/include-what-you-use -Xiwyu --mapping_file="<path-to-mapping-file>"': No such file or directory

I tried to change the command by hand (e.g. moving the iwyu option after the "--") but it did not work neither.

Any hint?
- CMake 3.3.0
- include-what-you-use 0.3 based on clang version 3.5.0 (tags/RELEASE_350/final)
No tags attached.
Issue History
2015-09-02 19:41Jeremie DelaitreNew Issue
2015-09-03 13:18Bill HoffmanAssigned To => Bill Hoffman
2015-09-03 13:18Bill HoffmanStatusnew => assigned
2015-09-03 13:22Bill HoffmanNote Added: 0039369
2015-09-03 13:31Brad KingNote Added: 0039370
2015-09-03 17:19Jeremie DelaitreNote Added: 0039371
2015-09-08 09:31Brad KingStatusassigned => resolved
2015-09-08 09:31Brad KingResolutionopen => no change required
2016-02-01 09:10Robert MaynardNote Added: 0040389
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0039369)
Bill Hoffman   
2015-09-03 13:22   
http://www.cmake.org/cmake/help/v3.3/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.html [^]

"Specify a ;-list containing a command line for the include-what-you-use tool."

So, this should work:
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "/usr/bin/iwyu;-Xiwyu;--mapping-file=...")
(0039370)
Brad King   
2015-09-03 13:31   
The set() command constructs a ;-list from its arguments so one can simply write:

 set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE /usr/bin/iwyu -Xiwyu --mapping-file=...)
(0039371)
Jeremie Delaitre   
2015-09-03 17:19   
Both way actually works! The only one not working was the one I was using (i.e. quoting the whole command, using spaces to separate args).

I did not quite understand the documentation, ";-list" was not very meaningful for me (next time, I'll read the linked page more carefully...), but now I understand what you meant!

Sorry for the noise.
(0040389)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.