浏览代码

Autogen: Pass build directory in Info file

Sebastian Holtermann 8 年之前
父节点
当前提交
0965002e57
共有 4 个文件被更改,包括 25 次插入22 次删除
  1. 1 0
      Modules/AutogenInfo.cmake.in
  2. 7 5
      Source/cmQtAutoGeneratorInitializer.cxx
  3. 16 16
      Source/cmQtAutoGenerators.cxx
  4. 1 1
      Source/cmQtAutoGenerators.h

+ 1 - 0
Modules/AutogenInfo.cmake.in

@@ -7,6 +7,7 @@ set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
 set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")
 set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")
+set(AM_BUILD_DIR @_autogen_build_dir@)
 set(AM_SOURCES @_sources@)
 set(AM_SOURCES @_sources@)
 set(AM_HEADERS @_headers@)
 set(AM_HEADERS @_headers@)
 # Qt environment
 # Qt environment

+ 7 - 5
Source/cmQtAutoGeneratorInitializer.cxx

@@ -67,7 +67,7 @@ static std::string GetAutogenTargetFilesDir(cmGeneratorTarget const* target)
   targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
   targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
   targetDir += "/";
   targetDir += "/";
   targetDir += GetAutogenTargetName(target);
   targetDir += GetAutogenTargetName(target);
-  targetDir += ".dir/";
+  targetDir += ".dir";
   return targetDir;
   return targetDir;
 }
 }
 
 
@@ -77,7 +77,6 @@ static std::string GetAutogenTargetBuildDir(cmGeneratorTarget const* target)
   std::string targetDir = makefile->GetCurrentBinaryDirectory();
   std::string targetDir = makefile->GetCurrentBinaryDirectory();
   targetDir += "/";
   targetDir += "/";
   targetDir += GetAutogenTargetName(target);
   targetDir += GetAutogenTargetName(target);
-  targetDir += "/";
   return targetDir;
   return targetDir;
 }
 }
 
 
@@ -624,7 +623,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
   if (target->GetPropertyAsBool("AUTOMOC")) {
   if (target->GetPropertyAsBool("AUTOMOC")) {
     cmMakefile* makefile = target->Target->GetMakefile();
     cmMakefile* makefile = target->Target->GetMakefile();
     std::string mocCppFile = GetAutogenTargetBuildDir(target);
     std::string mocCppFile = GetAutogenTargetBuildDir(target);
-    mocCppFile += "moc_compilation.cpp";
+    mocCppFile += "/moc_compilation.cpp";
     {
     {
       cmSourceFile* gFile = makefile->GetOrCreateSource(mocCppFile, true);
       cmSourceFile* gFile = makefile->GetOrCreateSource(mocCppFile, true);
       gFile->SetProperty("SKIP_AUTOGEN", "On");
       gFile->SetProperty("SKIP_AUTOGEN", "On");
@@ -706,14 +705,14 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   // Create autogen target includes directory and
   // Create autogen target includes directory and
   // add it to the origin target INCLUDE_DIRECTORIES
   // add it to the origin target INCLUDE_DIRECTORIES
   if (mocEnabled || uicEnabled) {
   if (mocEnabled || uicEnabled) {
-    const std::string incsDir = autogenBuildDir + "include";
+    const std::string incsDir = autogenBuildDir + "/include";
     cmSystemTools::MakeDirectory(incsDir);
     cmSystemTools::MakeDirectory(incsDir);
     target->AddIncludeDirectory(incsDir, true);
     target->AddIncludeDirectory(incsDir, true);
   }
   }
 
 
   // Register moc compilation file as generated
   // Register moc compilation file as generated
   if (mocEnabled) {
   if (mocEnabled) {
-    autogenProvides.push_back(autogenBuildDir + "moc_compilation.cpp");
+    autogenProvides.push_back(autogenBuildDir + "/moc_compilation.cpp");
   }
   }
 
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -785,6 +784,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
           // Compose rcc output file name
           // Compose rcc output file name
           {
           {
             std::string rccOut = autogenBuildDir;
             std::string rccOut = autogenBuildDir;
+            rccOut += "/";
             rccOut += fpathCheckSum.getPart(absFile);
             rccOut += fpathCheckSum.getPart(absFile);
             rccOut += "/qrc_";
             rccOut += "/qrc_";
             rccOut +=
             rccOut +=
@@ -919,6 +919,8 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
       }
       }
     }
     }
 
 
+    AddDefinitionEscaped(makefile, "_autogen_build_dir",
+                         GetAutogenTargetBuildDir(target));
     AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName);
     AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName);
     AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName());
     AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName());
     AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
     AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);

+ 16 - 16
Source/cmQtAutoGenerators.cxx

@@ -372,6 +372,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
   InfoGet(makefile, "AM_CMAKE_CURRENT_BINARY_DIR", this->CurrentBinaryDir);
   InfoGet(makefile, "AM_CMAKE_CURRENT_BINARY_DIR", this->CurrentBinaryDir);
   InfoGet(makefile, "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE",
   InfoGet(makefile, "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE",
           this->IncludeProjectDirsBefore);
           this->IncludeProjectDirsBefore);
