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)
This commit is contained in:
commit
bfc8d137c5
@ -6,6 +6,8 @@ SET(APPLE 1)
|
|||||||
# 8.x == Mac OSX 10.4 (Tiger)
|
# 8.x == Mac OSX 10.4 (Tiger)
|
||||||
# 9.x == Mac OSX 10.5 (Leopard)
|
# 9.x == Mac OSX 10.5 (Leopard)
|
||||||
# 10.x == Mac OSX 10.6 (Snow Leopard)
|
# 10.x == Mac OSX 10.6 (Snow Leopard)
|
||||||
|
# 11.x == Mac OSX 10.7 (Lion)
|
||||||
|
# 12.x == Mac OSX 10.8 (Mountain Lion)
|
||||||
STRING(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_SYSTEM_VERSION}")
|
STRING(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_SYSTEM_VERSION}")
|
||||||
STRING(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_VERSION "${CMAKE_SYSTEM_VERSION}")
|
STRING(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" DARWIN_MINOR_VERSION "${CMAKE_SYSTEM_VERSION}")
|
||||||
|
|
||||||
@ -59,19 +61,24 @@ ENDIF(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
|||||||
# Set the assumed (Pre 10.5 or Default) location of the developer tools
|
# Set the assumed (Pre 10.5 or Default) location of the developer tools
|
||||||
SET(OSX_DEVELOPER_ROOT "/Developer")
|
SET(OSX_DEVELOPER_ROOT "/Developer")
|
||||||
|
|
||||||
# Find installed SDKs
|
# Use the xcode-select tool if it's available (Xcode >= 3.0 installations)
|
||||||
FILE(GLOB _CMAKE_OSX_SDKS "${OSX_DEVELOPER_ROOT}/SDKs/*")
|
FIND_PROGRAM(CMAKE_XCODE_SELECT xcode-select)
|
||||||
|
IF(CMAKE_XCODE_SELECT)
|
||||||
|
EXECUTE_PROCESS(COMMAND ${CMAKE_XCODE_SELECT} "-print-path"
|
||||||
|
OUTPUT_VARIABLE OSX_DEVELOPER_ROOT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
ENDIF(CMAKE_XCODE_SELECT)
|
||||||
|
|
||||||
# If nothing is found there, then try locating the dev tools based on the xcode-select tool
|
# Find installed SDKs
|
||||||
# (available in Xcode >= 3.0 installations)
|
# Start with Xcode-4.3+ default SDKs directory
|
||||||
|
SET(_CMAKE_OSX_SDKS_DIR
|
||||||
|
"${OSX_DEVELOPER_ROOT}/Platforms/MacOSX.platform/Developer/SDKs")
|
||||||
|
FILE(GLOB _CMAKE_OSX_SDKS "${_CMAKE_OSX_SDKS_DIR}/*")
|
||||||
|
|
||||||
|
# If not present, try pre-4.3 SDKs directory
|
||||||
IF(NOT _CMAKE_OSX_SDKS)
|
IF(NOT _CMAKE_OSX_SDKS)
|
||||||
FIND_PROGRAM(CMAKE_XCODE_SELECT xcode-select)
|
SET(_CMAKE_OSX_SDKS_DIR "${OSX_DEVELOPER_ROOT}/SDKs")
|
||||||
IF(CMAKE_XCODE_SELECT)
|
FILE(GLOB _CMAKE_OSX_SDKS "${_CMAKE_OSX_SDKS_DIR}/*")
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_XCODE_SELECT} "-print-path"
|
|
||||||
OUTPUT_VARIABLE OSX_DEVELOPER_ROOT
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
FILE(GLOB _CMAKE_OSX_SDKS "${OSX_DEVELOPER_ROOT}/SDKs/*")
|
|
||||||
ENDIF(CMAKE_XCODE_SELECT)
|
|
||||||
ENDIF(NOT _CMAKE_OSX_SDKS)
|
ENDIF(NOT _CMAKE_OSX_SDKS)
|
||||||
|
|
||||||
EXECUTE_PROCESS(COMMAND sw_vers -productVersion
|
EXECUTE_PROCESS(COMMAND sw_vers -productVersion
|
||||||
@ -103,16 +110,16 @@ SET(ENV_SDKROOT "$ENV{SDKROOT}")
|
|||||||
# Set CMAKE_OSX_SYSROOT_DEFAULT based on _CURRENT_OSX_VERSION,
|
# Set CMAKE_OSX_SYSROOT_DEFAULT based on _CURRENT_OSX_VERSION,
|
||||||
# accounting for the known specially named SDKs.
|
# accounting for the known specially named SDKs.
|
||||||
SET(CMAKE_OSX_SYSROOT_DEFAULT
|
SET(CMAKE_OSX_SYSROOT_DEFAULT
|
||||||
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX${_CURRENT_OSX_VERSION}.sdk")
|
"${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CURRENT_OSX_VERSION}.sdk")
|
||||||
|
|
||||||
IF(_CURRENT_OSX_VERSION STREQUAL "10.4")
|
IF(_CURRENT_OSX_VERSION STREQUAL "10.4")
|
||||||
SET(CMAKE_OSX_SYSROOT_DEFAULT
|
SET(CMAKE_OSX_SYSROOT_DEFAULT
|
||||||
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.4u.sdk")
|
"${_CMAKE_OSX_SDKS_DIR}/MacOSX10.4u.sdk")
|
||||||
ENDIF(_CURRENT_OSX_VERSION STREQUAL "10.4")
|
ENDIF(_CURRENT_OSX_VERSION STREQUAL "10.4")
|
||||||
|
|
||||||
IF(_CURRENT_OSX_VERSION STREQUAL "10.3")
|
IF(_CURRENT_OSX_VERSION STREQUAL "10.3")
|
||||||
SET(CMAKE_OSX_SYSROOT_DEFAULT
|
SET(CMAKE_OSX_SYSROOT_DEFAULT
|
||||||
"${OSX_DEVELOPER_ROOT}/SDKs/MacOSX10.3.9.sdk")
|
"${_CMAKE_OSX_SDKS_DIR}/MacOSX10.3.9.sdk")
|
||||||
ENDIF(_CURRENT_OSX_VERSION STREQUAL "10.3")
|
ENDIF(_CURRENT_OSX_VERSION STREQUAL "10.3")
|
||||||
|
|
||||||
# Use environment or default as initial cache value:
|
# Use environment or default as initial cache value:
|
||||||
|
@ -63,6 +63,12 @@ cmCPackDragNDropGenerator::~cmCPackDragNDropGenerator()
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int cmCPackDragNDropGenerator::InitializeInternal()
|
int cmCPackDragNDropGenerator::InitializeInternal()
|
||||||
{
|
{
|
||||||
|
// Starting with Xcode 4.3, look in "/Applications/Xcode.app" first:
|
||||||
|
//
|
||||||
|
std::vector<std::string> paths;
|
||||||
|
paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools");
|
||||||
|
paths.push_back("/Developer/Tools");
|
||||||
|
|
||||||
const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil",
|
const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil",
|
||||||
std::vector<std::string>(), false);
|
std::vector<std::string>(), false);
|
||||||
if(hdiutil_path.empty())
|
if(hdiutil_path.empty())
|
||||||
@ -75,7 +81,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
|||||||
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
|
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
|
||||||
|
|
||||||
const std::string setfile_path = cmSystemTools::FindProgram("SetFile",
|
const std::string setfile_path = cmSystemTools::FindProgram("SetFile",
|
||||||
std::vector<std::string>(1, "/Developer/Tools"), false);
|
paths, false);
|
||||||
if(setfile_path.empty())
|
if(setfile_path.empty())
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
@ -86,7 +92,7 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
|||||||
this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
|
this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
|
||||||
|
|
||||||
const std::string rez_path = cmSystemTools::FindProgram("Rez",
|
const std::string rez_path = cmSystemTools::FindProgram("Rez",
|
||||||
std::vector<std::string>(1, "/Developer/Tools"), false);
|
paths, false);
|
||||||
if(rez_path.empty())
|
if(rez_path.empty())
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
@ -355,24 +355,73 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
|
|||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
||||||
"cmCPackPackageMakerGenerator::Initialize()" << std::endl);
|
"cmCPackPackageMakerGenerator::Initialize()" << std::endl);
|
||||||
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
||||||
std::vector<std::string> path;
|
|
||||||
std::string pkgPath
|
// Starting with Xcode 4.3, PackageMaker is a separate app, and you
|
||||||
= "/Developer/Applications/Utilities/PackageMaker.app/Contents";
|
// can put it anywhere you want. So... use a variable for its location.
|
||||||
std::string versionFile = pkgPath + "/version.plist";
|
// People who put it in unexpected places can use the variable to tell
|
||||||
if ( !cmSystemTools::FileExists(versionFile.c_str()) )
|
// 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 = "/Developer/Applications/PackageMaker.app/Contents";
|
pkgPath = inst_program;
|
||||||
std::string newVersionFile = pkgPath + "/version.plist";
|
}
|
||||||
if ( !cmSystemTools::FileExists(newVersionFile.c_str()) )
|
else
|
||||||
|
{
|
||||||
|
pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
|
||||||
|
if ( pkgPath.empty() )
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
|
||||||
"Cannot find PackageMaker compiler version file: "
|
|
||||||
<< versionFile.c_str() << " or " << newVersionFile.c_str()
|
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
return 0;
|
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());
|
std::ifstream ifs(versionFile.c_str());
|
||||||
if ( !ifs )
|
if ( !ifs )
|
||||||
{
|
{
|
||||||
@ -380,6 +429,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
|
|||||||
"Cannot open PackageMaker compiler version file" << std::endl);
|
"Cannot open PackageMaker compiler version file" << std::endl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the PackageMaker version
|
// Check the PackageMaker version
|
||||||
cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
|
cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
|
||||||
cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
|
cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
|
||||||
@ -442,17 +492,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
|
|||||||
this->PackageCompatibilityVersion = 10.3;
|
this->PackageCompatibilityVersion = 10.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgPath += "/MacOS";
|
std::vector<std::string> no_paths;
|
||||||
path.push_back(pkgPath);
|
pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
|
||||||
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);
|
|
||||||
if ( pkgPath.empty() )
|
if ( pkgPath.empty() )
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
|
||||||
|
@ -135,8 +135,17 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New()
|
|||||||
{
|
{
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
cmXcodeVersionParser parser;
|
cmXcodeVersionParser parser;
|
||||||
parser.ParseFile
|
if (cmSystemTools::FileExists(
|
||||||
("/Developer/Applications/Xcode.app/Contents/version.plist");
|
"/Applications/Xcode.app/Contents/version.plist"))
|
||||||
|
{
|
||||||
|
parser.ParseFile
|
||||||
|
("/Applications/Xcode.app/Contents/version.plist");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parser.ParseFile
|
||||||
|
("/Developer/Applications/Xcode.app/Contents/version.plist");
|
||||||
|
}
|
||||||
cmsys::auto_ptr<cmGlobalXCodeGenerator>
|
cmsys::auto_ptr<cmGlobalXCodeGenerator>
|
||||||
gg(new cmGlobalXCodeGenerator(parser.Version));
|
gg(new cmGlobalXCodeGenerator(parser.Version));
|
||||||
if (gg->XcodeVersion == 20)
|
if (gg->XcodeVersion == 20)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user