[Cmake-commits] CMake branch, next, updated. v2.8.11-1982-gf4d3fa6

Stephen Kelly steveire at gmail.com
Thu May 16 13:54:13 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  f4d3fa62b0cd6ff07158a9878152fcd6fd7b3ddd (commit)
       via  a467ad903f53f13eb8360602ff3466ae39a21a26 (commit)
      from  524ef46e37b618bcb99e7cbe7019ed482c5bcbf0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4d3fa62b0cd6ff07158a9878152fcd6fd7b3ddd
commit f4d3fa62b0cd6ff07158a9878152fcd6fd7b3ddd
Merge: 524ef46 a467ad9
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu May 16 13:54:11 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu May 16 13:54:11 2013 -0400

    Merge topic 'genex-generate-file' into next
    
    a467ad9 Make it possible to generate files at generate time.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a467ad903f53f13eb8360602ff3466ae39a21a26
commit a467ad903f53f13eb8360602ff3466ae39a21a26
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Jan 2 17:10:04 2013 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Thu May 16 19:53:25 2013 +0200

    Make it possible to generate files at generate time.
    
    The idea is to write to a temp file which contains generator expressions,
    and at generate time, evaluate the generator expressions, and write the
    result to a file.
    
    Because executables on Windows are limited in the length of command
    line it is possible to use, it is common to write command line arguments
    to a file instead and specify the file as a source of arguments.
    
    This new FILE(GENERATE) subcommand allows the use of generator expressions to
    create such files so that they can be used with add_custom_command
    for example.

diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 227b226..cbbd5db 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -17,6 +17,7 @@
 #include "cmExportCommand.cxx"
 #include "cmExportLibraryDependencies.cxx"
 #include "cmFLTKWrapUICommand.cxx"
+#include "cmGeneratorExpressionEvaluationFile.cxx"
 #include "cmIncludeExternalMSProjectCommand.cxx"
 #include "cmInstallProgramsCommand.cxx"
 #include "cmLinkLibrariesCommand.cxx"
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 018ce7e..c51a72a 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -167,6 +167,10 @@ bool cmFileCommand
     {
     return this->HandleTimestampCommand(args);
     }
+  else if ( subCommand == "GENERATE" )
+    {
+    return this->HandleGenerateCommand(args);
+    }
 
   std::string e = "does not recognize sub-command "+subCommand;
   this->SetError(e.c_str());
@@ -3250,6 +3254,80 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
 }
 
 //----------------------------------------------------------------------------
