ENH: Cleanup global targets even more and potentially fix Xcode

This commit is contained in:
Andy Cedilnik 2006-03-01 08:28:39 -05:00
parent d231a422ed
commit 07260a6f27
5 changed files with 67 additions and 95 deletions

View File

@ -1214,6 +1214,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
{
cmMakefile* mf = m_LocalGenerators[0]->GetMakefile();
const char* cmakeCfgIntDir = this->GetCMakeCFGInitDirectory();
const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
// CPack
cmCustomCommandLines cpackCommandLines;
@ -1233,7 +1234,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
configFile += "/CPackConfig.cmake";
singleLine.push_back(configFile);
cpackCommandLines.push_back(singleLine);
if ( this->GetPreInstallAvailable() )
if ( this->GetPreinstallTargetName() )
{
depends.push_back("preinstall");
}
@ -1256,58 +1257,74 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
}
//Edit Cache
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
const char* editCacheTargetName = this->GetEditCacheTargetName();
if ( editCacheTargetName )
{
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
// Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined.
// Otherwise default to the interactive command-line interface.
if(mf->GetDefinition("CMAKE_EDIT_COMMAND"))
{
singleLine.push_back(mf->GetDefinition("CMAKE_EDIT_COMMAND"));
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
cpackCommandLines.push_back(singleLine);
(*targets)[this->GetEditCacheTargetName()] =
this->CreateGlobalTarget(
this->GetEditCacheTargetName(), "Running CMake cache editor...",
&cpackCommandLines, depends);
}
else
{
singleLine.push_back(cmakeCommand);
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
singleLine.push_back("-i");
cpackCommandLines.push_back(singleLine);
(*targets)[this->GetEditCacheTargetName()] =
this->CreateGlobalTarget(
this->GetEditCacheTargetName(), "Running interactive CMake command-line interface...",
&cpackCommandLines, depends);
// Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined.
// Otherwise default to the interactive command-line interface.
if(mf->GetDefinition("CMAKE_EDIT_COMMAND"))
{
singleLine.push_back(mf->GetDefinition("CMAKE_EDIT_COMMAND"));
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
cpackCommandLines.push_back(singleLine);
(*targets)[editCacheTargetName] =
this->CreateGlobalTarget(
editCacheTargetName, "Running CMake cache editor...",
&cpackCommandLines, depends);
}
else
{
singleLine.push_back(cmakeCommand);
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
singleLine.push_back("-i");
cpackCommandLines.push_back(singleLine);
(*targets)[editCacheTargetName] =
this->CreateGlobalTarget(
editCacheTargetName, "Running interactive CMake command-line interface...",
&cpackCommandLines, depends);
}
}
//Rebuild Cache
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
singleLine.push_back(cmakeCommand);
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
cpackCommandLines.push_back(singleLine);
(*targets)[this->GetRebuildCacheTargetName()] =
this->CreateGlobalTarget(
this->GetRebuildCacheTargetName(), "Running CMake to regenerate build system...",
&cpackCommandLines, depends);
const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName();
if ( rebuildCacheTargetName )
{
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
singleLine.push_back(cmakeCommand);
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
cpackCommandLines.push_back(singleLine);
(*targets)[rebuildCacheTargetName] =
this->CreateGlobalTarget(
rebuildCacheTargetName, "Running CMake to regenerate build system...",
&cpackCommandLines, depends);
}
//Install
std::string cmd;
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
if ( this->GetPreInstallAvailable() )
if ( this->GetPreinstallTargetName() )
{
depends.push_back("preinstall");
depends.push_back(this->GetPreinstallTargetName());
}
else
{
const char* noall =
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
depends.push_back(this->GetAllTargetName());
}
}
if(mf->GetDefinition("CMake_BINARY_DIR"))
{
@ -1330,15 +1347,6 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
singleLine.push_back("-P");
singleLine.push_back("cmake_install.cmake");
cpackCommandLines.push_back(singleLine);
/*
const char* noall =
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
bool dependsOnAll = false;
if(!noall || cmSystemTools::IsOff(noall))
{
dependsOnAll = true;
}
*/
(*targets)[this->GetInstallTargetName()] =
this->CreateGlobalTarget(
this->GetInstallTargetName(), "Install the project...",

View File

@ -171,13 +171,13 @@ protected:
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, bool depends_on_all = false);
virtual const char* GetAllTargetName() { return "ALL_BUILD"; }
virtual const char* GetInstallTargetName() { return "INSTALL"; }
virtual const char* GetPreinstallTargetName() { return "PREINSTALL"; }
virtual const char* GetPreinstallTargetName() { return 0; }
virtual const char* GetTestTargetName() { return "RUN_TESTS"; }
virtual const char* GetPackageTargetName() { return "PACKAGE"; }
virtual const char* GetEditCacheTargetName() { return "EDIT_CACHE"; }
virtual const char* GetRebuildCacheTargetName() { return "REBUILD_CACHE"; }
virtual bool GetPreInstallAvailable() { return false; }
virtual const char* GetEditCacheTargetName() { return 0; }
virtual const char* GetRebuildCacheTargetName() { return 0; }
bool m_ForceUnixPaths;
cmStdString m_FindMakeProgramFile;

View File

@ -120,14 +120,13 @@ protected:
bool NeedRequiresStep(cmLocalUnixMakefileGenerator3 *lg, const char *);
// Setup target names
virtual const char* GetAllTargetName() { return "all"; }
virtual const char* GetInstallTargetName() { return "install"; }
virtual const char* GetPreinstallTargetName() { return "preinstall"; }
virtual const char* GetTestTargetName() { return "test"; }
virtual const char* GetPackageTargetName() { return "package"; }
virtual const char* GetEditCacheTargetName() { return "edit_cache"; }
virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; }
virtual bool GetPreInstallAvailable() { return true; }
// Some make programs (Borland) do not keep a rule if there are no
// dependencies or commands. This is a problem for creating rules

View File

@ -283,45 +283,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
no_working_directory,
"echo", "Build all projects");
cmTarget* allbuild = mf->FindTarget("ALL_BUILD");
// ADD install
std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
if(m_XcodeVersion == 15)
{
mf->AddUtilityCommand("install", false, no_output, no_depends,
no_working_directory,
cmake_command.c_str(),
"-P", "cmake_install.cmake");
}
else
{
mf->AddUtilityCommand("install", false, no_output, no_depends,
no_working_directory,
cmake_command.c_str(),
"-DBUILD_TYPE=$(CONFIGURATION)",
"-P", "cmake_install.cmake");
}
const char* noall =
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
cmTarget* install = mf->FindTarget("install");
install->AddUtility("ALL_BUILD");
}
// Add RUN_TESTS target if testing has been enabled
std::string fname;
fname = mf->GetStartOutputDirectory();
fname += "/";
fname += "DartTestfile.txt";
if (cmSystemTools::FileExists(fname.c_str()))
{
std::string ctest_command =
mf->GetRequiredDefinition("CMAKE_CTEST_COMMAND");
mf->AddUtilityCommand("RUN_TESTS", false, no_output, no_depends,
no_working_directory,
ctest_command.c_str());
}
// Add XCODE depend helper
std::string dir = mf->GetCurrentOutputDirectory();
m_CurrentXCodeHackMakefile = dir;

View File

@ -151,6 +151,9 @@ private:
const char* varNameSuffix,
const char* default_flags);
protected:
virtual const char* GetInstallTargetName() { return "install"; }
virtual const char* GetPackageTargetName() { return "package"; }
int m_XcodeVersion;
std::vector<cmXCodeObject*> m_XCodeObjects;
cmXCodeObject* m_RootObject;