[Cmake-commits] CMake branch, master, updated. v3.12.1-552-g612975c

Kitware Robot kwrobot at kitware.com
Tue Sep 4 10:05:08 EDT 2018


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, master has been updated
       via  612975c6652c83c29fcfcf56a7b5a0cfe0218c93 (commit)
       via  69ce0629696ae8673d9063ba6a2878cf841beb0c (commit)
       via  0a1426f00833cd1ceca669ac9a87df55fb85c080 (commit)
       via  1bfe6991ff887dcc7cc9666a6971d21a097d6167 (commit)
       via  1fa0f2bd03621121e0a5d4c6cf0b4bcf74ad2ceb (commit)
       via  d74c2282ea2b7df2276ce73c790fafe9a5571c56 (commit)
       via  7a7e94d6f7b74eeb165cab39f3aeeaba690160ef (commit)
      from  6b5f4ff9292fbe38e2a00b2c1052ee8b65f24b1d (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=612975c6652c83c29fcfcf56a7b5a0cfe0218c93
commit 612975c6652c83c29fcfcf56a7b5a0cfe0218c93
Merge: 69ce062 7a7e94d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 4 13:58:51 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 4 09:59:12 2018 -0400

    Merge topic 'cpack_test'
    
    7a7e94d6f7 CPack (DEB/RPM): add test for per-component description/summmary.
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2333


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69ce0629696ae8673d9063ba6a2878cf841beb0c
commit 69ce0629696ae8673d9063ba6a2878cf841beb0c
Merge: 0a1426f d74c228
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 4 13:57:46 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 4 09:57:58 2018 -0400

    Merge topic 'cmakeServerSourcesForInterfaceLibraries'
    
    d74c2282ea cmake-server: Support codemodel filegroups for INTERFACE_SOURCES
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: Tobias Hunger <tobias.hunger at gmail.com>
    Acked-by: Markus Enzenberger <markus.enzenberger at gmail.com>
    Merge-request: !2282

diff --cc Source/cmServerProtocol.cxx
index 31101e4,db7be2a..af4b466
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@@ -765,14 -784,71 +784,71 @@@ static void PopulateFileGroupData
      }
  
      fileData.IsGenerated = file->GetPropertyAsBool("GENERATED");
