[Cmake-commits] CMake branch, next, updated. v3.8.0-793-g9c6b747

Kitware Robot kwrobot at kitware.com
Tue Apr 18 10:25:03 EDT 2017


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  9c6b7474fc148063be7a564311c0ed0634238f65 (commit)
       via  ff6078d597562661270d3e675c6d136ade917243 (commit)
       via  bba5bcf93de71085e478ea958d82d97f26dfa658 (commit)
      from  4fb5157b5f8fb12cf7875008808a1a2b1bb50aec (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c6b7474fc148063be7a564311c0ed0634238f65
commit 9c6b7474fc148063be7a564311c0ed0634238f65
Merge: 4fb5157 ff6078d
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Tue Apr 18 14:20:51 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Apr 18 10:20:54 2017 -0400

    Stage topic 'autogen-fixes'
    
    Topic-id: 23520
    Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/671


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff6078d597562661270d3e675c6d136ade917243
commit ff6078d597562661270d3e675c6d136ade917243
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Apr 13 18:13:07 2017 +0200
Commit:     Aleix Pol <aleixpol at kde.org>
CommitDate: Tue Apr 18 15:59:28 2017 +0200

    Autogen: Include moc_predefs.h by absolute path

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 1cf06f2..ba4957b 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -581,6 +581,12 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
 
   this->MocCppFilenameAbs = this->CurrentBinaryDir + this->MocCppFilenameRel;
 
+  // Moc predefs file
+  if (!this->MocPredefsCmd.empty()) {
+    this->MocPredefsFileRel = this->AutogenBuildSubDir + "moc_predefs.h";
+    this->MocPredefsFileAbs = this->CurrentBinaryDir + this->MocPredefsFileRel;
+  }
+
   // Init file path checksum generator
   fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir,
                                 this->ProjectSourceDir,
@@ -1146,13 +1152,12 @@ bool cmQtAutoGenerators::MocGenerateAll(
 
   // Generate moc_predefs
   if (!this->MocPredefsCmd.empty()) {
-    const std::string mocPredefsFile =
-      this->AutogenBuildSubDir + "moc_predefs.h";
-    if (!this->MakeParentDirectory(mocPredefsFile)) {
-      this->LogError("AutoMoc: Error creating directory for" + mocPredefsFile);
+    if (!this->MakeParentDirectory(this->MocPredefsFileAbs)) {
+      this->LogError("AutoMoc: Error creating directory for " +
+                     this->MocPredefsFileRel);
       return false;
     }
-    this->LogBold("Generating " + mocPredefsFile);
+    this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
 
     std::vector<std::string> cmd = this->MocPredefsCmd;
     cmd.insert(cmd.end(), this->MocIncludes.begin(), this->MocIncludes.end());
@@ -1170,16 +1175,16 @@ bool cmQtAutoGenerators::MocGenerateAll(
 
     // actually write the file
     cmsys::ofstream outfile;
-    outfile.open(mocPredefsFile.c_str(), std::ios::trunc);
+    outfile.open(this->MocPredefsFileAbs.c_str(), std::ios::trunc);
     if (!outfile) {
       moc_predefsGenerated = false;
-      this->LogError("AutoMoc: Error opening " + mocPredefsFile);
+      this->LogError("AutoMoc: Error opening " + this->MocPredefsFileRel);
     } else {
       outfile << output;
       // Check for write errors
       if (!outfile.good()) {
         moc_predefsGenerated = false;
-        this->LogError("AutoMoc: Error writing " + mocPredefsFile);
+        this->LogError("AutoMoc: Error writing " + this->MocPredefsFileRel);
       }
     }
 
@@ -1350,9 +1355,9 @@ bool cmQtAutoGenerators::MocGenerateFile(
         cmd.push_back("-D" + (*it));
       }
       cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
-      if (!this->MocPredefsCmd.empty()) {
+      if (!this->MocPredefsFileAbs.empty()) {
         cmd.push_back("--include");
-        cmd.push_back(this->AutogenBuildSubDir + "moc_predefs.h");
+        cmd.push_back(this->MocPredefsFileAbs);
       }
 #ifdef _WIN32
       cmd.push_back("-DWIN32");
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index cc8b029..cb6f45a 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -176,6 +176,8 @@ private:
   // - Moc
   std::string MocCppFilenameRel;
   std::string MocCppFilenameAbs;
+  std::string MocPredefsFileRel;
+  std::string MocPredefsFileAbs;
   std::vector<std::string> MocSkipList;
   std::vector<std::string> MocIncludePaths;
   std::vector<std::string> MocIncludes;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bba5bcf93de71085e478ea958d82d97f26dfa658
commit bba5bcf93de71085e478ea958d82d97f26dfa658
Author:     Aleix Pol <aleixpol at kde.org>
AuthorDate: Thu Apr 6 04:14:35 2017 +0200
Commit:     Aleix Pol <aleixpol at kde.org>
CommitDate: Tue Apr 18 15:59:22 2017 +0200

    Fix automoc in some set ups
    
    Qt is relying on whoever calls moc to include a file with the predefined
    values that will be used by the compiler, otherwise moc takes wrong
    paths and weird things happen.
    Instead, generate an include file and feed it to all mocs to make sure
    it's generating correct code.
    
    Fixes: 16640

diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in
index fcecb6c..5e945bc 100644
--- a/Modules/AutogenInfo.cmake.in
+++ b/Modules/AutogenInfo.cmake.in
@@ -21,6 +21,7 @@ set(AM_MOC_INCLUDES @_moc_incs@)
 set(AM_MOC_OPTIONS @_moc_options@)
 set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@)
 set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@)
+set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@)
 # UIC settings
 set(AM_UIC_SKIP @_uic_skip@)
 set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index 02968b4..513e62a 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -22,5 +22,7 @@ else()
     string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
     string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
     string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
+
+    set(CMAKE_GENERATE_${lang}_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
   endmacro()
 endif()
diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake
index 6878254..939c08e 100644
--- a/Modules/Platform/Linux-GNU.cmake
+++ b/Modules/Platform/Linux-GNU.cmake
@@ -12,4 +12,5 @@ macro(__linux_compiler_gnu lang)
   # We pass this for historical reasons.  Projects may have
   # executables that use dlopen but do not set ENABLE_EXPORTS.
   set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
+  set(CMAKE_GENERATE_${lang}_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
 endmacro()
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index d69794c..07fcb2f 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -96,6 +96,36 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target)
   return qtMajorVersion;
 }
 
+static std::string GetQtMinorVersion(cmGeneratorTarget const* target)
+{
+  cmMakefile* makefile = target->Target->GetMakefile();
+  std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR");
+  if (qtMajorVersion.empty()) {
+    qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR");
+  }
+  const char* targetQtVersion =
+    target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", "");
+  if (targetQtVersion != CM_NULLPTR) {
+    qtMajorVersion = targetQtVersion;
+  }
+  return qtMajorVersion;
+}
+
+static bool QtVersionGreaterOrEqual(const std::string& major,
+                                    const std::string& minor,
+                                    unsigned long requestMajor,
+                                    unsigned long requestMinor)
+{
+  unsigned long majorUL(0);
+  unsigned long minorUL(0);
+  if (cmSystemTools::StringToULong(major.c_str(), &majorUL) &&
+      cmSystemTools::StringToULong(minor.c_str(), &minorUL)) {
+    return (majorUL > requestMajor) ||
+      (majorUL == requestMajor && minorUL >= requestMinor);
+  }
+  return false;
+}
+
 static void GetCompileDefinitionsAndDirectories(
   cmGeneratorTarget const* target, const std::string& config,
   std::string& incs, std::string& defs)
@@ -258,6 +288,12 @@ static void MocSetupAutoTarget(
   AddDefinitionEscaped(makefile, "_moc_depend_filters",
                        GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
 
+  if (QtVersionGreaterOrEqual(qtMajorVersion, GetQtMinorVersion(target), 5,
+                              8)) {
+    AddDefinitionEscaped(
+      makefile, "_moc_predefs_cmd",
+      makefile->GetSafeDefinition("CMAKE_GENERATE_CXX_PREDEFINES_COMMAND"));
+  }
   // Moc includes and compile definitions
   {
     std::string _moc_incs;
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 246dd8d..1cf06f2 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -360,6 +360,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
   InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable);
   InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable);
   InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable);
+
+  InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd);
   // Check Qt version
   if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) {
     this->LogError("AutoGen: Error: Unsupported Qt version: " +
@@ -1142,6 +1144,49 @@ bool cmQtAutoGenerators::MocGenerateAll(
     return true;
   }
 
+  // Generate moc_predefs
+  if (!this->MocPredefsCmd.empty()) {
+    const std::string mocPredefsFile =
+      this->AutogenBuildSubDir + "moc_predefs.h";
+    if (!this->MakeParentDirectory(mocPredefsFile)) {
+      this->LogError("AutoMoc: Error creating directory for" + mocPredefsFile);
+      return false;
+    }
+    this->LogBold("Generating " + mocPredefsFile);
+
+    std::vector<std::string> cmd = this->MocPredefsCmd;
+    cmd.insert(cmd.end(), this->MocIncludes.begin(), this->MocIncludes.end());
+    for (std::vector<std::string>::const_iterator it =
+           this->MocDefinitions.begin();
+         it != this->MocDefinitions.end(); ++it) {
+      cmd.push_back("-D" + (*it));
+    }
+    cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
+
+    std::string output;
+    bool moc_predefsGenerated = this->RunCommand(cmd, output, false);
+    if (!moc_predefsGenerated)
+      return false;
+
+    // actually write the file
+    cmsys::ofstream outfile;
+    outfile.open(mocPredefsFile.c_str(), std::ios::trunc);
+    if (!outfile) {
+      moc_predefsGenerated = false;
+      this->LogError("AutoMoc: Error opening " + mocPredefsFile);
+    } else {
+      outfile << output;
+      // Check for write errors
+      if (!outfile.good()) {
+        moc_predefsGenerated = false;
+        this->LogError("AutoMoc: Error writing " + mocPredefsFile);
+      }
+    }
+
+    if (!moc_predefsGenerated)
+      return false;
+  }
+
   bool mocCompFileGenerated = false;
   bool mocCompChanged = false;
 
@@ -1305,6 +1350,10 @@ bool cmQtAutoGenerators::MocGenerateFile(
         cmd.push_back("-D" + (*it));
       }
       cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
+      if (!this->MocPredefsCmd.empty()) {
+        cmd.push_back("--include");
+        cmd.push_back(this->AutogenBuildSubDir + "moc_predefs.h");
+      }
 #ifdef _WIN32
       cmd.push_back("-DWIN32");
 #endif
@@ -1805,7 +1854,7 @@ bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) const
  * @return True on success
  */
 bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
-                                    std::string& output) const
+                                    std::string& output, bool verbose) const
 {
   // Log command
   if (this->Verbose) {
@@ -1813,8 +1862,9 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
   }
   // Execute command
   int retVal = 0;
-  bool res =
-    cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
+  bool res = cmSystemTools::RunSingleCommand(
+    command, &output, &output, &retVal, CM_NULLPTR,
+    verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE);
   return (res && (retVal == 0));
 }
 
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index ee046de..cc8b029 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -142,8 +142,8 @@ private:
                              const char* basePrefix,
                              const char* baseSuffix) const;
   bool MakeParentDirectory(const std::string& filename) const;
-  bool RunCommand(const std::vector<std::string>& command,
-                  std::string& output) const;
+  bool RunCommand(const std::vector<std::string>& command, std::string& output,
+                  bool verbose = true) const;
 
   bool FindHeader(std::string& header, const std::string& testBasePath) const;
 
@@ -197,6 +197,8 @@ private:
   MacroFilter MacroFilters[2];
   cmsys::RegularExpression RegExpMocInclude;
   cmsys::RegularExpression RegExpUicInclude;
+  // - moc_predefs
+  std::vector<std::string> MocPredefsCmd;
   // - Flags
   bool IncludeProjectDirsBefore;
   bool Verbose;

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

Summary of changes:
 Modules/AutogenInfo.cmake.in            |    1 +
 Modules/Compiler/Intel.cmake            |    2 +
 Modules/Platform/Linux-GNU.cmake        |    1 +
 Source/cmQtAutoGeneratorInitializer.cxx |   36 ++++++++++++++++++
 Source/cmQtAutoGenerators.cxx           |   61 +++++++++++++++++++++++++++++--
 Source/cmQtAutoGenerators.h             |    8 +++-
 6 files changed, 104 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list