[CMake] CHECK_CXX_ACCEPTS_FLAG delieverts wrong result

Hendrik Sattler post at hendrik-sattler.de
Wed Sep 25 14:52:54 EDT 2013



"Fetzer, Andreas" <a.fetzer at dkfz-heidelberg.de> schrieb:
>Hi,
>
>thanks for your answer. But the problem is that this flag is accepted
>although the clang compiler does not accept it. This leads to a build
>error.
>My question is why the CHECK_CXX_ACCEPTS_FLAG marco does not recognize
>that the flag is not supported by my compiler.
>
>Andreas
>
>
>On Sep 24, 2013, at 7:13 PM, Hendrik Sattler <post at hendrik-sattler.de>
>wrote:
>
>> 
>> 
>> "Fetzer, Andreas" <a.fetzer at Dkfz-Heidelberg.de> schrieb:
>>> Hi,
>>> 
>>> I am using Mac OS X 10.7 with Apple clang version 3.1. At the moment
>>> our build fails due to an unknown compiler flag:
>>> 
>>> error: unknown warning option '-Wstrict-null-sentinel'
>>> [-Werror,-Wunknown-warning-option]
>>> 
>>> Although we are checking whether the flag is accepted by the
>selected
>>> compiler. When I use the following statement:
>>> 
>>> 
>>>   CHECK_CXX_ACCEPTS_FLAG(${_cxxflag} HAS_FLAG)
>>> 
>>>   if(NOT HAS_FLAG)
>>> 
>>>     message("Flag check failure ${_cxxflag}")
>>> 
>>>   else()
>>> 
>>>     message("Flag ${_cxxflag} accepted")
>>> 
>>>   endif()
>>> 
>>> Cmake tells me that the '-Wstrict-null-sentinel' flag is accepted.
>Is
>>> this a bug in Cmake or am I doing something wrong?
>>> I use Cmake 2.8.8
>>> 
>>> Thanks in advance!
>>> 
>>> Best regards
>>> Andreas
>>> 
>>> 
>>> 
>>>
>------------------------------------------------------------------------
>>> 
>>> --
>>> 
>>> Powered by www.kitware.com
>>> 
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>> 
>>> Kitware offers various services to support the CMake community. For
>>> more information on each offering, please visit:
>>> 
>>> CMake Support: http://cmake.org/cmake/help/support.html
>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>> 
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>> 
>> Hi, 
>> 
>> the clang error message already tells you what other option are
>needed so that clang rejects unknown -W options: -Werror
>> 
>> HS
>> 
>> 
>> --
>> 
>> Powered by www.kitware.com
>> 
>> Please keep messages on-topic and check the CMake FAQ at:
>http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Kitware offers various services to support the CMake community. For
>more information on each offering, please visit:
>> 
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>> 
>> Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake

Hi,

clang -Werror -Wfoo
returns with non-zero error code but
clang -Wfoo
returns with error code 0.
The latter cannot be detected with the cmake method you use.



More information about the CMake mailing list