summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-05-24 16:06:59 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-05-24 16:06:59 (GMT)
commit7147c3e1cc23953abc968e9502669ef7628de75c (patch)
tree77623c4e22a14c85452c3e0a9b8c3807795d0d32 /Source/cmCoreTryCompile.cxx
parent7d7aba292c09170fc9f145d68644e1ff6d158eec (diff)
downloadCMake-7147c3e1cc23953abc968e9502669ef7628de75c.zip
CMake-7147c3e1cc23953abc968e9502669ef7628de75c.tar.gz
CMake-7147c3e1cc23953abc968e9502669ef7628de75c.tar.bz2
ENH: add COPY_FILE argument to TRY_COMPILE, so the compiled executable can
be used e.g. for getting strings out of it. Alex
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 4b6e742..ee4fe97 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -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;
}