diff options
author | Brad King <brad.king@kitware.com> | 2012-03-19 18:41:43 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-03-19 18:41:43 (GMT) |
commit | bfc8d137c5ff505717f71099f149cfc2682b76ec (patch) | |
tree | 7dde1d714033d64c3808f5c295d883a17faae7a1 /Source/CPack/cmCPackPackageMakerGenerator.cxx | |
parent | 572994bd9f8ea77c3101f0b019b693c37b0d502e (diff) | |
parent | 0f4dfa6960e51b7460b91f828932a42d5827467a (diff) | |
download | CMake-bfc8d137c5ff505717f71099f149cfc2682b76ec.zip CMake-bfc8d137c5ff505717f71099f149cfc2682b76ec.tar.gz CMake-bfc8d137c5ff505717f71099f149cfc2682b76ec.tar.bz2 |
Merge topic 'fix-12621-xcode43'
0f4dfa6 CPack: Use real path to PackageMaker to find its version file (#12621)
4693cf8 Xcode: Detect new default locations of Xcode 4.3 bits and pieces (#12621)
Diffstat (limited to 'Source/CPack/cmCPackPackageMakerGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 87 |
1 files changed, 64 insertions, 23 deletions
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 327c4a6..3a0e89b 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -355,24 +355,73 @@ int cmCPackPackageMakerGenerator::InitializeInternal() cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPackageMakerGenerator::Initialize()" << std::endl); this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); - std::vector<std::string> path; - std::string pkgPath - = "/Developer/Applications/Utilities/PackageMaker.app/Contents"; - std::string versionFile = pkgPath + "/version.plist"; - if ( !cmSystemTools::FileExists(versionFile.c_str()) ) + + // Starting with Xcode 4.3, PackageMaker is a separate app, and you + // can put it anywhere you want. So... use a variable for its location. + // People who put it in unexpected places can use the variable to tell + // us where it is. + // + // Use the following locations, in "most recent installation" order, + // to search for the PackageMaker app. Assume people who copy it into + // the new Xcode 4.3 app in "/Applications" will copy it into the nested + // Applications folder inside the Xcode bundle itself. Or directly in + // the "/Applications" directory. + // + // If found, save result in the CPACK_INSTALLER_PROGRAM variable. + + std::vector<std::string> paths; + paths.push_back( + "/Applications/Xcode.app/Contents/Applications" + "/PackageMaker.app/Contents/MacOS"); + paths.push_back( + "/Applications/Utilities" + "/PackageMaker.app/Contents/MacOS"); + paths.push_back( + "/Applications" + "/PackageMaker.app/Contents/MacOS"); + paths.push_back( + "/Developer/Applications/Utilities" + "/PackageMaker.app/Contents/MacOS"); + paths.push_back( + "/Developer/Applications" + "/PackageMaker.app/Contents/MacOS"); + + std::string pkgPath; + const char *inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM"); + if (inst_program && *inst_program) + { + pkgPath = inst_program; + } + else { - pkgPath = "/Developer/Applications/PackageMaker.app/Contents"; - std::string newVersionFile = pkgPath + "/version.plist"; - if ( !cmSystemTools::FileExists(newVersionFile.c_str()) ) + pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false); + if ( pkgPath.empty() ) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot find PackageMaker compiler version file: " - << versionFile.c_str() << " or " << newVersionFile.c_str() + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler" << std::endl); return 0; } - versionFile = newVersionFile; + this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); } + + // Get path to the real PackageMaker, not a symlink: + pkgPath = cmSystemTools::GetRealPath(pkgPath.c_str()); + // Up from there to find the version.plist file in the "Contents" dir: + std::string contents_dir; + contents_dir = cmSystemTools::GetFilenamePath(pkgPath); + contents_dir = cmSystemTools::GetFilenamePath(contents_dir); + + std::string versionFile = contents_dir + "/version.plist"; + + if ( !cmSystemTools::FileExists(versionFile.c_str()) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find PackageMaker compiler version file: " + << versionFile.c_str() + << std::endl); + return 0; + } + std::ifstream ifs(versionFile.c_str()); if ( !ifs ) { @@ -380,6 +429,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal() "Cannot open PackageMaker compiler version file" << std::endl); return 0; } + // Check the PackageMaker version cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>"); cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>"); @@ -442,17 +492,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal() this->PackageCompatibilityVersion = 10.3; } - pkgPath += "/MacOS"; - path.push_back(pkgPath); - pkgPath = cmSystemTools::FindProgram("PackageMaker", path, false); - if ( pkgPath.empty() ) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler" - << std::endl); - return 0; - } - this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); - pkgPath = cmSystemTools::FindProgram("hdiutil", path, false); + std::vector<std::string> no_paths; + pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false); if ( pkgPath.empty() ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" |