+void cmFileCommand::AddEvaluationFile(const std::string &inputName,
+                                      const std::string &outputExpr,
+                                      const std::string &condition,
+                                      bool inputIsContent
+                                     )
+{
+  cmListFileBacktrace lfbt;
+  this->Makefile->GetBacktrace(lfbt);
+
+  cmGeneratorExpression outputGe(lfbt);
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge
+                                                = outputGe.Parse(outputExpr);
+
+  cmGeneratorExpression conditionGe(lfbt);
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge
+                                              = conditionGe.Parse(condition);
+
+  this->Makefile->GetLocalGenerator()
+                ->GetGlobalGenerator()->AddEvaluationFile(inputName,
+                                                          outputCge,
+                                                          this->Makefile,
+                                                          conditionCge,
+                                                          inputIsContent);
+}
+
+//----------------------------------------------------------------------------
+bool cmFileCommand::HandleGenerateCommand(
+  std::vector<std::string> const& args)
+{
+  if (args.size() < 5)
+    {
+    this->SetError("Incorrect arguments to GENERATE subcommand.");
+    return false;
+    }
+  if (args[1] != "OUTPUT")
+    {
+    this->SetError("Incorrect arguments to GENERATE subcommand.");
+    return false;
+    }
+  std::string condition;
+  if (args.size() > 5)
+    {
+    if (args[5] != "CONDITION")
+      {
+      this->SetError("Incorrect arguments to GENERATE subcommand.");
+      return false;
+      }
+    if (args.size() != 7)
+      {
+      this->SetError("Incorrect arguments to GENERATE subcommand.");
+      return false;
+      }
+    condition = args[6];
+    if (condition.empty())
+      {
+      this->SetError("CONDITION of sub-command GENERATE must not be empty if "
+        "specified.");
+      return false;
+      }
+    }
+  std::string output = args[2];
+  const bool inputIsContent = args[3] != "INPUT";
+  if (inputIsContent && args[3] != "CONTENT")
+    {
+    this->SetError("Incorrect arguments to GENERATE subcommand.");
+    return false;
+    }
+  std::string input = args[4];
+
+  this->AddEvaluationFile(input, output, condition, inputIsContent);
+  return true;
+}
+
+//----------------------------------------------------------------------------
 bool cmFileCommand::HandleTimestampCommand(
   std::vector<std::string> const& args)
 {
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index 5973fa7..a50b738 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -269,6 +269,13 @@ protected:
   bool HandleUploadCommand(std::vector<std::string> const& args);
 
   bool HandleTimestampCommand(std::vector<std::string> const& args);
+  bool HandleGenerateCommand(std::vector<std::string> const& args);
+
+private:
+  void AddEvaluationFile(const std::string &inputName,
+                         const std::string &outputExpr,
+                         const std::string &condition,
+                         bool inputIsContent);
 };
 
 
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
new file mode 100644
index 0000000..cab99ed
--- /dev/null
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -0,0 +1,151 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2013 Stephen Kelly <steveire at gmail.com>
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "cmGeneratorExpressionEvaluationFile.h"
+
+#include "cmMakefile.h"
+
+#include <assert.h>
+
+//----------------------------------------------------------------------------
+cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
+        const std::string &input,
+        cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+        cmMakefile *makefile,
+        cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+        bool inputIsContent)
+  : Input(input),
+    OutputFileExpr(outputFileExpr),
+    Makefile(makefile),
+    Condition(condition),
+    InputIsContent(inputIsContent)
+{
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
+              cmCompiledGeneratorExpression* inputExpression,
+              std::map<std::string, std::string> &outputFiles)
+{
+  std::string rawCondition = this->Condition->GetInput();
+  if (!rawCondition.empty())
+    {
+    std::string condResult = this->Condition->Evaluate(this->Makefile, config);
+    if (condResult == "0")
+      {
+      return;
+      }
+    if (condResult != "1")
+      {
+      cmOStringStream e;
+      e << "Evaluation file condition \"" << rawCondition << "\" did "
+          "not evaluate to valid content. Got \"" << condResult << "\".";
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      return;
+      }
+    }
+
+  const std::string outputFileName
+                    = this->OutputFileExpr->Evaluate(this->Makefile, config);
+  const std::string outputContent
+                          = inputExpression->Evaluate(this->Makefile, config);
+
+  std::map<std::string, std::string>::iterator it
+                                          = outputFiles.find(outputFileName);
+
+  if(it != outputFiles.end())
+    {
+    if (it->second == outputContent)
+      {
+      return;
+      }
+    cmOStringStream e;
+    e << "Evaluation file to be written multiple times for different "
+         "configurations with different content:\n  " << outputFileName;
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return;
+    }
+
+  this->Files.push_back(outputFileName);
+  outputFiles[outputFileName] = outputContent;
+
+  std::ofstream fout(outputFileName.c_str());
+
+  if(!fout)
+    {
+    cmOStringStream e;
+    e << "Evaluation file \"" << outputFileName << "\" cannot be written.";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return;
+    }
+
+  fout << outputContent;
+
+  fout.close();
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorExpressionEvaluationFile::Generate()
+{
+  std::string inputContent;
+  if (this->InputIsContent)
+    {
+    inputContent = this->Input;
+    }
+  else
+    {
+    std::ifstream fin(this->Input.c_str());
+    if(!fin)
+      {
+      cmOStringStream e;
+      e << "Evaluation file \"" << this->Input << "\" cannot be read.";
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      return;
+      }
+
+    std::string line;
+    std::string sep;
+    while(cmSystemTools::GetLineFromStream(fin, line))
+      {
+      inputContent += sep + line;
+      sep = "\n";
+      }
+    inputContent += sep;
+    }
+
+  cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
+  cmGeneratorExpression contentGE(lfbt);
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression
+                                              = contentGE.Parse(inputContent);
+
+  std::map<std::string, std::string> outputFiles;
+
+  std::vector<std::string> allConfigs;
+  this->Makefile->GetConfigurations(allConfigs);
+
+  if (allConfigs.empty())
+    {
+    this->Generate(0, inputExpression.get(), outputFiles);
+    }
+  else
+    {
+    for(std::vector<std::string>::const_iterator li = allConfigs.begin();
+        li != allConfigs.end(); ++li)
+      {
+      this->Generate(li->c_str(), inputExpression.get(), outputFiles);
+      if(cmSystemTools::GetFatalErrorOccured())
+        {
+        return;
+        }
+      }
+    }
+}
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
new file mode 100644
index 0000000..20ee5cb
--- /dev/null
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -0,0 +1,48 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2013 Stephen Kelly <steveire at gmail.com>
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#ifndef cmGeneratorExpressionEvaluationFile_h
+#define cmGeneratorExpressionEvaluationFile_h
+
+#include "cmStandardIncludes.h"
+#include <cmsys/auto_ptr.hxx>
+
+#include "cmGeneratorExpression.h"
+
+//----------------------------------------------------------------------------
+class cmGeneratorExpressionEvaluationFile
+{
+public:
+  cmGeneratorExpressionEvaluationFile(const std::string &input,
+        cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+        cmMakefile *makefile,
+        cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+        bool inputIsContent);
+
+  void Generate();
+
+  std::vector<std::string> GetFiles() const { return this->Files; }
+
+private:
+  void Generate(const char *config,
+              cmCompiledGeneratorExpression* inputExpression,
+              std::map<std::string, std::string> &outputFiles);
+
+private:
+  const std::string Input;
+  const cmsys::auto_ptr<cmCompiledGeneratorExpression> OutputFileExpr;
+  cmMakefile *Makefile;
+  const cmsys::auto_ptr<cmCompiledGeneratorExpression> Condition;
+  std::vector<std::string> Files;
+  const bool InputIsContent;
+};
+
+#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index df14331..2e94c42 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -26,6 +26,7 @@
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGeneratorExpression.h"
+#include "cmGeneratorExpressionEvaluationFile.h"
 
 #include <cmsys/Directory.hxx>
 
@@ -981,6 +982,8 @@ void cmGlobalGenerator::Generate()
   // Create per-target generator information.
   this->CreateGeneratorTargets();
 
+  this->ProcessEvaluationFiles();
+
   // Compute the inter-target dependencies.
   if(!this->ComputeTargetDepends())
     {
@@ -2558,3 +2561,44 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) {
   }
   return result;
 }