+  InfoGet(makefile, "AM_BUILD_DIR", this->AutogenBuildDir);
   InfoGet(makefile, "AM_SOURCES", this->Sources);
   InfoGet(makefile, "AM_SOURCES", this->Sources);
   InfoGet(makefile, "AM_HEADERS", this->Headers);
   InfoGet(makefile, "AM_HEADERS", this->Headers);
 
 
@@ -615,18 +616,15 @@ bool cmQtAutoGenerators::SettingsFileWrite()
 
 
 void cmQtAutoGenerators::Init(cmMakefile* makefile)
 void cmQtAutoGenerators::Init(cmMakefile* makefile)
 {
 {
-  this->AutogenBuildSubDir = this->AutogenTargetName;
-  this->AutogenBuildSubDir += "/";
-
-  this->MocCppFilenameRel = this->AutogenBuildSubDir;
-  this->MocCppFilenameRel += "moc_compilation.cpp";
-
-  this->MocCppFilenameAbs = this->CurrentBinaryDir + this->MocCppFilenameRel;
+  this->MocCppFilenameRel = "moc_compilation.cpp";
+  this->MocCppFilenameAbs = cmSystemTools::CollapseCombinedPath(
+    this->AutogenBuildDir, this->MocCppFilenameRel);
 
 
   // Moc predefs file
   // Moc predefs file
   if (!this->MocPredefsCmd.empty()) {
   if (!this->MocPredefsCmd.empty()) {
-    this->MocPredefsFileRel = this->AutogenBuildSubDir + "moc_predefs.h";
-    this->MocPredefsFileAbs = this->CurrentBinaryDir + this->MocPredefsFileRel;
+    this->MocPredefsFileRel = "moc_predefs.h";
+    this->MocPredefsFileAbs = cmSystemTools::CollapseCombinedPath(
+      this->AutogenBuildDir, this->MocPredefsFileRel);
   }
   }
 
 
   // Init file path checksum generator
   // Init file path checksum generator
@@ -1335,8 +1333,9 @@ bool cmQtAutoGenerators::MocGenerateFile(
   bool generateMoc = this->MocSettingsChanged || this->MocPredefsChanged;
   bool generateMoc = this->MocSettingsChanged || this->MocPredefsChanged;
 
 
   const std::string mocFileRel =
   const std::string mocFileRel =
-    this->AutogenBuildSubDir + subDir + mocFileName;
-  const std::string mocFileAbs = this->CurrentBinaryDir + mocFileRel;
+    cmSystemTools::CollapseCombinedPath(subDir, mocFileName);
+  const std::string mocFileAbs =
+    cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, mocFileRel);
 
 
   if (!generateMoc) {
   if (!generateMoc) {
     // Test if the source file is newer that the build file
     // Test if the source file is newer that the build file
@@ -1525,8 +1524,9 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
   bool generateUic = this->UicSettingsChanged;
   bool generateUic = this->UicSettingsChanged;
 
 
   const std::string uicFileRel =
   const std::string uicFileRel =
-    this->AutogenBuildSubDir + "include/" + uiOutputFile;
-  const std::string uicFileAbs = this->CurrentBinaryDir + uicFileRel;
+    cmSystemTools::CollapseCombinedPath("include", uiOutputFile);
+  const std::string uicFileAbs =
+    cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, uicFileRel);
 
 
   if (!generateUic) {
   if (!generateUic) {
     // Test if the source file is newer that the build file
     // Test if the source file is newer that the build file
@@ -1594,8 +1594,7 @@ bool cmQtAutoGenerators::RccGenerateAll()
        si != this->RccSources.end(); ++si) {
        si != this->RccSources.end(); ++si) {
     const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
     const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
     if (ext == ".qrc") {
     if (ext == ".qrc") {
-      qrcGenMap[*si] =
-        this->AutogenBuildSubDir + this->ChecksumedPath(*si, "qrc_", ".cpp");
+      qrcGenMap[*si] = this->ChecksumedPath(*si, "qrc_", ".cpp");
     }
     }
   }
   }
 
 
@@ -1636,7 +1635,8 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
   bool rccGenerated = false;
   bool rccGenerated = false;
   bool generateRcc = this->RccSettingsChanged;
   bool generateRcc = this->RccSettingsChanged;
 
 
-  const std::string rccBuildFile = this->CurrentBinaryDir + rccOutputFile;
+  const std::string rccBuildFile =
+    cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, rccOutputFile);
 
 
   if (!generateRcc) {
   if (!generateRcc) {
     // Test if the resources list file is newer than build file
     // Test if the resources list file is newer than build file

+ 1 - 1
Source/cmQtAutoGenerators.h

@@ -165,7 +165,7 @@ private:
   std::string ProjectBinaryDir;
   std::string ProjectBinaryDir;
   std::string CurrentSourceDir;
   std::string CurrentSourceDir;
   std::string CurrentBinaryDir;
   std::string CurrentBinaryDir;
-  std::string AutogenBuildSubDir;
+  std::string AutogenBuildDir;
   // -- Qt environment
   // -- Qt environment
   std::string QtMajorVersion;
   std::string QtMajorVersion;
   std::string MocExecutable;
   std::string MocExecutable;