MantisBT - CMake
View Issue Details
0016038CMakeCMakepublic2016-03-30 14:512016-06-10 14:21
Reid Kleckner 
Brad King 
normalminoralways
closedfixed 
Windows
CMake 3.4.3 
CMake 3.6CMake 3.6 
0016038: CHECK_COMPILER_FLAG_COMMON_PATTERNS doesn't match clang-cl's unknown argument warning
These are the patterns that cmake appears to be looking for to spot unsupported options:
     FAIL_REGEX "unknown .*option" # Clang
     FAIL_REGEX "optimization flag .* not supported" # Clang

But we actually have two other diagnostics, one of which needs to be matched:
def err_drv_unknown_argument : Error<"unknown argument: '%0'">;
def warn_drv_unknown_argument_clang_cl : Warning<
  "unknown argument ignored in clang-cl: '%0'">,
  InGroup<UnknownArgument>;

The first is an error diagnostic, so you don't need to match it. We added the second because MSVC ignores unknown flags, and clang-cl needs to do the same. We chose the text for consistency with the error diagnostic.
Have this in a cmake project:
check_cxx_compiler_flag(-not-a-real-flag IS_REAL_FLAG)

Configure the project with clang-cl as the compiler.

Observe that IS_REAL_FLAG is ON.
This came up while I was trying to build asan with clang-cl.
No tags attached.
Issue History
2016-03-30 14:51Reid KlecknerNew Issue
2016-03-31 08:56Brad KingNote Added: 0040774
2016-03-31 08:56Brad KingAssigned To => Brad King
2016-03-31 08:56Brad KingStatusnew => resolved
2016-03-31 08:56Brad KingResolutionopen => fixed
2016-03-31 08:56Brad KingFixed in Version => CMake 3.6
2016-03-31 08:56Brad KingTarget Version => CMake 3.6
2016-03-31 14:03Reid KlecknerNote Added: 0040784
2016-03-31 14:10Brad KingNote Added: 0040785
2016-03-31 19:35Reid KlecknerNote Added: 0040786
2016-06-10 14:21Kitware RobotNote Added: 0041206
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040774)
Brad King   
2016-03-31 08:56   
Thanks. Please try this fix:

 Check*CompilerFlag: Add another pattern for Clang
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17c4863c [^]
(0040784)
Reid Kleckner   
2016-03-31 14:03   
Do you think a shorter pattern of just "unknown argument" would be better?
(0040785)
Brad King   
2016-03-31 14:10   
Many of the other matching expressions include the "ignored" part, so how about "unknown argument ignored":

 Check*CompilerFlag: Add another pattern for Clang
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fae80ee2 [^]

?
(0040786)
Reid Kleckner   
2016-03-31 19:35   
Yep, sounds good. BTW, I checked out that commit, and it fixed the asan runtime build issues with clang-cl. Thanks!
(0041206)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.