+
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile,
+                    cmsys::auto_ptr<cmCompiledGeneratorExpression> outputExpr,
+                    cmMakefile *makefile,
+                    cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+                    bool inputIsContent)
+{
+  this->EvaluationFiles.push_back(
+              new cmGeneratorExpressionEvaluationFile(inputFile, outputExpr,
+                                                      makefile, condition,
+                                                      inputIsContent));
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::ProcessEvaluationFiles()
+{
+  std::set<std::string> generatedFiles;
+  for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
+      li = this->EvaluationFiles.begin();
+      li != this->EvaluationFiles.end();
+      ++li)
+    {
+    (*li)->Generate();
+    if (cmSystemTools::GetFatalErrorOccured())
+      {
+      return;
+      }
+    std::vector<std::string> files = (*li)->GetFiles();
+    for(std::vector<std::string>::const_iterator fi = files.begin();
+        fi != files.end(); ++fi)
+      {
+      if (!generatedFiles.insert(*fi).second)
+        {
+        cmSystemTools::Error("File to be generated by multiple different "
+          "commands: ", fi->c_str());
+        return;
+        }
+      }
+    }
+}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 11616e0..381918b 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -20,9 +20,11 @@
 #include "cmSystemTools.h" // for cmSystemTools::OutputOption
 #include "cmExportSetMap.h" // For cmExportSetMap
 #include "cmGeneratorTarget.h"
+#include "cmGeneratorExpression.h"
 
 class cmake;
 class cmGeneratorTarget;
+class cmGeneratorExpressionEvaluationFile;
 class cmMakefile;
 class cmLocalGenerator;
 class cmExternalMakefileProjectGenerator;
@@ -278,6 +280,14 @@ public:
 
   static std::string EscapeJSON(const std::string& s);
 
+  void AddEvaluationFile(const std::string &inputFile,
+                  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName,
+                  cmMakefile *makefile,
+                  cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+                  bool inputIsContent);
+
+  void ProcessEvaluationFiles();
+
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
@@ -337,6 +347,7 @@ protected:
   // All targets in the entire project.
   std::map<cmStdString,cmTarget *> TotalTargets;
   std::map<cmStdString,cmTarget *> ImportedTargets;
+  std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
 
   virtual const char* GetPredefinedTargetsFolder();
   virtual bool UseFolderProperty();
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 402c8a9..53bb8d8 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -86,3 +86,5 @@ if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
   add_RunCMake_test(include_external_msproject)
   add_RunCMake_test(SolutionGlobalSections)
 endif()
