[cmake-developers] [CMake 0015526]: check_c_compiler_flag gives wrong answer on Mac

Mantis Bug Tracker mantis at public.kitware.com
Tue Apr 21 19:37:57 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15526 
====================================================================== 
Reported By:                Dan Kegel
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15526
Category:                   Modules
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-04-21 19:37 EDT
Last Modified:              2015-04-21 19:37 EDT
====================================================================== 
Summary:                    check_c_compiler_flag gives wrong answer on Mac
Description: 
Per
http://stackoverflow.com/questions/26108606/no-support-to-finline-functions-in-clang-3-5
XCode 6 has dropped support for -finline-functions:

$ clang -finline-functions -c foo.c -Werror
clang: error: optimization flag '-finline-functions' is not supported

so projects that use -Werror must not use that flag.

But check_c_compiler_flag doesn't use -Werror, and the output:
$ clang -finline-functions -c foo.c
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
sails right by its regex, so the flag is listed as supported.  D'oh.


Steps to Reproduce: 
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
include(CheckCCompilerFlag)
check_c_compiler_flag(-finline-functions FOOBARC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-finline-functions FOOBARCXX)
$ cmake
-- The C compiler identification is AppleClang 6.1.0.6020049
-- The CXX compiler identification is AppleClang 6.1.0.6020049
-- Performing Test FOOBARC
-- Performing Test FOOBARC - Success
-- Performing Test FOOBARCXX
-- Performing Test FOOBARCXX - Success

But I expected 'Failed', not success, as that flag is not really supported and
will cause build error if used with -Werror.

Additional Information: 
Patch sent to cmake-developers, but I guess I'm not subscribed yet, so I'll
attach it here too.

Also affects older versions of cmake.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-04-21 19:37 Dan Kegel      New Issue                                    
2015-04-21 19:37 Dan Kegel      File Added: opt.patch                        
======================================================================



More information about the cmake-developers mailing list