ENH: add COPY_FILE argument to TRY_COMPILE, so the compiled executable can

be used e.g. for getting strings out of it.

Alex
This commit is contained in:
Alexander Neundorf
2007-05-24 12:06:59 -04:00
parent 7d7aba292c
commit 7147c3e1cc
4 changed files with 50 additions and 8 deletions
+32
View File
@@ -90,6 +90,24 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
}
}
// look for COPY_FILE
std::string copyFile;
for (i = 3; i < argv.size(); ++i)
{
if (argv[i] == "COPY_FILE")
{
if ( argv.size() <= (i+1) )
{
cmSystemTools::Error(
"COPY_FILE specified but there is no variable");
return -1;
}
extraArgs += 2;
copyFile = argv[i+1];
break;
}
}
// do we have a srcfile signature
if (argv.size() - extraArgs == 3)
{
@@ -112,6 +130,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
"COMPILE_FLAGS specified on a srcdir type TRY_COMPILE");
return -1;
}
if (copyFile.size())
{
cmSystemTools::Error("COPY_FILE specified on a srcdir type TRY_COMPILE");
return -1;
}
}
// make sure the binary directory exists
cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str());
@@ -262,6 +285,15 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if (this->SrcFileSignature)
{
this->FindOutputFile(targetName);
if ((res==0) && (copyFile.size()))
{
if(!cmSystemTools::CopyFileAlways(this->OutputFile.c_str(),
copyFile.c_str()))
{
cmSystemTools::Error("Could not COPY_FILE");
return -1;
}
}
}
return res;
}