MantisBT - CMake
View Issue Details
0015225CMakeCMakepublic2014-10-28 13:422015-04-06 09:07
Ilya 
Brad King 
normalmajoralways
closedfixed 
AppleMac OS X10.10
CMake 3.0.2 
CMake 3.1CMake 3.1 
0015225: Clarify add_compile_options command documentation
The flags specified via add_compile_options do not appear anywhere in generated Xcode project (I use Xcode 6)

In other hand, options specified via the add_definitions command will be properly placed under the OTHER_CFLAGS Xcode attribute. Moreover, generator seems to categorize these flags and put them under appropriate Xcode attributes.

E.g.

    add_definitions(
        -DHAVE_PTHREADS
        -Wduplicate-method-match
    )

-DHAVE_PTHREADS will be added to the GCC_PREPROCESSOR_DEFINITIONS Xcode attribute while -Wduplicate-method-match will be added to the OTHER_CFLAGS Xcode attribute.
No tags attached.
zip TestCMake.zip (100,266) 2014-10-28 16:23
https://public.kitware.com/Bug/file/5286/TestCMake.zip
Issue History
2014-10-28 13:42IlyaNew Issue
2014-10-28 14:12Brad KingNote Added: 0037089
2014-10-28 16:23IlyaFile Added: TestCMake.zip
2014-10-28 16:24IlyaNote Added: 0037090
2014-10-28 18:19Nils GladitzNote Added: 0037094
2014-10-29 09:23Brad KingNote Added: 0037098
2014-10-29 09:23Brad KingTarget Version => CMake 3.2
2014-10-29 09:23Brad KingSummaryXcode generator ignores the add_compile_options command => Clarify add_compile_options command documentation
2014-10-29 13:18IlyaNote Added: 0037101
2014-10-29 14:49Brad KingNote Added: 0037103
2014-10-29 15:16IlyaNote Added: 0037104
2014-10-29 15:25Brad KingNote Added: 0037105
2014-10-30 14:20Brad KingStatusnew => resolved
2014-10-30 14:20Brad KingResolutionopen => fixed
2014-10-30 14:20Brad KingFixed in Version => CMake 3.2
2014-10-31 11:41Brad KingAssigned To => Brad King
2014-10-31 11:41Brad KingFixed in VersionCMake 3.2 => CMake 3.1
2014-10-31 11:41Brad KingTarget VersionCMake 3.2 => CMake 3.1
2015-04-06 09:07Robert MaynardNote Added: 0038435
2015-04-06 09:07Robert MaynardStatusresolved => closed

Notes
(0037089)
Brad King   
2014-10-28 14:12   
I cannot reproduce this. Our test suite covers add_compile_options and passes on Xcode.

Please provide an example CMakeLists.txt that shows the failure.
(0037090)
Ilya   
2014-10-28 16:24   
I uploaded both CMakeLists.txt and generated Xcode project.
(0037094)
Nils Gladitz   
2014-10-28 18:19   
add_compile_options() populates the COMPILE_OPTIONS directory property.

When a target is created (e.g. add_executable()) these options are copied into the COMPILE_OPTIONS target property.

The attached test project sets the options after the target has been created which is why they don't take effect.
(0037098)
Brad King   
2014-10-29 09:23   
Re 0015225:0037094: Correct. However, it looks like the documentation could be clearer on this. Updated:

 Help: Clarify add_compile_options documentation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a9f8c50a [^]
(0037101)
Ilya   
2014-10-29 13:18   
But it seems to work for add_definitions. I though add_compile_options is just a specific version of add_definitions. Why does it work in one case but not in the other?
(0037103)
Brad King   
2014-10-29 14:49   
Re 0015225:0037101: add_definitions was one of the earliest commands so its behavior has been kept for compatibility. The add_compile_options command is quite new and uses what we've learned from experience over the years. It is better for a target to use directory-level settings to initialize its main build properties upon creation but then not pay attention to them anymore. That way a target can be modified independent of further directory-level settings with the target_* commands or direct target property settings.
(0037104)
Ilya   
2014-10-29 15:16   
If you're going to maintain this compatibility it would make sense to specify it command description.
(0037105)
Brad King   
2014-10-29 15:25   
Re 0015225:0037104: I've updated the add_definitions docs:

 Help: Reference add_compile_options from add_definitions
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=352cbb6e [^]
(0038435)
Robert Maynard   
2015-04-06 09:07   
Closing resolved issues that have not been updated in more than 4 months.