diff options
author | Brad King <brad.king@kitware.com> | 2012-08-10 15:58:47 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-08-10 16:58:22 (GMT) |
commit | e88bae77c3388a5b474b081e572004f02772d162 (patch) | |
tree | a5d1b2819ec213c52aa7bc9c2dc7bea671ed0d41 /Source/cmGlobalXCodeGenerator.cxx | |
parent | 2c061d5cc9a380d1c8c9c16259a329db825e4a08 (diff) | |
download | CMake-e88bae77c3388a5b474b081e572004f02772d162.zip CMake-e88bae77c3388a5b474b081e572004f02772d162.tar.gz CMake-e88bae77c3388a5b474b081e572004f02772d162.tar.bz2 |
Xcode: Run xcode-select to find Xcode version file (#13463)
Multiple versions of Xcode may be installed in different locations.
Run "xcode-select --print-path" to detect the active Xcode location
and parse its Contents/version.plist file. Note that the Xcode.app
directory name may vary in developer versions.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 938977b..cbf4bea 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -136,8 +136,23 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New() { #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; - if (cmSystemTools::FileExists( - "/Applications/Xcode.app/Contents/version.plist")) + std::string versionFile; + { + std::string out; + std::string::size_type pos; + if(cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0, 0, + cmSystemTools::OUTPUT_NONE) && + (pos = out.find(".app/"), pos != out.npos)) + { + versionFile = out.substr(0, pos+5)+"Contents/version.plist"; + } + } + if(!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) + { + parser.ParseFile(versionFile.c_str()); + } + else if (cmSystemTools::FileExists( + "/Applications/Xcode.app/Contents/version.plist")) { parser.ParseFile ("/Applications/Xcode.app/Contents/version.plist"); |