+
+add_RunCMake_test(File_Generate)
diff --git a/Tests/RunCMake/File_Generate/BadCondition-result.txt b/Tests/RunCMake/File_Generate/BadCondition-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/BadCondition-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/BadCondition-stderr.txt b/Tests/RunCMake/File_Generate/BadCondition-stderr.txt
new file mode 100644
index 0000000..bab8368
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/BadCondition-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Evaluation file condition \"\$<1:Bad>\" did not evaluate to valid content.
+  Got \"Bad\".
diff --git a/Tests/RunCMake/File_Generate/BadCondition.cmake b/Tests/RunCMake/File_Generate/BadCondition.cmake
new file mode 100644
index 0000000..82ad672
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/BadCondition.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+              CONDITION $<1:Bad>
+)
diff --git a/Tests/RunCMake/File_Generate/CMakeLists.txt b/Tests/RunCMake/File_Generate/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/File_Generate/CommandConflict-result.txt b/Tests/RunCMake/File_Generate/CommandConflict-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CommandConflict-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/CommandConflict-stderr.txt b/Tests/RunCMake/File_Generate/CommandConflict-stderr.txt
new file mode 100644
index 0000000..da97ba4
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CommandConflict-stderr.txt
@@ -0,0 +1 @@
+CMake Error: File to be generated by multiple different commands: .*CommandConflict-build/output_.*.txt
diff --git a/Tests/RunCMake/File_Generate/CommandConflict.cmake b/Tests/RunCMake/File_Generate/CommandConflict.cmake
new file mode 100644
index 0000000..d57bc12
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CommandConflict.cmake
@@ -0,0 +1,9 @@
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_$<CONFIGURATION>.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+              CONDITION $<CONFIG:$<CONFIGURATION>>
+)
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_$<CONFIGURATION>.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+              CONDITION $<CONFIG:$<CONFIGURATION>>
+)
diff --git a/Tests/RunCMake/File_Generate/DebugEvaluate.cmake b/Tests/RunCMake/File_Generate/DebugEvaluate.cmake
new file mode 100644
index 0000000..1fa9b62
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/DebugEvaluate.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+              CONDITION $<CONFIG:Debug>
+)
diff --git a/Tests/RunCMake/File_Generate/EmptyCondition1-result.txt b/Tests/RunCMake/File_Generate/EmptyCondition1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/EmptyCondition1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt b/Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt
new file mode 100644
index 0000000..9fe39cc
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at EmptyCondition1.cmake:2 \(file\):
+  file Incorrect arguments to GENERATE subcommand.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/File_Generate/EmptyCondition1.cmake b/Tests/RunCMake/File_Generate/EmptyCondition1.cmake
new file mode 100644
index 0000000..8574a5f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/EmptyCondition1.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+              CONDITION
+)
diff --git a/Tests/RunCMake/File_Generate/EmptyCondition2-result.txt b/Tests/RunCMake/File_Generate/EmptyCondition2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/EmptyCondition2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt b/Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt
new file mode 100644
index 0000000..73d5f25
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at EmptyCondition2.cmake:2 \(file\):
+  file CONDITION of sub-command GENERATE must not be empty if specified.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/File_Generate/EmptyCondition2.cmake b/Tests/RunCMake/File_Generate/EmptyCondition2.cmake
new file mode 100644
index 0000000..626bfb4
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/EmptyCondition2.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+              CONDITION ""
+)
diff --git a/Tests/RunCMake/File_Generate/OutputConflict-result.txt b/Tests/RunCMake/File_Generate/OutputConflict-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/OutputConflict-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/OutputConflict-stderr.txt b/Tests/RunCMake/File_Generate/OutputConflict-stderr.txt
new file mode 100644
index 0000000..dbd39de
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/OutputConflict-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error in CMakeLists.txt:
+  Evaluation file to be written multiple times for different configurations
+  with different content:
+
+  .*output.txt
diff --git a/Tests/RunCMake/File_Generate/OutputConflict.cmake b/Tests/RunCMake/File_Generate/OutputConflict.cmake
new file mode 100644
index 0000000..7f3e8c7
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/OutputConflict.cmake
@@ -0,0 +1,4 @@
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+              INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
+)
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
new file mode 100644
index 0000000..f07431c
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -0,0 +1,10 @@
+include(RunCMake)
+
+run_cmake(CommandConflict)
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio" OR "${RunCMake_GENERATOR}" MATCHES "XCode" )
+    run_cmake(OutputConflict)
+endif()
+run_cmake(EmptyCondition1)
+run_cmake(EmptyCondition2)
+run_cmake(BadCondition)
+run_cmake(DebugEvaluate)
diff --git a/Tests/RunCMake/File_Generate/input.txt b/Tests/RunCMake/File_Generate/input.txt
new file mode 100644
index 0000000..3db429d
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/input.txt
@@ -0,0 +1 @@
+Some $<$<CONFIG:Debug>:conflicting> $<$<NOT:$<CONFIG:Debug>>:content>

