View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015794 | CMake | CMake | public | 2015-10-15 13:12 | 2016-03-07 09:12 | ||||
Reporter | Davy Durham | ||||||||
Assigned To | Gregor Jasny | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | Xcode generator | OS | OS Version | ||||||
Product Version | CMake 3.0 | ||||||||
Target Version | CMake 3.5 | Fixed in Version | CMake 3.5 | ||||||
Summary | 0015794: The Xcode generator consumes all arguments beginning with "-O" even when they're not optimization flags. | ||||||||
Description | cmake, when generating Xcode projects, attempts to translate optimization (i.e. arguments starting with -O…) flags into the proper Xcode project file setting. In doing so, it removes all arguments beginning with "-O" from the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS variables and they do not get passed to the OTHER_CPLUSPLUSFLAGS and OTHER_CFLAGS values in the Xcode project. However flags such as "-ObjC" and "-ObjC++" get incorrectly stripped out of the generated project. I have attached a patch file that addresses the issue by ignoring arguments that begin with -O which are longer than 3 characters. (two files, one for cmake-3.1 and the other for git master) | ||||||||
Steps To Reproduce | For a CMakeLists.txt file containing: cmake_minimum_required(VERSION 3.0.2) project(foo) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ObjC++") add_executable(foo foo.cpp) running: cmake -G Xcode <path> results in a generated foo.xcodeproj/project.pbxproj file This file's OTHER_CPLUSPLUSFLAGS= value ought to contain -ObjC++, but it does not. | ||||||||
Additional Information | One can work around the issue by adding adding quotes around the argument which Xcode strips off but cmake doesn't check for (it technically should.. another bug?) Example: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \"-ObjC++\"") This is a fragile work around and may not work as it currently does in future versions of cmake and Xcode | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | cmake3_1-xcode-optimize-arg-fix.patch [^] (3,307 bytes) 2015-10-15 13:13 [Show Content]
0001-Fixed-an-issue-where-the-Xcode-generated-was-clobber.patch [^] (3,528 bytes) 2015-10-15 13:13 [Show Content] | ||||||||
Relationships | |
Relationships |
Notes | |
(0039621) Brad King (manager) 2015-10-15 15:06 |
Associated mailing list thread: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14732 [^] |
(0039625) Gregor Jasny (developer) 2015-10-18 16:55 |
Hello Davy, thank you for the bug report and the patch. Unfortunately your approach does not work with the (currently broken) handling for -Ofast. I took another route via a regular expression for the flags. I pushed my current work to the xcode-optimization-flags branch. This topic branch should fix the error but lacks some additional tests (e.g. for your -ObjC flags). Thanks, Gregor PS: Topic is here: https://cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/xcode-optimization-flags [^] |
(0039635) Davy Durham (reporter) 2015-10-19 11:40 |
Yep, I see that it never handled -Ofast properly. Your approach is probably the best it can be (a whitelist of expected values following -O, else preserve as an additional flag). Thanks |
(0039647) Brad King (manager) 2015-10-19 15:52 |
Thanks Gregor. The regex: "-Ofast|-Os|-O[0-9]*" could be something like "(^| )(-Ofast|-Os|-O[0-9]*)( |$)" to avoid the boundary checks in the C++ code. Then just use the proper match index to get the content. |
(0039654) Ching Ping Sun (reporter) 2015-10-20 08:48 |
Hi,Gregor, I found the option begins with "-g", for example: "-gline-tables-only" has the same situation.(being consumed without output). Do I have to fire another issue or just report here? |
(0039657) Gregor Jasny (developer) 2015-10-20 16:30 |
Ching Ping Sun, please file a new issue for this. -g handling is much more complex than optimisation level. |
(0039658) Gregor Jasny (developer) 2015-10-20 16:52 |
I merged the topic branch to next for testing. |
(0039684) Brad King (manager) 2015-10-27 13:26 |
The fix has been integrated here: Xcode: Use regular expression to extract all optimisation flags https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=601e6e1a [^] |
(0040626) Robert Maynard (manager) 2016-03-07 09:12 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2015-10-15 13:12 | Davy Durham | New Issue | |
2015-10-15 13:13 | Davy Durham | File Added: cmake3_1-xcode-optimize-arg-fix.patch | |
2015-10-15 13:13 | Davy Durham | File Added: 0001-Fixed-an-issue-where-the-Xcode-generated-was-clobber.patch | |
2015-10-15 13:28 | Brad King | Assigned To | => Gregor Jasny |
2015-10-15 13:28 | Brad King | Status | new => assigned |
2015-10-15 13:28 | Brad King | Target Version | => CMake 3.5 |
2015-10-15 15:06 | Brad King | Note Added: 0039621 | |
2015-10-18 16:55 | Gregor Jasny | Note Added: 0039625 | |
2015-10-19 11:40 | Davy Durham | Note Added: 0039635 | |
2015-10-19 15:52 | Brad King | Note Added: 0039647 | |
2015-10-20 08:48 | Ching Ping Sun | Note Added: 0039654 | |
2015-10-20 16:30 | Gregor Jasny | Note Added: 0039657 | |
2015-10-20 16:52 | Gregor Jasny | Note Added: 0039658 | |
2015-10-27 13:26 | Brad King | Note Added: 0039684 | |
2015-10-27 13:27 | Brad King | Status | assigned => resolved |
2015-10-27 13:27 | Brad King | Resolution | open => fixed |
2015-10-27 13:27 | Brad King | Fixed in Version | => CMake 3.5 |
2016-03-07 09:12 | Robert Maynard | Note Added: 0040626 | |
2016-03-07 09:12 | Robert Maynard | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |