[cmake-commits] alex committed cmCoreTryCompile.cxx 1.1 1.2 cmTryCompileCommand.h 1.22 1.23 cmTryRunCommand.cxx 1.27 1.28

cmake-commits at cmake.org cmake-commits at cmake.org
Thu May 24 12:07:01 EDT 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv6617/Source

Modified Files:
	cmCoreTryCompile.cxx cmTryCompileCommand.h cmTryRunCommand.cxx 
Log Message:

ENH: add COPY_FILE argument to TRY_COMPILE, so the compiled executable can
be used e.g. for getting strings out of it.

Alex


Index: cmCoreTryCompile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCoreTryCompile.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmCoreTryCompile.cxx	24 May 2007 15:27:51 -0000	1.1
+++ cmCoreTryCompile.cxx	24 May 2007 16:06:59 -0000	1.2
@@ -90,6 +90,24 @@
       }
     }
 
+  // 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 @@
         "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 @@
   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;
 }

Index: cmTryCompileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTryCompileCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmTryCompileCommand.h	24 May 2007 15:27:51 -0000	1.22
+++ cmTryCompileCommand.h	24 May 2007 16:06:59 -0000	1.23
@@ -60,20 +60,22 @@
     {
     return
       "  TRY_COMPILE(RESULT_VAR bindir srcdir\n"
-      "              projectName <targetname> <CMAKE_FLAGS <Flags>>\n"
-      "              <OUTPUT_VARIABLE var>)\n"
+      "              projectName <targetname> [CMAKE_FLAGS <Flags>]\n"
+      "              [OUTPUT_VARIABLE var])\n"
       "Try compiling a program.  In this form, srcdir should contain a complete "
       "CMake project with a CMakeLists.txt file and all sources. The bindir and "
       "srcdir will not be deleted after this command is run. "
       "If <target name> is specified then build just that target "
       "otherwise the all or ALL_BUILD target is built.\n"
       "  TRY_COMPILE(RESULT_VAR bindir srcfile\n"
-      "              <CMAKE_FLAGS <Flags>>\n"
-      "              <COMPILE_DEFINITIONS <flags> ...>\n"
-      "              <OUTPUT_VARIABLE var>)\n"
+      "              [CMAKE_FLAGS <Flags>]\n"
+      "              [COMPILE_DEFINITIONS <flags> ...]\n"
+      "              [OUTPUT_VARIABLE var]\n"
+      "              [COPY_FILE <filename> )\n"
       "Try compiling a srcfile.  In this case, the user need only supply a "
       "source file.  CMake will create the appropriate CMakeLists.txt file "
-      "to build the source. "
+      "to build the source. If COPY_FILE is used, the compiled file will be"
+      "copied to the given file.\n"
       "In this version all files in bindir/CMakeFiles/CMakeTmp, "
       "will be cleaned automatically, for debugging a --debug-trycompile can "
       "be passed to cmake to avoid the clean. Some extra flags that "

Index: cmTryRunCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTryRunCommand.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmTryRunCommand.cxx	24 May 2007 15:27:51 -0000	1.27
+++ cmTryRunCommand.cxx	24 May 2007 16:06:59 -0000	1.28
@@ -76,7 +76,6 @@
   // now try running the command if it compiled
   if (!res)
     {
-      fprintf(stderr, "running %s\n", this->OutputFile.c_str());
     if (this->OutputFile.size() == 0)
       {
       cmSystemTools::Error(this->FindErrorMessage.c_str());



More information about the Cmake-commits mailing list