MantisBT - CMake
View Issue Details
0015641CMakeCMakepublic2015-07-08 09:272016-01-04 11:51
Nikolay Zapolnov 
Brad King 
normalmajoralways
closedfixed 
AppleOSX10.10.4
CMake 3.2.3 
CMake 3.3CMake 3.3 
0015641: In CMake 3.3.0-rc3 macro CHECK_CXX_COMPILER_FLAG is broken on OSX for some flags
In CMake 3.2.3 the CHECK_CXX_COMPILER_FLAG macro launches compiler and then linker.
But tested flag is passed *only* to the compiler and test passes.

But in CMake 3.3.0-rc3 argument is passed to *both* the compiler and the linker. This causes an error for some flags, for example for '-x objective-c++'. Passing this flag to the linker makes it recognize .o files as objective-c++ sources and fail.
Use the following CMakeLists.txt

INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-x objective-c++" HAVE_OBJC)

This will work correctly in CMake 3.2.3 but in CMake 3.3.0-rc3 HAVE_OBJC will be always false.
Part of CMakeOutput.log for good case and part of CMakeError.log for broken case are attached to the ticket.
No tags attached.
log good-cmake322.log (1,364) 2015-07-08 09:27
https://public.kitware.com/Bug/file/5483/good-cmake322.log
log broken-cmake330rc3.log (1,201,657) 2015-07-08 09:27
https://public.kitware.com/Bug/file/5484/broken-cmake330rc3.log
Issue History
2015-07-08 09:27Nikolay ZapolnovNew Issue
2015-07-08 09:27Nikolay ZapolnovFile Added: good-cmake322.log
2015-07-08 09:27Nikolay ZapolnovFile Added: broken-cmake330rc3.log
2015-07-08 10:01Brad KingNote Added: 0039086
2015-07-08 10:01Brad KingAssigned To => Brad King
2015-07-08 10:01Brad KingStatusnew => assigned
2015-07-08 10:01Brad KingTarget Version => CMake 3.3
2015-07-08 10:07Brad KingNote Added: 0039087
2015-07-08 10:07Brad KingStatusassigned => resolved
2015-07-08 10:07Brad KingResolutionopen => fixed
2015-07-08 10:07Brad KingFixed in Version => CMake 3.3
2016-01-04 11:51Robert MaynardNote Added: 0040089
2016-01-04 11:51Robert MaynardStatusresolved => closed

Notes
(0039086)
Brad King   
2015-07-08 10:01   
Thanks for testing the release candidate!

This problem was introduced by the patch posted here:

 [PATCH] fix use of CMAKE_REQUIRED_DEFINITIONS
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/12520 [^]

and committed here:

 Check*CompilerFlag: Refactor method used to pass flags
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5d5067ae [^]

We'll have to revert it and add a test case for compiler-only flags.
(0039087)
Brad King   
2015-07-08 10:07   
Fixed and test case added:

 Check*CompilerFlag: Revert to previous method used to pass flags
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a639689c [^]

I've queued this for merge to the 'release' branch for 3.3.
(0040089)
Robert Maynard   
2016-01-04 11:51   
Closing resolved issues that have not been updated in more than 4 months.