MantisBT - CMake
View Issue Details
0002582CMakeCMakepublic2005-12-09 15:422016-06-10 14:30
karl 
Kitware Robot 
lowfeaturealways
closedmoved 
 
 
0002582: Set XCode arguments from CMakeLists.txt
Is there a way to set the XCode internal variables from CMake? As a specific example, I have an application that uses the DYLD_LIBRARY_PATH to find shared libraries during development. XCode requires that the environment variable be set internally on the executable so that the executable can be run/debugged. I can set it within XCode but it gets lost everytime I rebuild the project with CMake. Is there anyway to set the DYLD_LIBRARY_PATH from my CMakeLists.txt?
No tags attached.
related to 0009125closed David Cole Add support to set GCC Version and Deployment Target for XCode projects 
Issue History
2007-08-17 13:33Gabriel BeaucheminNote Added: 0008503
2007-08-22 13:32Brad KingNote Added: 0008582
2007-08-22 13:45Brad KingNote Added: 0008583
2007-10-12 11:39Bill HoffmanAssigned ToBill Hoffman => Brad King
2007-10-12 13:45Sean McBrideNote Added: 0009451
2009-02-12 16:08karlNote Added: 0014917
2009-02-12 16:30Brad KingNote Added: 0014918
2011-02-08 14:34David ColeRelationship addedrelated to 0009125
2012-02-02 08:03Brad KingAssigned ToBrad King =>
2012-02-02 08:03Brad KingStatusassigned => backlog
2016-06-10 14:27Kitware RobotNote Added: 0041303
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:27Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0003396)
Bill Hoffman   
2005-12-12 11:31   
How do you set variables like that from the Xcode GUI?
What menu item do you use?
(0003398)
karl   
2005-12-12 11:48   
It took me a while to find out how to do this and my frustration level with XCode is fairly high right now (and it has _nothing_ to do with CMake!)

Expand the executable item in the Groups and Files window. Double click on the executable that is listed there. This will bring up a dialog box entitled "executable_name" info. Select the Arguments option from the top of the dialog. At the bottom of that pane you will see plus and minus symbols. Select plus to add a new environmental variable. Give the environment variable name and then click on the left hand side to set the variable.

The results of this action are saved in the .pbxuser file

               debuggerPlugin = GDBDebugging;
               disassemblyDisplayState = 0;
               dylibVariantSuffix = "";
               enableDebugStr = 1;
               environmentEntries = (
                        {
                                active = YES;
                                name = DYLD_LIBRARY_PATH;
                                value = "/Developer/qt-3.3.4/lib:/usr/local/eng_sci/cubit/verdict/verdict1.1.2/lib:/usr/local/eng_sci/cubit/VTK/VTK-4.2.2/bin
                        },
                );
                isa = PBXExecutable;
(0004594)
karl   
2006-08-01 16:48   
It looks like the location of the option has changed in XCode 2.2. I now find the arguments by selecting the menu option Project/Edit Active Executable and Selecting Arguments from the top of the resulting dialog.
(0008503)
Gabriel Beauchemin   
2007-08-17 13:33   
See 0001260' attachments for a possible solution. I added support for GCC_xxx to be passed as attributes. The same could be done for others

Gabriel
(0008582)
Brad King   
2007-08-22 13:32   
Gabriel's approach is to put the xcode "GCC_*" properties into the COMPILE_FLAGS target property and then parse them out in cmGlobalXCodeGenerator. We're trying to move away from putting everything in COMPILE_FLAGS in favor of other more specific target properties.

Perhaps we can come up with some form of target properties that get transformed into Xcode attributes.
(0008583)
Brad King   
2007-08-22 13:45   
Upon closer inspection I see that Gabriel's proposal does not solve the problem originally reported. The request in this issue is to set the environment variables under which programs are run through the IDE, not to set Xcode attributes.
(0009451)
Sean McBride   
2007-10-12 13:45   
FYI, relying on DYLD_LIBRARY_PATH is probably a bad idea, see:

http://docs.info.apple.com/article.html?artnum=305509 [^]
(0014917)
karl   
2009-02-12 16:08   
I realize that DYLD_LIBRARY_PATH is a nasty thing to do to a user . . . but I'm typically using this in a development environment while testing with a specific library version. This problem is still a pain.
(0014918)
Brad King   
2009-02-12 16:30   
Currently CMake only generates the "project.pbxproj" file and does not touch the .pbxuser file. If a user has loaded the project and adjusted preferences, we do not want to erase those changes by regenerating the pbxuser file. I don't think we should create a first-class CMake feature for this.

I suggest putting code in your CMakeLists.txt file to create the .pbxuser file yourself (perhaps only if it doesn't exist). Untested code:

set(pbxfile "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.xcodeproj/project.pbxuser")
if(NOT EXISTS "${pbxfile}")
  file(WRITE "${pbxfile}" "
...
")
endif()
(0041303)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.