-     std::vector<std::string>& groupFileList = fileGroups[fileData];
-     groupFileList.push_back(file->GetFullPath());
+     FileGroupSources& groupFileList = fileGroups[fileData];
+     groupFileList.IsInterfaceSources = isInterfaceSources;
+     groupFileList.Files.push_back(file->GetFullPath());
+   }
+ }
+ 
+ static Json::Value DumpSourceFilesList(
+   cmGeneratorTarget* target, const std::string& config,
+   const std::map<std::string, LanguageData>& languageDataMap)
+ {
+   const cmStateEnums::TargetType type = target->GetType();
+   std::unordered_map<LanguageData, FileGroupSources> fileGroups;
+ 
+   // Collect sourcefile groups:
+ 
+   std::vector<cmSourceFile*> files;
+   if (type == cmStateEnums::INTERFACE_LIBRARY) {
+     // INTERFACE_LIBRARY targets do not create all the data structures
+     // associated with regular targets. If properties are explicitly specified
+     // for files in INTERFACE_SOURCES then we can get them through the Makefile
+     // rather than the target.
+     files = target->Makefile->GetSourceFiles();
+   } else {
+     target->GetSourceFiles(files, config);
+     PopulateFileGroupData(target, false /* isInterfaceSources */, files,
+                           config, languageDataMap, fileGroups);
+   }
+ 
+   // Collect interface sourcefile groups:
+ 
+   auto targetProp = target->Target->GetProperty("INTERFACE_SOURCES");
+   if (targetProp != nullptr) {
+     cmGeneratorExpressionInterpreter genexInterpreter(
+       target->GetLocalGenerator(), target, config, target->GetName(), "");
+ 
+     auto evaluatedSources = cmsys::SystemTools::SplitString(
+       genexInterpreter.Evaluate(targetProp, "INTERFACE_SOURCES"), ';');
+ 
+     std::map<std::string, cmSourceFile*> filesMap;
+     for (auto file : files) {
+       filesMap[file->GetFullPath()] = file;
+     }
+ 
+     std::vector<cmSourceFile*> interfaceSourceFiles;
+     for (const std::string& interfaceSourceFilePath : evaluatedSources) {
+       auto entry = filesMap.find(interfaceSourceFilePath);
+       if (entry != filesMap.end()) {
+         // use what we have since it has all the associated properties
+         interfaceSourceFiles.push_back(entry->second);
+       } else {
+         interfaceSourceFiles.push_back(
+           new cmSourceFile(target->Makefile, interfaceSourceFilePath));
+       }
+     }
+ 
+     PopulateFileGroupData(target, true /* isInterfaceSources */,
+                           interfaceSourceFiles, config, languageDataMap,
+                           fileGroups);
    }
  
 -  const std::string baseDir = target->Makefile->GetCurrentSourceDirectory();
 +  const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory();
    Json::Value result = Json::arrayValue;
    for (auto const& it : fileGroups) {
-     Json::Value group = DumpSourceFileGroup(it.first, it.second, baseDir);
+     Json::Value group = DumpSourceFileGroup(
+       it.first, it.second.IsInterfaceSources, it.second.Files, baseDir);
      if (!group.isNull()) {
        result.append(group);
      }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0a1426f00833cd1ceca669ac9a87df55fb85c080
commit 0a1426f00833cd1ceca669ac9a87df55fb85c080
Merge: 6b5f4ff 1bfe699
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Sep 4 13:57:15 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Sep 4 09:57:22 2018 -0400

    Merge topic 'improve-isonoff'
    
    1bfe6991ff cmSystemTools: Re-implement IsOn,IsOff with manual branching
    1fa0f2bd03 cmSystemTools: Add IsOn(),IsOff() overloads accepting std::string
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: vvs31415 <vstakhovsky at fastmail.com>
    Merge-request: !2336


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1bfe6991ff887dcc7cc9666a6971d21a097d6167
commit 1bfe6991ff887dcc7cc9666a6971d21a097d6167
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Aug 30 14:41:54 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Aug 31 14:58:03 2018 -0400

    cmSystemTools: Re-implement IsOn,IsOff with manual branching
    
    Replace use of std::string allocation, std::set lookups, and toupper
    conversions with explicit manual logic to do case-insensitive
    recognition of a specific set of strings.

diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7663af1..79e5ccf 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -42,7 +42,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include <iostream>
-#include <set>
 #include <sstream>
 #include <stdio.h>
 #include <stdlib.h>
@@ -372,24 +371,31 @@ bool cmSystemTools::IsOn(const char* val)
   if (!val) {
     return false;
   }
-  size_t len = strlen(val);
-  if (len > 4) {
-    return false;
+  /* clang-format off */
+  // "1"
+  if (val[0] == '1' && val[1] == '\0') {
+    return true;
   }
-  std::string v(val, len);
-
-  static std::set<std::string> onValues;
-  if (onValues.empty()) {
-    onValues.insert("ON");
-    onValues.insert("1");
-    onValues.insert("YES");
-    onValues.insert("TRUE");
-    onValues.insert("Y");
+  // "ON"
+  if ((val[0] == 'O' || val[0] == 'o') &&
+      (val[1] == 'N' || val[1] == 'n') && val[2] == '\0') {
+    return true;
   }
-  for (char& c : v) {
-    c = static_cast<char>(toupper(c));
+  // "Y", "YES"
+  if ((val[0] == 'Y' || val[0] == 'y') && (val[1] == '\0' || (
+      (val[1] == 'E' || val[1] == 'e') &&
+      (val[2] == 'S' || val[2] == 's') && val[3] == '\0'))) {
+    return true;
   }
-  return (onValues.count(v) > 0);
+  // "TRUE"
+  if ((val[0] == 'T' || val[0] == 't') &&
+      (val[1] == 'R' || val[1] == 'r') &&
+      (val[2] == 'U' || val[2] == 'u') &&
+      (val[3] == 'E' || val[3] == 'e') && val[4] == '\0') {
+    return true;
+  }
+  /* clang-format on */
+  return false;
 }
 
 bool cmSystemTools::IsOn(const std::string& val)
@@ -407,30 +413,45 @@ bool cmSystemTools::IsNOTFOUND(const char* val)
 
 bool cmSystemTools::IsOff(const char* val)
 {
-  if (!val || !*val) {
+  // ""
+  if (!val || val[0] == '\0') {
     return true;
   }
-  size_t len = strlen(val);
-  // Try and avoid toupper() for large strings.
-  if (len > 6) {
-    return cmSystemTools::IsNOTFOUND(val);
+  /* clang-format off */
+  // "0"
+  if (val[0] == '0' && val[1] == '\0') {
+    return true;
   }
-
-  static std::set<std::string> offValues;
-  if (offValues.empty()) {
-    offValues.insert("OFF");
-    offValues.insert("0");
-    offValues.insert("NO");
-    offValues.insert("FALSE");
-    offValues.insert("N");
-    offValues.insert("IGNORE");
+  // "OFF"
+  if ((val[0] == 'O' || val[0] == 'o') &&
+      (val[1] == 'F' || val[1] == 'f') &&
+      (val[2] == 'F' || val[2] == 'f') && val[3] == '\0') {
+    return true;
   }
-  // Try and avoid toupper().
-  std::string v(val, len);
-  for (char& c : v) {
-    c = static_cast<char>(toupper(c));
+  // "N", "NO"
+  if ((val[0] == 'N' || val[0] == 'n') && (val[1] == '\0' || (
+      (val[1] == 'O' || val[1] == 'o') && val[2] == '\0'))) {
+    return true;
+  }
+  // "FALSE"
+  if ((val[0] == 'F' || val[0] == 'f') &&
+      (val[1] == 'A' || val[1] == 'a') &&
+      (val[2] == 'L' || val[2] == 'l') &&
+      (val[3] == 'S' || val[3] == 's') &&
+      (val[4] == 'E' || val[4] == 'e') && val[5] == '\0') {
+    return true;
+  }
+  // "IGNORE"
+  if ((val[0] == 'I' || val[0] == 'i') &&
+      (val[1] == 'G' || val[1] == 'g') &&
+      (val[2] == 'N' || val[2] == 'n') &&
+      (val[3] == 'O' || val[3] == 'o') &&
+      (val[4] == 'R' || val[4] == 'r') &&
+      (val[5] == 'E' || val[5] == 'e') && val[6] == '\0') {
+    return true;
   }
-  return (offValues.count(v) > 0);
+  /* clang-format on */
+  return cmSystemTools::IsNOTFOUND(val);
 }
 
 bool cmSystemTools::IsOff(const std::string& val)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1fa0f2bd03621121e0a5d4c6cf0b4bcf74ad2ceb
commit 1fa0f2bd03621121e0a5d4c6cf0b4bcf74ad2ceb
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Tue Aug 28 21:47:07 2018 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Aug 31 14:58:03 2018 -0400

    cmSystemTools: Add IsOn(),IsOff() overloads accepting std::string

diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 72fd2bb..7663af1 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -392,6 +392,11 @@ bool cmSystemTools::IsOn(const char* val)
   return (onValues.count(v) > 0);
 }
 
+bool cmSystemTools::IsOn(const std::string& val)
+{
+  return cmSystemTools::IsOn(val.c_str());
+}
+
 bool cmSystemTools::IsNOTFOUND(const char* val)
 {
   if (strcmp(val, "NOTFOUND") == 0) {
@@ -428,6 +433,11 @@ bool cmSystemTools::IsOff(const char* val)
   return (offValues.count(v) > 0);
 }
 
+bool cmSystemTools::IsOff(const std::string& val)
+{
+  return cmSystemTools::IsOff(val.c_str());
+}
+
 void cmSystemTools::ParseWindowsCommandLine(const char* command,
                                             std::vector<std::string>& args)
 {
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index c0a1b6b..5c383ee 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -129,6 +129,7 @@ public:
    * as ifdef.
    */
   static bool IsOn(const char* val);
+  static bool IsOn(const std::string& val);
 
   /**
    * does a string indicate a false or off value ? Note that this is
@@ -138,6 +139,7 @@ public:
    * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true.
    */
   static bool IsOff(const char* val);
+  static bool IsOff(const std::string& val);
 
   ///! Return true if value is NOTFOUND or ends in -NOTFOUND.
   static bool IsNOTFOUND(const char* value);

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d74c2282ea2b7df2276ce73c790fafe9a5571c56
commit d74c2282ea2b7df2276ce73c790fafe9a5571c56
Author:     Justin Goshi <jgoshi at microsoft.com>
AuthorDate: Fri Aug 10 10:45:56 2018 -0700
Commit:     Justin Goshi <jgoshi at microsoft.com>
CommitDate: Thu Aug 30 16:09:22 2018 -0700

    cmake-server: Support codemodel filegroups for INTERFACE_SOURCES
    
    This change returns information for INTERFACE_SOURCES. We add
    a flag to the filegroup to indicate if the target represents
    interface sources.
    
    Protocol version is updated to 1.3 since this is a change to what was
    released in cmake version 3.12.

diff --git a/Help/manual/cmake-server.7.rst b/Help/manual/cmake-server.7.rst
index 25d364c..b4c1436 100644
--- a/Help/manual/cmake-server.7.rst
+++ b/Help/manual/cmake-server.7.rst
@@ -308,6 +308,9 @@ which will result in a response type "reply"::
 
 indicating that the server is ready for action.
 
+Protocol version 1.3 introduces an optional flag on the target filegroup
+that indicates if the filegroup represents :prop_tgt:`INTERFACE_SOURCES`.
+
 
 Type "globalSettings"
 ^^^^^^^^^^^^^^^^^^^^^
@@ -524,6 +527,8 @@ FileGroups are used to group sources using similar settings together.
 
 Each fileGroup object may contain the following keys:
 
+"isInterfaceSources"
+  true if the fileGroup represents :prop_tgt:`INTERFACE_SOURCES`.
 "language"
   contains the programming language used by all files in the group.
 "compileFlags"
@@ -538,6 +543,8 @@ Each fileGroup object may contain the following keys:
 "defines"
   with a list of defines in the form "SOMEVALUE" or "SOMEVALUE=42". This
   value is encoded in the system's native shell format.
+"isGenerated"
+  true if the files were generated.
 "sources"
   with a list of source files.
 
diff --git a/Source/cmServerDictionary.h b/Source/cmServerDictionary.h
index 685542c..ebf16eb 100644
--- a/Source/cmServerDictionary.h
+++ b/Source/cmServerDictionary.h
@@ -96,6 +96,7 @@ static const std::string kCTEST_COMMAND = "ctestCommand";
 static const std::string kCTEST_INFO = "ctestInfo";
 static const std::string kMINIMUM_CMAKE_VERSION = "minimumCMakeVersion";
 static const std::string kIS_GENERATOR_PROVIDED_KEY = "isGeneratorProvided";
+static const std::string kIS_INTERFACE_SOURCES_KEY = "isInterfaceSources";
 
 static const std::string kSTART_MAGIC = "[== \"CMake Server\" ==[";
 static const std::string kEND_MAGIC = "]== \"CMake Server\" ==]";
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index c267160..db7be2a 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -256,7 +256,12 @@ bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/,
 
 std::pair<int, int> cmServerProtocol1::ProtocolVersion() const
 {
-  return std::make_pair(1, 2);
+  // Revision history
+  // 1, 1 - Report backtraces in codemodel response
+  // 1, 2 - Add target install destinations to codemodel
+  // 1, 3 - Add a flag to target filegroups indicating whether or not the
+  // filegroup is for INTERFACE_SOURCES
+  return std::make_pair(1, 3);
 }
 
 static void setErrorMessage(std::string* errorMessage, const std::string& text)
@@ -593,6 +598,8 @@ cmServerResponse cmServerProtocol1::ProcessCMakeInputs(
   return request.Reply(result);
 }
 
+const std::string kInterfaceSourcesLanguageDataKey =
+  "INTERFACE_SOURCES_LD_KEY";
 class LanguageData
 {
 public:
@@ -625,6 +632,12 @@ void LanguageData::SetDefines(const std::set<std::string>& defines)
   Defines = std::move(result);
 }
 
+struct FileGroupSources
+{
+  bool IsInterfaceSources;
+  std::vector<std::string> Files;
+};
+
 namespace std {
 
 template <>
@@ -652,31 +665,35 @@ struct hash<LanguageData>
 } // namespace std
 
 static Json::Value DumpSourceFileGroup(const LanguageData& data,
+                                       bool isInterfaceSource,
                                        const std::vector<std::string>& files,
                                        const std::string& baseDir)
 {
   Json::Value result = Json::objectValue;
 
+  if (isInterfaceSource) {
+    result[kIS_INTERFACE_SOURCES_KEY] = true;
+  }
   if (!data.Language.empty()) {
     result[kLANGUAGE_KEY] = data.Language;
-    if (!data.Flags.empty()) {
-      result[kCOMPILE_FLAGS_KEY] = data.Flags;
-    }
-    if (!data.IncludePathList.empty()) {
-      Json::Value includes = Json::arrayValue;
-      for (auto const& i : data.IncludePathList) {
-        Json::Value tmp = Json::objectValue;
-        tmp[kPATH_KEY] = i.first;
-        if (i.second) {
-          tmp[kIS_SYSTEM_KEY] = i.second;
-        }
-        includes.append(tmp);
+  }
+  if (!data.Flags.empty()) {
+    result[kCOMPILE_FLAGS_KEY] = data.Flags;
+  }
+  if (!data.IncludePathList.empty()) {
+    Json::Value includes = Json::arrayValue;
+    for (auto const& i : data.IncludePathList) {
+      Json::Value tmp = Json::objectValue;
+      tmp[kPATH_KEY] = i.first;
+      if (i.second) {
+        tmp[kIS_SYSTEM_KEY] = i.second;
       }
-      result[kINCLUDE_PATH_KEY] = includes;
-    }
-    if (!data.Defines.empty()) {
-      result[kDEFINES_KEY] = fromStringList(data.Defines);
+      includes.append(tmp);
     }
+    result[kINCLUDE_PATH_KEY] = includes;
+  }
+  if (!data.Defines.empty()) {
+    result[kDEFINES_KEY] = fromStringList(data.Defines);
   }
 
   result[kIS_GENERATED_KEY] = data.IsGenerated;
@@ -691,21 +708,19 @@ static Json::Value DumpSourceFileGroup(const LanguageData& data,
   return result;
 }
 
-static Json::Value DumpSourceFilesList(
-  cmGeneratorTarget* target, const std::string& config,
-  const std::map<std::string, LanguageData>& languageDataMap)
+static void PopulateFileGroupData(
+  cmGeneratorTarget* target, bool isInterfaceSources,
+  const std::vector<cmSourceFile*>& files, const std::string& config,
+  const std::map<std::string, LanguageData>& languageDataMap,
+  std::unordered_map<LanguageData, FileGroupSources>& fileGroups)
 {
-  // Collect sourcefile groups:
-
-  std::vector<cmSourceFile*> files;
-  target->GetSourceFiles(files, config);
-
-  std::unordered_map<LanguageData, std::vector<std::string>> fileGroups;
   for (cmSourceFile* file : files) {
     LanguageData fileData;
     fileData.Language = file->GetLanguage();
-    if (!fileData.Language.empty()) {
-      const LanguageData& ld = languageDataMap.at(fileData.Language);
+    if (!fileData.Language.empty() || isInterfaceSources) {
+      const LanguageData& ld = isInterfaceSources
+        ? languageDataMap.at(kInterfaceSourcesLanguageDataKey)
+        : languageDataMap.at(fileData.Language);
       cmLocalGenerator* lg = target->GetLocalGenerator();
       cmGeneratorExpressionInterpreter genexInterpreter(
         lg, target, config, target->GetName(), fileData.Language);
@@ -733,10 +748,14 @@ static Json::Value DumpSourceFilesList(
         lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file);
 
         for (const auto& include : includes) {
+          // INTERFACE_LIBRARY targets do not support the
+          // IsSystemIncludeDirectory call so just set it to false.
+          const bool isSystemInclude = isInterfaceSources
+            ? false
+            : target->IsSystemIncludeDirectory(include, config,
+                                               fileData.Language);
           fileData.IncludePathList.push_back(
-            std::make_pair(include,
-                           target->IsSystemIncludeDirectory(
-                             include, config, fileData.Language)));
+            std::make_pair(include, isSystemInclude));
         }
       }
 
@@ -765,14 +784,71 @@ static Json::Value DumpSourceFilesList(
     }
 
     fileData.IsGenerated = file->GetPropertyAsBool("GENERATED");
-    std::vector<std::string>& groupFileList = fileGroups[fileData];
-    groupFileList.push_back(file->GetFullPath());
+    FileGroupSources& groupFileList = fileGroups[fileData];
+    groupFileList.IsInterfaceSources = isInterfaceSources;
+    groupFileList.Files.push_back(file->GetFullPath());
+  }
+}
+
+static Json::Value DumpSourceFilesList(
+  cmGeneratorTarget* target, const std::string& config,
+  const std::map<std::string, LanguageData>& languageDataMap)
+{
+  const cmStateEnums::TargetType type = target->GetType();
+  std::unordered_map<LanguageData, FileGroupSources> fileGroups;
+
+  // Collect sourcefile groups:
+
+  std::vector<cmSourceFile*> files;
+  if (type == cmStateEnums::INTERFACE_LIBRARY) {
+    // INTERFACE_LIBRARY targets do not create all the data structures
+    // associated with regular targets. If properties are explicitly specified
+    // for files in INTERFACE_SOURCES then we can get them through the Makefile
+    // rather than the target.
+    files = target->Makefile->GetSourceFiles();
+  } else {
+    target->GetSourceFiles(files, config);
+    PopulateFileGroupData(target, false /* isInterfaceSources */, files,
+                          config, languageDataMap, fileGroups);
+  }
+
+  // Collect interface sourcefile groups:
+
+  auto targetProp = target->Target->GetProperty("INTERFACE_SOURCES");
+  if (targetProp != nullptr) {
+    cmGeneratorExpressionInterpreter genexInterpreter(
+      target->GetLocalGenerator(), target, config, target->GetName(), "");
+
+    auto evaluatedSources = cmsys::SystemTools::SplitString(
+      genexInterpreter.Evaluate(targetProp, "INTERFACE_SOURCES"), ';');
+
+    std::map<std::string, cmSourceFile*> filesMap;
+    for (auto file : files) {
+      filesMap[file->GetFullPath()] = file;
+    }
+
+    std::vector<cmSourceFile*> interfaceSourceFiles;
+    for (const std::string& interfaceSourceFilePath : evaluatedSources) {
+      auto entry = filesMap.find(interfaceSourceFilePath);
+      if (entry != filesMap.end()) {
+        // use what we have since it has all the associated properties
+        interfaceSourceFiles.push_back(entry->second);
+      } else {
+        interfaceSourceFiles.push_back(
+          new cmSourceFile(target->Makefile, interfaceSourceFilePath));
+      }
+    }
+
+    PopulateFileGroupData(target, true /* isInterfaceSources */,
+                          interfaceSourceFiles, config, languageDataMap,
+                          fileGroups);
   }
 
   const std::string baseDir = target->Makefile->GetCurrentSourceDirectory();
   Json::Value result = Json::arrayValue;
   for (auto const& it : fileGroups) {
-    Json::Value group = DumpSourceFileGroup(it.first, it.second, baseDir);
+    Json::Value group = DumpSourceFileGroup(
+      it.first, it.second.IsInterfaceSources, it.second.Files, baseDir);
     if (!group.isNull()) {
       result.append(group);
     }
@@ -883,6 +959,59 @@ static Json::Value DumpCTestConfigurationsList(const cmake* cm)
   return result;
 }
 
+static void GetTargetProperty(
+  cmGeneratorExpressionInterpreter& genexInterpreter,
+  cmGeneratorTarget* target, const char* propertyName,
+  std::vector<std::string>& propertyValue)
+{
+  auto targetProp = target->Target->GetProperty(propertyName);
+  if (targetProp != nullptr) {
+    propertyValue = cmsys::SystemTools::SplitString(
+      genexInterpreter.Evaluate(targetProp, propertyName), ';');
+  }
+}
+
+static void CreateInterfaceSourcesEntry(
+  cmLocalGenerator* lg, cmGeneratorTarget* target, const std::string& config,
+  std::map<std::string, LanguageData>& languageDataMap)
+{
+  LanguageData& ld = languageDataMap[kInterfaceSourcesLanguageDataKey];
+  ld.Language = "";
+
+  cmGeneratorExpressionInterpreter genexInterpreter(lg, target, config,
+                                                    target->GetName(), "");
+  std::vector<std::string> propertyValue;
+  GetTargetProperty(genexInterpreter, target, "INTERFACE_INCLUDE_DIRECTORIES",
+                    propertyValue);
+  for (std::string const& i : propertyValue) {
+    ld.IncludePathList.push_back(
+      std::make_pair(i, false /* isSystemInclude */));
+  }
+
+  propertyValue.clear();
+  GetTargetProperty(genexInterpreter, target,
+                    "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", propertyValue);
+  for (std::string const& i : propertyValue) {
+    ld.IncludePathList.push_back(
+      std::make_pair(i, true /* isSystemInclude */));
+  }
+
+  propertyValue.clear();
+  GetTargetProperty(genexInterpreter, target, "INTERFACE_COMPILE_OPTIONS",
+                    propertyValue);
+  for (const auto& s : propertyValue) {
+    ld.Flags += " " + s;
+  }
+
+  propertyValue.clear();
+  GetTargetProperty(genexInterpreter, target, "INTERFACE_COMPILE_DEFINITIONS",
+                    propertyValue);
+  if (!propertyValue.empty()) {
+    std::set<std::string> defines(propertyValue.begin(), propertyValue.end());
+    ld.SetDefines(defines);
+  }
+}
+
 static Json::Value DumpTarget(cmGeneratorTarget* target,
                               const std::string& config)
 {
@@ -912,11 +1041,6 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
   result[kTYPE_KEY] = typeName;
   result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
   result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
-
-  if (type == cmStateEnums::INTERFACE_LIBRARY) {
-    return result;
-  }
-
   result[kFULL_NAME_KEY] = target->GetFullName(config);
 
   if (target->Target->GetHaveInstallRule()) {
@@ -1003,8 +1127,22 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
   }
 
   std::set<std::string> languages;
-  target->GetLanguages(languages, config);
   std::map<std::string, LanguageData> languageDataMap;
+  if (type == cmStateEnums::INTERFACE_LIBRARY) {
+    // INTERFACE_LIBRARY targets do not create all the data structures
+    // associated with regular targets. If properties are explicitly specified
+    // for files in INTERFACE_SOURCES then we can get them through the Makefile
+    // rather than the target.
+    for (auto file : target->Makefile->GetSourceFiles()) {
+      const std::string& language = file->GetLanguage();
+      if (!language.empty()) {
+        languages.insert(language);
+      }
+    }
+  } else {
+    target->GetLanguages(languages, config);
+  }
+
   for (std::string const& lang : languages) {
     LanguageData& ld = languageDataMap[lang];
     ld.Language = lang;
@@ -1020,6 +1158,11 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
     }
   }
 
+  if (target->Target->GetProperty("INTERFACE_SOURCES") != nullptr) {
+    // Create an entry in the languageDataMap for interface sources.
+    CreateInterfaceSourcesEntry(lg, target, config, languageDataMap);
+  }
+
   Json::Value sourceGroupsValue =
     DumpSourceFilesList(target, config, languageDataMap);
   if (!sourceGroupsValue.empty()) {

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a7e94d6f7b74eeb165cab39f3aeeaba690160ef
commit 7a7e94d6f7b74eeb165cab39f3aeeaba690160ef
Author:     David Faure <faure at kde.org>
AuthorDate: Thu Aug 30 19:52:19 2018 +0200
Commit:     David Faure <faure at kde.org>
CommitDate: Thu Aug 30 22:08:11 2018 +0200

    CPack (DEB/RPM): add test for per-component description/summmary.

diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake
index 18ef63c..b4bdb61 100644
--- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake
@@ -1,7 +1,7 @@
 function(checkPackageInfo_ TYPE FILE REGEX)
   getPackageInfo("${FILE}" "FILE_INFO_")
   if(NOT FILE_INFO_ MATCHES "${REGEX}")
-    message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'")
+    message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'; does not match '${REGEX}'")
   endif()
 endfunction()
 
@@ -24,3 +24,15 @@ checkPackageInfo_("name" "${FOUND_FILE_3}" ".*${name_}${whitespaces_}:${whitespa
 checkPackageInfo_("group" "${FOUND_FILE_1}" ".*${group_}${whitespaces_}:${whitespaces_}default")
 checkPackageInfo_("group" "${FOUND_FILE_2}" ".*${group_}${whitespaces_}:${whitespaces_}second_group")
 checkPackageInfo_("group" "${FOUND_FILE_3}" ".*${group_}${whitespaces_}:${whitespaces_}default")
+
+# check package summaries (not available in DEB)
+if(GENERATOR_TYPE STREQUAL "RPM")
+  checkPackageInfo_("summary" "${FOUND_FILE_1}" ".*Summary${whitespaces_}:${whitespaces_}Global summary")
+  checkPackageInfo_("summary" "${FOUND_FILE_2}" ".*Summary${whitespaces_}:${whitespaces_}Summary for pkg_2")
+  checkPackageInfo_("summary" "${FOUND_FILE_3}" ".*Summary${whitespaces_}:${whitespaces_}Global summary")
+endif()
+
+# check package description
+checkPackageInfo_("description" "${FOUND_FILE_1}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_1")
+checkPackageInfo_("description" "${FOUND_FILE_2}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_2")
+checkPackageInfo_("description" "${FOUND_FILE_3}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_3")
diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake
index 8719c0b..dc61d0a 100644
--- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake
+++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake
@@ -11,6 +11,13 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM")
   set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_${group_} "default")
   set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second")
   set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_${group_} "second_group")
+
+  set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_SUMMARY "Global summary") # not used for DEB
+  set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_SUMMARY "Summary for pkg_2") # not used for DEB
+
+  set(CPACK_COMPONENT_PKG_1_DESCRIPTION "Description for pkg_1")
+  set(CPACK_COMPONENT_PKG_2_DESCRIPTION "Description for pkg_2")
+  set(CPACK_COMPONENT_PKG_3_DESCRIPTION "Description for pkg_3")
 endif()
 
 install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1)

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

Summary of changes:
 Help/manual/cmake-server.7.rst                     |   7 +
 Source/cmServerDictionary.h                        |   1 +
 Source/cmServerProtocol.cxx                        | 223 +++++++++++++++++----
 Source/cmSystemTools.cxx                           | 101 ++++++----
 Source/cmSystemTools.h                             |   2 +
 .../tests/PER_COMPONENT_FIELDS/VerifyResult.cmake  |  14 +-
 .../CPack/tests/PER_COMPONENT_FIELDS/test.cmake    |   7 +
 7 files changed, 279 insertions(+), 76 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list