Hi all,  

I am working on Xcode with CMake's Xcode Generator and it works nicely.  

However, the Xcode Generator does not handle the -Ofast flag properly,  
and then it is necessary to the set Optimization Level manually  
when -Ofast flag is utilized in the project.  

This is because the Xcode Generator uses just one letter right after the `-O`  
to determine what the project setting should be.  
When `-O3` is given, `3` is used for Optimization Level and everything is fine, 
 
but when `-Ofast` is given, `f` is used for it, which is an invalid value.  

It is not tested but it can be resolved by accepting all letter after `-O` 
flags.  

Here is the relevant code handling Optimization Level:  
https://github.com/Kitware/CMake/blob/3ae8e84ef5c94e5fa250b4e2466aa6632a233bb2/Source/cmGlobalXCodeGenerator.cxx#L2218
  

The following is an example to reproduce this problem:  

-- CMakeLists.txt  
cmake_minimum_required(VERSION 3.2)  
add_executable(hello hello.c)  
target_compile_definitions(hello PRIVATE -Ofast)  
#target_compile_definitions(hello PRIVATE -O3)  

-- hello.c  
#include <stdio.h>  
int main(void)  
{  
  printf("hello world\n");  
  return 0;  
}  

-- Shell  
$ cd /path/to/project  
$ mkdir build; cd build  
$ cmake -G Xcode ..  
$ open Project.xcodeproj  

Then open the project setting on Xcode and show the setting of 'hello'  
Finally it is found that Optimization Level is -O0, not -Ofast  
When -O3 is specified, Optimization Level is set to -O3, correctly.  

I would appreciate any comments.  

Thank you for reading,  
Kaito  

--  
Signed-Off-By: Udagawa Kaito <[email protected]>  


-- 

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://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to