MantisBT - CMake
View Issue Details
0013802CMakeCMakepublic2012-12-19 07:212013-05-06 09:32
tzeH 
 
normalminoralways
closedduplicate 
 
 
0013802: set_property doesn't work for CMAKE_XCODE_ATTRIBUTE_
These two things don't do the same although they should:

set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
set_property(GLOBAL PROPERTY CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")

The first line works, the second line doesn't.
The code for this is in cmGlobalXCodeGenerator.cxx:

void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
                                                 cmXCodeObject* buildSettings,
                                                 const char* configName)
{
...
cmPropertyMap const& props = target.GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
{
  if(i->first.find("XCODE_ATTRIBUTE_") == 0)
  {
    buildSettings->AddAttribute(i->first.substr(16).c_str(), this->CreateString(i->second.GetValue()));
  }
}
...
}

I don't know enough about the objects and classes involved, but it seems there is something wrong here and I hope this pointer will help to fix it.
No tags attached.
duplicate of 0009831closed Brad King Need method to set properties on every target / set defaults 
Issue History
2012-12-19 07:21tzeHNew Issue
2012-12-19 08:36Brad KingNote Added: 0031925
2012-12-19 09:29tzeHNote Added: 0031926
2012-12-19 13:13Brad KingNote Added: 0031927
2012-12-20 11:01Brad KingRelationship addedduplicate of 0009831
2012-12-20 11:02Brad KingNote Added: 0031932
2012-12-20 11:02Brad KingStatusnew => resolved
2012-12-20 11:02Brad KingResolutionopen => duplicate
2013-05-06 09:32Robert MaynardNote Added: 0032991
2013-05-06 09:32Robert MaynardStatusresolved => closed

Notes
(0031925)
Brad King   
2012-12-19 08:36   
There is no global property for XCODE_ATTRIBUTE_. It is a target property:

 http://www.cmake.org/cmake/help/v2.8.10/cmake.html#prop_tgt:XCODE_ATTRIBUTE_an-attribute [^]

It looks like your real goal is to select the toolchain in an Xcode project. In issue 0013774 there is work in progress to add support for selecting the toolchain in the VS IDE for VS >= 10. The approach has been designed to be general enough to allow support for Xcode toolchain selection to be added too.
(0031926)
tzeH   
2012-12-19 09:29   
Aah, okay! What I wanted to achieve is to set a property for all targets (before they are even defined) and then customize a single target with it's own settings later.

My first approach was to use

set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")

followed by

set_target_property( ProjectName PROPERTY CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.gcc42")

but that didn't work: I had llvm for "ProjectName", too.

After experimenting I was under the (now obv. wrong) impression, that "GLOBAL" would simply set the property for everything, which I could later override with set_target_property.

Do you know a different way to realize this? (I just need this to tweak per-project optimization and, in this case, compiler settings.)

Cheers!
(0031927)
Brad King   
2012-12-19 13:13   
There is no global equivalent for the XCODE_ATTRIBUTE_ target properties AFAIK. They are meant as a last resort, not a first-class feature. Ideally CMake should be taught to generate project files with whatever you need.

In order to fully use a non-default toolchain a lot more changes are needed than just setting the attribute for each target in the project itself. For example, CMake generates test projects for try_compile calls. All such places would need to be taught to use the specific compiler or the results would be inconsistent. This is what the ongoing work in 0013774 is trying to do for VS. It shouldn't be hard to extend it for Xcode too.
(0031932)
Brad King   
2012-12-20 11:02   
Resolving as duplicate of 0009831 which asks for the same feature for the same purpose.
(0032991)
Robert Maynard   
2013-05-06 09:32   
Closing resolved issues that have not been updated in more than 4 months.