<div dir="ltr">Thanks for the explanation of how to solve the problem, that’s very helpful I’ll give it a try.<div><br></div><div>Shouldn’t the variable be set to something like “FALSE” even if reporting incorrectly when left blank? I appreciate the workaround but I believe there is still a bug that would need to be addressed. Is this the right place to report bugs or is it mainly for questions?</div><div><br></div><div>Thanks again!</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div><br></div>Cheers!<div>Andrew Hundt</div></div></div>
<br><div class="gmail_quote">On Fri, Feb 26, 2016 at 2:57 PM, Gregor Jasny <span dir="ltr"><<a href="mailto:gjasny@googlemail.com" target="_blank">gjasny@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<span class=""><br>
On 26/02/16 00:00, Andrew Hundt wrote:<br>
> I believe check_cxx_compiler_flags is failing due to a long/complicated<br>
> compiler path.<br>
><br>
> Specifically my compiler is set to:<br>
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++<br>
><br>
> CMake version: 3.4.3<br>
><br>
> Full trace output in gist where you can see lines warning of regex failure:<br>
> <a href="https://gist.github.com/ahundt/88ce65bcc3c268acdd94" rel="noreferrer" target="_blank">https://gist.github.com/ahundt/88ce65bcc3c268acdd94</a><br>
><br>
><br>
> Here is the code snippet that fails:<br>
><br>
> include(CheckCXXCompilerFlag)<br>
>> check_cxx_compiler_flag(-std=c++11 COMPILER_SUPPORTS_CXX11)<br>
>> check_cxx_compiler_flag(-std=c++0x COMPILER_SUPPORTS_CXX0X)<br>
>> message(STATUS <<<<<<<<COMPILER_SUPPORTS_CXX11:${COMPILER_SUPPORTS_CXX11})<br>
<br>
</span>The problem is not compiler path related but related to the additional<br>
warnings that are enabled:<br>
<br>
<a href="https://github.com/code-iai/iai_kinect2/blob/master/kinect2_calibration/CMakeLists.txt#L4" rel="noreferrer" target="_blank">https://github.com/code-iai/iai_kinect2/blob/master/kinect2_calibration/CMakeLists.txt#L4</a><br>
<br>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBT_USE_DOUBLE_PRECISION -Wall")<br>
> # Unused warnings<br>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized -Winit-self -Wunused-function -Wunused-label -Wunused-variable -Wunused-but-set-variable -Wunused-but-set-parameter")<br>
> # Additional warnings<br>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Warray-bounds -Wtype-limits -Wreturn-type -Wsequence-point -Wparentheses -Wmissing-braces -Wchar-subscripts -Wswitch -Wwrite-strings -Wenum-compare -Wempty-body -Wlogical-op")<br>
<br>
Those cause clang to emit a warning about unknown warnings:<br>
<br>
>  clang -c -DBT_USE_DOUBLE_PRECISION -Wall -Wuninitialized -Winit-self -Wunused-function -Wunused-label -Wunused-variable -Wunused-but-set-variable -Wunused-but-set-parameter -Warray-bounds -Wtype-limits -Wreturn-type -Wsequence-point -Wparentheses -Wmissing-braces -Wchar-subscripts -Wswitch -Wwrite-strings -Wenum-compare -Wempty-body foo.cpp<br>
> warning: unknown warning option '-Wunused-but-set-variable'; did you mean<br>
>       '-Wunused-const-variable'? [-Wunknown-warning-option]<br>
> warning: unknown warning option '-Wunused-but-set-parameter'; did you mean<br>
>       '-Wunused-parameter'? [-Wunknown-warning-option]<br>
> 2 warnings generated.<br>
<br>
Those warnings are interpreted by check_cxx_compiler_flag as failure<br>
(this is the regex you observed [1]) which leads to a negative setting<br>
of the variable.<br>
<br>
I see three possible solutions:<br>
<br>
1) Move the check before touching the CMAKE_CXX_FLAGS.<br>
2) Require a more modern CMake (3.3) and set<br>
  CMAKE_CXX_STANDARD to 11<br>
  CMAKE_CXX_STANDARD_REQUIRED to TRUE<br>
3) Use modern CMake with target compile features:<br>
  <a href="https://cmake.org/cmake/help/v3.3/manual/cmake-compile-features.7.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/v3.3/manual/cmake-compile-features.7.html</a><br>
<br>
Thanks,<br>
Gregor<br>
<br>
[1]<br>
<a href="https://github.com/Kitware/CMake/blob/master/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake#L25" rel="noreferrer" target="_blank">https://github.com/Kitware/CMake/blob/master/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake#L25</a><br>
<br>
<br>
</blockquote></div><br></div>