-----------------------------------------------------------------------

Summary of changes:
 Source/cmCommands.cxx                              |    1 +
 Source/cmFileCommand.cxx                           |   78 ++++++++++
 Source/cmFileCommand.h                             |    7 +
 Source/cmGeneratorExpressionEvaluationFile.cxx     |  151 ++++++++++++++++++++
 Source/cmGeneratorExpressionEvaluationFile.h       |   48 ++++++
 Source/cmGlobalGenerator.cxx                       |   44 ++++++
 Source/cmGlobalGenerator.h                         |   11 ++
 Tests/RunCMake/CMakeLists.txt                      |    2 +
 .../BadCondition-result.txt}                       |    0
 .../RunCMake/File_Generate/BadCondition-stderr.txt |    3 +
 Tests/RunCMake/File_Generate/BadCondition.cmake    |    5 +
 .../{CMP0004 => File_Generate}/CMakeLists.txt      |    0
 .../CommandConflict-result.txt}                    |    0
 .../File_Generate/CommandConflict-stderr.txt       |    1 +
 Tests/RunCMake/File_Generate/CommandConflict.cmake |    9 ++
 Tests/RunCMake/File_Generate/DebugEvaluate.cmake   |    5 +
 .../EmptyCondition1-result.txt}                    |    0
 .../File_Generate/EmptyCondition1-stderr.txt       |    4 +
 Tests/RunCMake/File_Generate/EmptyCondition1.cmake |    5 +
 .../EmptyCondition2-result.txt}                    |    0
 .../File_Generate/EmptyCondition2-stderr.txt       |    4 +
 Tests/RunCMake/File_Generate/EmptyCondition2.cmake |    5 +
 .../OutputConflict-result.txt}                     |    0
 .../File_Generate/OutputConflict-stderr.txt        |    5 +
 Tests/RunCMake/File_Generate/OutputConflict.cmake  |    4 +
 Tests/RunCMake/File_Generate/RunCMakeTest.cmake    |   10 ++
 Tests/RunCMake/File_Generate/input.txt             |    1 +
 27 files changed, 403 insertions(+), 0 deletions(-)
 create mode 100644 Source/cmGeneratorExpressionEvaluationFile.cxx
 create mode 100644 Source/cmGeneratorExpressionEvaluationFile.h
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => File_Generate/BadCondition-result.txt} (100%)
 create mode 100644 Tests/RunCMake/File_Generate/BadCondition-stderr.txt
 create mode 100644 Tests/RunCMake/File_Generate/BadCondition.cmake
 copy Tests/RunCMake/{CMP0004 => File_Generate}/CMakeLists.txt (100%)
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => File_Generate/CommandConflict-result.txt} (100%)
 create mode 100644 Tests/RunCMake/File_Generate/CommandConflict-stderr.txt
 create mode 100644 Tests/RunCMake/File_Generate/CommandConflict.cmake
 create mode 100644 Tests/RunCMake/File_Generate/DebugEvaluate.cmake
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => File_Generate/EmptyCondition1-result.txt} (100%)
 create mode 100644 Tests/RunCMake/File_Generate/EmptyCondition1-stderr.txt
 create mode 100644 Tests/RunCMake/File_Generate/EmptyCondition1.cmake
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => File_Generate/EmptyCondition2-result.txt} (100%)
 create mode 100644 Tests/RunCMake/File_Generate/EmptyCondition2-stderr.txt
 create mode 100644 Tests/RunCMake/File_Generate/EmptyCondition2.cmake
 copy Tests/RunCMake/{CMP0004/CMP0004-NEW-result.txt => File_Generate/OutputConflict-result.txt} (100%)
 create mode 100644 Tests/RunCMake/File_Generate/OutputConflict-stderr.txt
 create mode 100644 Tests/RunCMake/File_Generate/OutputConflict.cmake
 create mode 100644 Tests/RunCMake/File_Generate/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/File_Generate/input.txt


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list