[cmake-developers] [CMake 0015794]: The Xcode generator consumes all arguments beginning with "-O" even when they're not optimization flags.
Mantis Bug Tracker
mantis at public.kitware.com
Thu Oct 15 13:12:05 EDT 2015
The following issue has been SUBMITTED.
======================================================================
https://cmake.org/Bug/view.php?id=15794
======================================================================
Reported By: Davy Durham
Assigned To:
======================================================================
Project: CMake
Issue ID: 15794
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2015-10-15 13:12 EDT
Last Modified: 2015-10-15 13:12 EDT
======================================================================
Summary: 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
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2015-10-15 13:12 Davy Durham New Issue
======================================================================
More information about the cmake-developers
mailing list