MantisBT - CMake
View Issue Details
0013408CMakeCMakepublic2012-07-17 13:322013-03-04 08:38
Sean McBride 
Brad King 
normalmajoralways
closedfixed 
MacOS X10.7
CMake 2.8.8 
CMake 2.8.10CMake 2.8.10 
0013408: CMake should support default installation of Xcode.app only, without 'command line tools' extras
Nowadays, Xcode is distributed as a standalone .app instead of an installer that copies files all over the place. As a consequence of this, nothing gets installed at /usr/bin/make, /usr/bin/cc, etc. Those programs are still included, just not at those locations; instead, they are within the Xcode.app bundle somewhere.

Optionally, one can install a separate 'command line tools' package that places things at those venerable locations. Without installing that, one can still find and use 'make' and other tools using 'xcrun' (see 'man xcrun'). ex:

$ xcrun make --version
GNU Make 3.81

$ xcrun -find make
/Applications/Xcode.app/Contents/Developer/usr/bin/make

Without the 'command line tools' installed, CMake seems unable to get far:

Error(s) when configuring the project
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.

It would be nice if CMake could support having only Xcode.app and not the 'command line tools' extras.

Suggestions:
 - invoke 'xcrun -find' to find the paths to the tools it needs.
 - invoke 'xcrun <tool name>' to invoke the tool.
No tags attached.
Issue History
2012-07-17 13:32Sean McBrideNew Issue
2012-07-17 13:48David ColeNote Added: 0030061
2012-07-17 13:49David ColeNote Edited: 0030061bug_revision_view_page.php?bugnote_id=30061#r748
2012-07-17 14:20Sean McBrideNote Added: 0030062
2012-07-17 16:22David ColeNote Added: 0030065
2012-07-17 17:33Sean McBrideNote Added: 0030066
2012-08-09 17:58Jerry KrinockNote Added: 0030203
2012-08-15 16:43Brad KingNote Added: 0030679
2012-09-21 11:45Brad KingNote Added: 0031080
2012-09-21 11:45Brad KingAssigned To => Brad King
2012-09-21 11:45Brad KingStatusnew => resolved
2012-09-21 11:45Brad KingResolutionopen => fixed
2012-09-21 11:45Brad KingFixed in Version => CMake 2.8.10
2012-09-21 11:45Brad KingTarget Version => CMake 2.8.10
2013-03-04 08:38Robert MaynardNote Added: 0032457
2013-03-04 08:38Robert MaynardStatusresolved => closed

Notes
(0030061)
David Cole   
2012-07-17 13:48   
(edited on: 2012-07-17 13:49)
Another alternative might be simply to add "/Applications/Xcode.app/Contents/Developer/usr/bin" to the PATH environment variable prior to calling CMake.

That way, it should find make and all the other stuff in that bin directory just as easily as it finds it in "/usr/bin".

Try this in a command prompt before calling CMake:

  export PATH=/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH

If that works, you could simply permanently make such a change in your ~/.bash_profile

(0030062)
Sean McBride   
2012-07-17 14:20   
David, that could be a partial/temporary solution, but:

- nothing requires Xcode.app to be in /Applications
- Xcode.app might be named differently, recent betas are named, for example "Xcode45-DP2.app"
- one can have multiple copies of Xcode.app. One of them is 'blessed' as 'the' Xcode using xcode-select. 'xcrun -find' resolves according to which is blessed. ex, on my system now:

$ sudo xcode-select -switch /Applications/Xcode45-DP2.app

$ xcrun -find make
/Applications/Xcode45-DP2.app/Contents/Developer/usr/bin/make

$ sudo xcode-select -switch /Applications/Xcode44-DP7.app

$ xcrun -find make
/Applications/Xcode44-DP7.app/Contents/Developer/usr/bin/make

Still, most will have only one Xcode.app and it will likely be in /Applications, so if your idea is much faster/easier I'd say go for it. Instead of hardcoding, would it be hard to extend your idea to use the output of:

$ xcode-select -print-path
/Applications/Xcode44-DP7.app/Contents/Developer
(0030065)
David Cole   
2012-07-17 16:22   
I think you missed the point of my note. My suggestion is for users to do something so that CMake does not even have to be changed.

I'm suggesting that users modify their own PATH whenever they modify the "selected Xcode" and this way CMake has nothing to do.

No change should be required to do this, unless there's something beyond PATH that also needs to be changed.

Does CMake work with the Xcode generator without the command line tools installed? Or is there a problem with that as well?
(0030066)
Sean McBride   
2012-07-17 17:33   
Indeed I read too fast.

I've removed the 'command line tools' from Rogue11, changed my PATH, and we'll see on tomorrow's dashboard.
(0030203)
Jerry Krinock   
2012-08-09 17:58   
Although not requiring installation of Xcode's command-line tools would be nice, at a minimum, CMake's runtime, or at least its installer, should check for any needed prerequisites and inform the user if a prerequisite is missing. I've spent several hours in the last few days trying to figure out why CMake 2.8.8 just wouldn't work on a new Mac, until someone pointed out to me that it was necessary to install Xcode's command-line tools. The error messages I received from CMake just added to the confusion.
(0030679)
Brad King   
2012-08-15 16:43   
I was able to build CMake and run the tests with Xcode 4.4 on OS X 10.8 without installing the command line tools. Source the following bash code into your shell to set up the environment:

SDK="$(xcodebuild -sdk macosx -version Path)" &&
export PATH="$(dirname $(xcrun --find make)):$PATH" &&
export CC="$(xcrun --find cc)" &&
export CXX="$(xcrun --find c++)" &&
export CFLAGS="-isysroot $SDK" &&
export CXXFLAGS="-isysroot $SDK" &&
unset SDK


Then just run "cmake" and "make" as normal.
(0031080)
Brad King   
2012-09-21 11:45   
The following two commits address this (after some other cleanup):

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a0a0877a [^]
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=230ea218 [^]

Now CMake will always verify that the SDKs directory exists before using it. If not it will fall back to an empty value for CMAKE_OSX_SYSROOT. This allows one to build with just the command line tools for Xcode 4.5 but not the IDE.

Furthermore when CMAKE_OSX_SYSROOT is not empty then CMake will always use the -isysroot flag if the compiler supports it. One may now build with Xcode 4.4 without the command-line tools, even using the Makefile generator, by setting the environment as:

export PATH="$(dirname $(xcrun --find make)):$PATH"
export CC="$(xcrun --find cc)"
export CXX="$(xcrun --find c++)"

(0032457)
Robert Maynard   
2013-03-04 08:38   
Closing resolved issues that have not been updated in more than 4 months.