[Cmake-commits] CMake branch, next, updated. v3.0.0-rc2-1426-gdd464a2

Stephen Kelly steveire at gmail.com
Mon Mar 24 11:31:09 EDT 2014


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  dd464a2e4e4643c46a33ed0075614591d3463791 (commit)
       via  3528f3a3e3536ca4d8fbaa92ebae9f438d88dbd0 (commit)
       via  d14c4e88bfab9ed7c43a9084f9372df2fca37b06 (commit)
       via  23510bb22d725830404b574514592aec472033e7 (commit)
       via  49701d131ecc9ee18a91651f683ee95cfbd0b461 (commit)
       via  3ed1e60577b5e409ff6da5bcca712d0d9824745e (commit)
       via  efed55b63305ec0a6f1deb1932531b58040ba98e (commit)
      from  6a73d83176f40764440afab2da8a2dde655452f3 (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=dd464a2e4e4643c46a33ed0075614591d3463791
commit dd464a2e4e4643c46a33ed0075614591d3463791
Merge: 6a73d83 3528f3a
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Mon Mar 24 11:31:07 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Mar 24 11:31:07 2014 -0400

    Merge topic 'target-sources-refactor' into next
    
    3528f3a3 Genex: Only evaluate TARGET_OBJECTS to determine target sources.
    d14c4e88 cmGeneratorTarget: Compute target objects on demand
    23510bb2 cmTarget: Compute languages from object libraries on demand.
    49701d13 cmGeneratorTarget: Compute consumed object libraries on demand.
    3ed1e605 cmComputeTargetDepends: Track object library depends.
    efed55b6 cmTarget: Allow any generator expression in SOURCES property.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3528f3a3e3536ca4d8fbaa92ebae9f438d88dbd0
commit 3528f3a3e3536ca4d8fbaa92ebae9f438d88dbd0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Mar 20 15:37:12 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Mar 24 16:30:45 2014 +0100

    Genex: Only evaluate TARGET_OBJECTS to determine target sources.
    
    The output of this expression may contain macros for IDEs to replace
    such as $(Configuration), $(CURRENT_ARCH) etc.  To avoid generating
    content which is not usable in other contexts, report an error if
    there is an attempt to use it in other contexts.
    
    This commit may be reverted in the future if a solution to the
    above difference is implemented.

diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 17263d4..dfda8dc 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -190,4 +190,6 @@ property is non-empty::
   Content of ``...`` converted to a C identifier.
 ``$<TARGET_OBJECTS:objLib>``
   List of objects resulting from build of ``objLib``. ``objLib`` must be an
-  object of type ``OBJECT_LIBRARY``.
+  object of type ``OBJECT_LIBRARY``.  This expression may only be used in
+  the sources of :command:`add_library` and :command:`add_executable`
+  commands.
diff --git a/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst b/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst
deleted file mode 100644
index 853a803..0000000
--- a/Help/release/dev/file-GENERATE-TARGET_OBJECTS.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-file-GENERATE-TARGET_OBJECTS
-----------------------------
-
-* The :command:`file(GENERATE)` subcommand learned to evaluate the
-  ``TARGET_OBJECTS``
-  :manual:`generator expression <cmake-generator-expressions(7)>`.
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index e127f3a..d09e950 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -90,6 +90,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
   context.HadError = false;
   context.HadContextSensitiveCondition = false;
   context.HeadTarget = headTarget;
+  context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
   context.CurrentTarget = currentTarget ? currentTarget : headTarget;
   context.Backtrace = this->Backtrace;
 
@@ -124,7 +125,8 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
               cmListFileBacktrace const& backtrace,
               const std::string& input)
   : Backtrace(backtrace), Input(input),
-    HadContextSensitiveCondition(false)
+    HadContextSensitiveCondition(false),
+    EvaluateForBuildsystem(false)
 {
   cmGeneratorExpressionLexer l;
   std::vector<cmGeneratorExpressionToken> tokens =
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index d0a6aef..da64515 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -112,6 +112,11 @@ public:
     return this->HadContextSensitiveCondition;
   }
 
+  void SetEvaluateForBuildsystem(bool eval)
+  {
+    this->EvaluateForBuildsystem = eval;
+  }
+
 private:
   cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
               const std::string& input);
@@ -131,6 +136,7 @@ private:
   mutable std::set<std::string> SeenTargetProperties;
   mutable std::string Output;
   mutable bool HadContextSensitiveCondition;
+  bool EvaluateForBuildsystem;
 };
 
 #endif
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 669694c..b90d094 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -1251,6 +1251,16 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
                        const GeneratorExpressionContent *content,
                        cmGeneratorExpressionDAGChecker *) const
   {
+    if (!context->EvaluateForBuildsystem)
+      {
+      cmOStringStream e;
+      e << "The TARGET_OBJECTS generator expression may only be evaluated "
+        "by cmake itself.  It may not be evaluated by file(GENERATE), "
+        "install(FILES) etc.";
+      reportError(context, content->GetOriginalExpression(), e.str());
+      return std::string();
+      }
+
     std::string tgtName = parameters.front();
     cmGeneratorTarget* gt =
                 context->Makefile->FindGeneratorTargetToUse(tgtName.c_str());
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index a7099cb..54a2548 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -34,6 +34,7 @@ struct cmGeneratorExpressionContext
   bool Quiet;
   bool HadError;
   bool HadContextSensitiveCondition;
+  bool EvaluateForBuildsystem;
 };
 
 struct cmGeneratorExpressionDAGChecker;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 61260be..aeb477d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -732,6 +732,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src)
     this->Makefile->GetBacktrace(lfbt);
     cmGeneratorExpression ge(lfbt);
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+    cge->SetEvaluateForBuildsystem(true);
     this->Internal->SourceEntries.push_back(
                           new cmTargetInternals::TargetPropertyEntry(cge));
     }
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index b506853..758165c 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -258,17 +258,3 @@ set(CMP0044_TYPE NEW)
 add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-NEW)
 set(CMP0044_TYPE OLD)
 add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-OLD)
-
-add_library(objlib OBJECT objlib1.c objlib2.c)
-file(GENERATE
-  OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/objlib_files"
-  CONTENT "$<JOIN:$<TARGET_OBJECTS:objlib>,\n>\n"
-)
-add_custom_target(check_object_files ALL
-  COMMAND ${CMAKE_COMMAND}
-    "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/objlib_files"
-    -DTEST_CONFIGURATION=${CMAKE_BUILD_TYPE}
-    -DEXPECTED_NUM_OBJECTFILES=2
-    -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
-  DEPENDS objlib
-)
diff --git a/Tests/GeneratorExpression/check_object_files.cmake b/Tests/GeneratorExpression/check_object_files.cmake
deleted file mode 100644
index 889fe80..0000000
--- a/Tests/GeneratorExpression/check_object_files.cmake
+++ /dev/null
@@ -1,48 +0,0 @@
-
-if (NOT EXISTS ${OBJLIB_LISTFILE})
-  message(SEND_ERROR "Object listing file \"${OBJLIB_LISTFILE}\" not found!")
-endif()
-
-file(STRINGS ${OBJLIB_LISTFILE} objlib_files)
-
-list(LENGTH objlib_files num_objectfiles)
-if (NOT EXPECTED_NUM_OBJECTFILES EQUAL num_objectfiles)
-  message(SEND_ERROR "Unexpected number of entries in object list file (${num_objectfiles} instead of ${EXPECTED_NUM_OBJECTFILES})")
-endif()
-
-foreach(objlib_file ${objlib_files})
-  set(file_exists False)
-  if (EXISTS ${objlib_file})
-    set(file_exists True)
-  endif()
-
-  if (NOT file_exists)
-    if (objlib_file MATCHES ".(CURRENT_ARCH)")
-      string(REPLACE "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" "*" config_file "${objlib_file}")
-      string(REPLACE "$(PROJECT_NAME)" "GeneratorExpression" config_file "${config_file}")
-      string(REPLACE "$(CURRENT_ARCH)" "*" config_file "${config_file}")
-      file(GLOB_RECURSE files "${config_file}")
-      list(LENGTH files num_files)
-      if (NOT files)
-        message(SEND_ERROR "Got no files for expression ${config_file}")
-      endif()
-      set(file_exists True)
-    else()
-      foreach(config_macro "$(Configuration)" "$(OutDir)" "$(IntDir)")
-        string(REPLACE "${config_macro}" "${TEST_CONFIGURATION}" config_file "${objlib_file}")
-        list(APPEND attempts ${config_file})
-        if (EXISTS ${config_file})
-          set(file_exists True)
-        endif()
-      endforeach()
-    endif()
-  endif()
-
-  if (NOT file_exists)
-    if(attempts)
-      list(REMOVE_DUPLICATES attempts)
-      set(tried "  Tried ${attempts}")
-    endif()
-    message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}")
-  endif()
-endforeach()
diff --git a/Tests/GeneratorExpression/objlib1.c b/Tests/GeneratorExpression/objlib1.c
deleted file mode 100644
index aa8de0a..0000000
--- a/Tests/GeneratorExpression/objlib1.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-void objlib1()
-{
-
-}
diff --git a/Tests/GeneratorExpression/objlib2.c b/Tests/GeneratorExpression/objlib2.c
deleted file mode 100644
index 3c7307a..0000000
--- a/Tests/GeneratorExpression/objlib2.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-void objlib2()
-{
-
-}
diff --git a/Tests/RunCMake/TargetObjects/NoTarget-result.txt b/Tests/RunCMake/TargetObjects/BadContext-result.txt
similarity index 100%
rename from Tests/RunCMake/TargetObjects/NoTarget-result.txt
rename to Tests/RunCMake/TargetObjects/BadContext-result.txt
diff --git a/Tests/RunCMake/TargetObjects/BadContext-stderr.txt b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt
new file mode 100644
index 0000000..4d28c8e
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt
@@ -0,0 +1,17 @@
+CMake Error at BadContext.cmake:2 \(file\):
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:NoTarget>
+
+  The TARGET_OBJECTS generator expression may only be evaluated by cmake
+  itself.  It may not be evaluated by file\(GENERATE\), install\(FILES\) etc.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:NoTarget>
+
+  The TARGET_OBJECTS generator expression may only be evaluated by cmake
+  itself.  It may not be evaluated by file\(GENERATE\), install\(FILES\) etc.
diff --git a/Tests/RunCMake/TargetObjects/NoTarget.cmake b/Tests/RunCMake/TargetObjects/BadContext.cmake
similarity index 52%
rename from Tests/RunCMake/TargetObjects/NoTarget.cmake
rename to Tests/RunCMake/TargetObjects/BadContext.cmake
index f203c23..67962a4 100644
--- a/Tests/RunCMake/TargetObjects/NoTarget.cmake
+++ b/Tests/RunCMake/TargetObjects/BadContext.cmake
@@ -1,2 +1,4 @@
 
 file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:NoTarget>)
+
+install(FILES $<TARGET_OBJECTS:NoTarget> DESTINATION objects)
diff --git a/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt
deleted file mode 100644
index 2c4f877..0000000
--- a/Tests/RunCMake/TargetObjects/NoTarget-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at NoTarget.cmake:2 \(file\):
-  Error evaluating generator expression:
-
-    \$<TARGET_OBJECTS:NoTarget>
-
-  Objects of target "NoTarget" referenced but no such target exists.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
deleted file mode 100644
index bb83934..0000000
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at NotObjlibTarget.cmake:4 \(file\):
-  Error evaluating generator expression:
-
-    \$<TARGET_OBJECTS:StaticLib>
-
-  Objects of target "StaticLib" referenced but is not an OBJECT library.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
deleted file mode 100644
index c7f8a71..0000000
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-
-add_library(StaticLib empty.cpp)
-
-file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:StaticLib>)
diff --git a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
index 30b9fee..85c76e2 100644
--- a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
+++ b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
@@ -1,4 +1,3 @@
 include(RunCMake)
 
-run_cmake(NoTarget)
-run_cmake(NotObjlibTarget)
+run_cmake(BadContext)
diff --git a/Tests/RunCMake/TargetObjects/empty.cpp b/Tests/RunCMake/TargetObjects/empty.cpp
deleted file mode 100644
index bfbbdde..0000000
--- a/Tests/RunCMake/TargetObjects/empty.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int empty()
-{
-  return 0;
-}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d14c4e88bfab9ed7c43a9084f9372df2fca37b06
commit d14c4e88bfab9ed7c43a9084f9372df2fca37b06
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Mar 14 13:21:26 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Mar 24 16:30:45 2014 +0100

    cmGeneratorTarget: Compute target objects on demand
    
    Add a ComputeObjectMapping method to compute the object
    names.  It takes mapping to populate as an out-parameter so
    that it can be extended in the future with parameters
    relevant to generator expression evaluation.
    
    Remove the supporting cmGeneratorTarget::AddObject method. It is
    no longer needed as the container member is populated directly.
    
    The ComputeObjectMapping method is called whenever objects are
    requested from the cmGeneratorTarget.  Because the Xcode generator
    makes no such request, explicitly invoke the method from that
    generator so that the logic of checking for bad sources in object
    libraries is executed.
    
    In a follow-up, the UseObjectLibraries usage may be replaced by a
    true generator expression evaluator for TARGET_OBJECTS. That
    will require generators to use cmGeneratorTarget::GetExternalObjects
    which is not currently the case for Xcode and VS generators.

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 64ca863..321dd42 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -311,18 +311,36 @@ cmGeneratorTarget
 ::GetObjectSources(std::vector<cmSourceFile const*> &data) const
 {
   IMPLEMENT_VISIT(ObjectSources);
+
+  if (!this->Objects.empty())
+    {
+    return;
+    }
+
+  for(std::vector<cmSourceFile const*>::const_iterator it = data.begin();
+      it != data.end(); ++it)
+    {
+    this->Objects[*it];
+    }
+
+  this->LocalGenerator->ComputeObjectFilenames(this->Objects, this);
 }
 
-//----------------------------------------------------------------------------
-const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
+void cmGeneratorTarget::ComputeObjectMapping()
 {
-  return this->Objects[file];
+  if(!this->Objects.empty())
+    {
+    return;
+    }
+  std::vector<cmSourceFile const*> sourceFiles;
+  this->GetObjectSources(sourceFiles);
 }
 
-void cmGeneratorTarget::AddObject(cmSourceFile const* sf,
-                                  std::string const&name)
+//----------------------------------------------------------------------------
+const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
 {
-    this->Objects[sf] = name;
+  this->ComputeObjectMapping();
+  return this->Objects[file];
 }
 
 //----------------------------------------------------------------------------
@@ -334,6 +352,7 @@ void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
 //----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
 {
+  const_cast<cmGeneratorTarget*>(this)->ComputeObjectMapping();
   std::set<cmSourceFile const*>::const_iterator it
                                         = this->ExplicitObjectName.find(file);
   return it != this->ExplicitObjectName.end();
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index cb59783..38e6510 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -35,7 +35,6 @@ public:
   void GetObjectSources(std::vector<cmSourceFile const*> &) const;
   const std::string& GetObjectName(cmSourceFile const* file);
 
-  void AddObject(cmSourceFile const* sf, std::string const&name);
   bool HasExplicitObjectName(cmSourceFile const* file) const;
   void AddExplicitObjectName(cmSourceFile const* sf);
 
@@ -47,6 +46,8 @@ public:
   void GetCustomCommands(std::vector<cmSourceFile const*>&) const;
   void GetExpectedResxHeaders(std::set<std::string>&) const;
 
+  void ComputeObjectMapping();
+
   cmTarget* Target;
   cmMakefile* Makefile;
   cmLocalGenerator* LocalGenerator;
@@ -123,7 +124,7 @@ private:
   typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
   SourceEntriesType SourceEntries;
 
-  std::map<cmSourceFile const*, std::string> Objects;
+  mutable std::map<cmSourceFile const*, std::string> Objects;
   std::set<cmSourceFile const*> ExplicitObjectName;
   mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6caaee3..66ccf39 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1222,8 +1222,6 @@ void cmGlobalGenerator::Generate()
     this->LocalGenerators[i]->GenerateTargetManifest();
     }
 
-  this->ComputeGeneratorTargetObjects();
-
   this->ProcessEvaluationFiles();
 
   // Compute the inter-target dependencies.
@@ -1440,27 +1438,6 @@ void cmGlobalGenerator::CreateGeneratorTargets()
     }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeGeneratorTargetObjects()
-{
-  // Construct per-target generator information.
-  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
-    {
-    cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
-    cmGeneratorTargetsType targets = mf->GetGeneratorTargets();
-    for(cmGeneratorTargetsType::iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
-      if (ti->second->Target->IsImported()
-          || ti->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
-        {
-        continue;
-        }
-      cmGeneratorTarget* gt = ti->second;
-      this->ComputeTargetObjects(gt);
-      }
-    }
-}
 
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::ClearGeneratorMembers()
@@ -1522,29 +1499,6 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
-{
-  std::vector<cmSourceFile const*> objectSources;
-  gt->GetObjectSources(objectSources);
-
-  std::map<cmSourceFile const*, std::string> mapping;
-  for(std::vector<cmSourceFile const*>::const_iterator it
-      = objectSources.begin(); it != objectSources.end(); ++it)
-    {
-    mapping[*it];
-    }
-
-  gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
-
-  for(std::map<cmSourceFile const*, std::string>::const_iterator it
-      = mapping.begin(); it != mapping.end(); ++it)
-    {
-    assert(!it->second.empty());
-    gt->AddObject(it->first, it->second);
-    }
-}
-
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
 {
 }
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 668bb6b..54f5f3b 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -444,8 +444,6 @@ private:
   friend class cmake;
   void CreateGeneratorTargets(cmMakefile* mf);
   void CreateGeneratorTargets();
-  void ComputeGeneratorTargetObjects();
-  void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
   void ClearGeneratorMembers();
 
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 2a6e522..d9d4927 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -987,6 +987,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
     cmtarget.GetSourceFiles(classes);
     std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
 
+    gtgt->ComputeObjectMapping();
+
     std::vector<cmXCodeObject*> externalObjFiles;
     std::vector<cmXCodeObject*> headerFiles;
     std::vector<cmXCodeObject*> resourceFiles;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=23510bb22d725830404b574514592aec472033e7
commit 23510bb22d725830404b574514592aec472033e7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 18 19:23:45 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Mar 24 16:30:45 2014 +0100

    cmTarget: Compute languages from object libraries on demand.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index aea6446..61260be 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -608,13 +608,6 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
     if(src[0] == '$' && src[1] == '<')
       {
       this->AddSource(src);
-
-      if(cmHasLiteralPrefix(i->c_str(), "$<TARGET_OBJECTS:") &&
-         (*i)[i->size()-1] == '>')
-        {
-        std::string objLibName = i->substr(17, i->size()-18);
-        this->ObjectLibraries.push_back(objLibName);
-        }
       }
     else
       {
@@ -5013,6 +5006,53 @@ void cmTarget::GetLanguages(std::set<std::string>& languages) const
       languages.insert(lang);
       }
     }
+
+  std::vector<cmTarget*> objectLibraries;
+  std::vector<cmSourceFile const*> externalObjects;
+  if (this->Makefile->GetGeneratorTargets().empty())
+    {
+    // At configure-time, this method can be called as part of getting the
+    // LOCATION property or to export() a file to be include()d.  However
+    // there is no cmGeneratorTarget at configure-time, so search the SOURCES
+    // for TARGET_OBJECTS instead for backwards compatibility with OLD
+    // behavior of CMP0024 and CMP0026 only.
+    std::vector<std::string> srcs;
+    cmSystemTools::ExpandListArgument(this->GetProperty("SOURCES"), srcs);
+    for(std::vector<std::string>::const_iterator it = srcs.begin();
+        it != srcs.end(); ++it)
+      {
+      if (cmHasLiteralPrefix(*it, "$<TARGET_OBJECTS:")
+          && cmHasLiteralSuffix(*it, ">"))
+        {
+        std::string objLibName = it->substr(17, it->size()-18);
+        if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLibName))
+          {
+          objectLibraries.push_back(tgt);
+          }
+        }
+      }
+    }
+  else
+    {
+    cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator()
+                                ->GetGlobalGenerator()
+                                ->GetGeneratorTarget(this);
+    gt->GetExternalObjects(externalObjects);
+    for(std::vector<cmSourceFile const*>::const_iterator
+          i = externalObjects.begin(); i != externalObjects.end(); ++i)
+      {
+      std::string objLib = (*i)->GetObjectLibrary();
+      if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+        {
+        objectLibraries.push_back(tgt);
+        }
+      }
+    }
+  for(std::vector<cmTarget*>::const_iterator
+      i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
+    {
+    (*i)->GetLanguages(languages);
+    }
 }
 
 //----------------------------------------------------------------------------
@@ -6077,19 +6117,6 @@ cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const
   std::set<std::string> languages;
   // Get languages used in our source files.
   this->GetLanguages(languages);
-  // Get languages used in object library sources.
-  for(std::vector<std::string>::const_iterator
-      i = this->ObjectLibraries.begin();
-      i != this->ObjectLibraries.end(); ++i)
-    {
-    if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i))
-      {
-      if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
-        {
-        objLib->GetLanguages(languages);
-        }
-      }
-    }
   // Copy the set of langauges to the link implementation.
   for(std::set<std::string>::iterator li = languages.begin();
       li != languages.end(); ++li)
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 45fca53..fcbff93 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -137,10 +137,6 @@ public:
    */
   void GetSourceFiles(std::vector<std::string> &files) const;
   void GetSourceFiles(std::vector<cmSourceFile*> &files) const;
-  std::vector<std::string> const& GetObjectLibraries() const
-    {
-    return this->ObjectLibraries;
-    }
 
   /**
    * Add sources to the target.
@@ -686,7 +682,6 @@ private:
   std::vector<cmCustomCommand> PreLinkCommands;
   std::vector<cmCustomCommand> PostBuildCommands;
   TargetType TargetTypeValue;
-  std::vector<std::string> ObjectLibraries;
   LinkLibraryVectorType LinkLibraries;
   LinkLibraryVectorType PrevLinkedLibraries;
   bool LinkLibrariesAnalyzed;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49701d131ecc9ee18a91651f683ee95cfbd0b461
commit 49701d131ecc9ee18a91651f683ee95cfbd0b461
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 18 17:07:56 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Mar 24 16:30:45 2014 +0100

    cmGeneratorTarget: Compute consumed object libraries on demand.
    
    Remove up-front object library computation from cmGlobalGenerator.
    
    Adjust tests for message coming from the generator expression
    evaluation.

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 66f6bdf..64ca863 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -504,57 +504,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::LookupObjectLibraries()
-{
-  std::vector<std::string> const& objLibs =
-    this->Target->GetObjectLibraries();
-  for(std::vector<std::string>::const_iterator oli = objLibs.begin();
-      oli != objLibs.end(); ++oli)
-    {
-    std::string const& objLibName = *oli;
-    if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName))
-      {
-      if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
-        {
-        if(this->Target->GetType() != cmTarget::EXECUTABLE &&
-           this->Target->GetType() != cmTarget::STATIC_LIBRARY &&
-           this->Target->GetType() != cmTarget::SHARED_LIBRARY &&
-           this->Target->GetType() != cmTarget::MODULE_LIBRARY)
-          {
-          this->GlobalGenerator->GetCMakeInstance()
-            ->IssueMessage(cmake::FATAL_ERROR,
-                           "Only executables and non-OBJECT libraries may "
-                           "reference target objects.",
-                           this->Target->GetBacktrace());
-          return;
-          }
-        this->ObjectLibraries.push_back(objLib);
-        }
-      else
-        {
-        cmOStringStream e;
-        e << "Objects of target \"" << objLibName
-          << "\" referenced but is not an OBJECT library.";
-        this->GlobalGenerator->GetCMakeInstance()
-          ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                         this->Target->GetBacktrace());
-        return;
-        }
-      }
-    else
-      {
-      cmOStringStream e;
-      e << "Objects of target \"" << objLibName
-        << "\" referenced but no such target exists.";
-      this->GlobalGenerator->GetCMakeInstance()
-        ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                       this->Target->GetBacktrace());
-      return;
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetModuleDefinitionFile() const
 {
   std::string data;
@@ -566,9 +515,26 @@ std::string cmGeneratorTarget::GetModuleDefinitionFile() const
 void
 cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
 {
+  std::vector<cmSourceFile const*> objectFiles;
+  this->GetExternalObjects(objectFiles);
+  std::vector<cmTarget*> objectLibraries;
+  std::set<cmTarget*> emitted;
+  for(std::vector<cmSourceFile const*>::const_iterator
+      it = objectFiles.begin(); it != objectFiles.end(); ++it)
+    {
+    std::string objLib = (*it)->GetObjectLibrary();
+    if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+      {
+      if (emitted.insert(tgt).second)
+        {
+        objectLibraries.push_back(tgt);
+        }
+      }
+    }
+
   for(std::vector<cmTarget*>::const_iterator
-        ti = this->ObjectLibraries.begin();
-      ti != this->ObjectLibraries.end(); ++ti)
+        ti = objectLibraries.begin();
+      ti != objectLibraries.end(); ++ti)
     {
     cmTarget* objLib = *ti;
     cmGeneratorTarget* ogt =
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 53e27c5..cb59783 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -84,8 +84,6 @@ public:
    */
   void TraceDependencies();
 
-  void LookupObjectLibraries();
-
   /** Get sources that must be built before the given source.  */
   std::vector<cmSourceFile*> const*
   GetSourceDepends(cmSourceFile const* sf) const;
@@ -127,7 +125,6 @@ private:
 
   std::map<cmSourceFile const*, std::string> Objects;
   std::set<cmSourceFile const*> ExplicitObjectName;
-  std::vector<cmTarget*> ObjectLibraries;
   mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
 
   void ConstructSourceFileFlags() const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2f3c6c9..6caaee3 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1457,7 +1457,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects()
         continue;
         }
       cmGeneratorTarget* gt = ti->second;
-      gt->LookupObjectLibraries();
       this->ComputeTargetObjects(gt);
       }
     }
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
index f1fcbe8..7060c61 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
@@ -1,4 +1,8 @@
 CMake Error at BadSourceExpression2.cmake:1 \(add_library\):
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:DoesNotExist>
+
   Objects of target "DoesNotExist" referenced but no such target exists.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
index ad14a35..838b3d8 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
@@ -1,4 +1,8 @@
 CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:NotObjLib>
+
   Objects of target "NotObjLib" referenced but is not an OBJECT library.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ed1e60577b5e409ff6da5bcca712d0d9824745e
commit 3ed1e60577b5e409ff6da5bcca712d0d9824745e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 18 17:04:46 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Mar 24 16:30:45 2014 +0100

    cmComputeTargetDepends: Track object library depends.
    
    Relieve cmGeneratorTarget of that responsibility.

diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index b4dbce7..723988b 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -16,6 +16,7 @@
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
+#include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
 
@@ -213,6 +214,34 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
   {
   std::set<std::string> emitted;
   {
+  cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator()
+                                  ->GetGlobalGenerator()
+                                  ->GetGeneratorTarget(depender);
+  std::vector<cmSourceFile const*> objectFiles;
+  gt->GetExternalObjects(objectFiles);
+  for(std::vector<cmSourceFile const*>::const_iterator
+      it = objectFiles.begin(); it != objectFiles.end(); ++it)
+    {
+    std::string objLib = (*it)->GetObjectLibrary();
+    if (emitted.insert(objLib).second)
+      {
+      if(depender->GetType() != cmTarget::EXECUTABLE &&
+          depender->GetType() != cmTarget::STATIC_LIBRARY &&
+          depender->GetType() != cmTarget::SHARED_LIBRARY &&
+          depender->GetType() != cmTarget::MODULE_LIBRARY)
+        {
+        this->GlobalGenerator->GetCMakeInstance()
+          ->IssueMessage(cmake::FATAL_ERROR,
+                          "Only executables and non-OBJECT libraries may "
+                          "reference target objects.",
+                          depender->GetBacktrace());
+        return;
+        }
+      const_cast<cmTarget*>(depender)->AddUtility(objLib);
+      }
+    }
+  }
+  {
   std::vector<std::string> tlibs;
   depender->GetDirectLinkLibraries("", tlibs, depender);
   // A target should not depend on itself.
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 834f9fd..66f6bdf 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -528,7 +528,6 @@ void cmGeneratorTarget::LookupObjectLibraries()
                            this->Target->GetBacktrace());
           return;
           }
-        this->Target->AddUtility(objLib->GetName());
         this->ObjectLibraries.push_back(objLib);
         }
       else

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=efed55b63305ec0a6f1deb1932531b58040ba98e
commit efed55b63305ec0a6f1deb1932531b58040ba98e
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 18 16:40:46 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Mon Mar 24 16:30:45 2014 +0100

    cmTarget: Allow any generator expression in SOURCES property.
    
    Remove use of UseObjectLibraries from Makefile and Ninja generators. It
    is not needed now because those generators use GetExternalObjects
    which already contains the objects from object libraries.
    
    The VS10 generator calls both the UseObjectLibraries and the GetExternalObjects
    methods. Ensure that duplicates are not created by skipping objects
    from object libraries in handling of GetExternalObjects.
    
    Similarly, fix Xcode object handling by skipping external objects from
    OBJECT_LIBRARY usage as appropriate.
    
    The error message in the BadSourceExpression1 test is now reported
    by the generator expression evaluator, so it has different text.

diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst
index 231eeed..4ed10e1 100644
--- a/Help/command/add_executable.rst
+++ b/Help/command/add_executable.rst
@@ -35,8 +35,11 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on
 the created target.  See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
 target property for details.
 
-See the :manual:`cmake-buildsystem(7)` manual for more on defining
-buildsystem properties.
+Source arguments to ``add_executable`` may use "generator expressions" with
+the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
 
 --------------------------------------------------------------------------
 
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index 0944269..e93ef53 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -39,8 +39,10 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on
 the created target.  See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
 target property for details.
 
-See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem
-properties.
+Source arguments to ``add_library`` may use "generator expressions" with
+the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
 
 --------------------------------------------------------------------------
 
diff --git a/Help/release/dev/target-SOURCES-genex.rst b/Help/release/dev/target-SOURCES-genex.rst
index 1ca6f66..9a65101 100644
--- a/Help/release/dev/target-SOURCES-genex.rst
+++ b/Help/release/dev/target-SOURCES-genex.rst
@@ -5,3 +5,8 @@ target-SOURCES-genex
   :manual:`generator expression <cmake-generator-expressions(7)>`
   such as ``TARGET_OBJECTS`` when read at configure time, if
   policy :policy:`CMP0051` is ``NEW``.
+
+* The :prop_tgt:`SOURCES` target property now generally supports
+  :manual:`generator expression <cmake-generator-expressions(7)>`.  The
+  generator expressions may be used in the :command:`add_library` and
+  :command:`add_executable` commands.
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index fdf73d6..2a6e522 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1007,7 +1007,10 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
       if(filetype &&
          filetype->GetString() == "compiled.mach-o.objfile")
         {
-        externalObjFiles.push_back(xsf);
+        if ((*i)->GetObjectLibrary().empty())
+          {
+          externalObjFiles.push_back(xsf);
+          }
         }
       else if(this->IsHeaderFile(*i) ||
         (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) ||
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index e99f3a4..11e9679 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -324,6 +324,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
       i != classes.end(); i++)
     {
+    if (!(*i)->GetObjectLibrary().empty())
+      {
+      continue;
+      }
+
     // Add the file to the list of sources.
     std::string source = (*i)->GetFullPath();
     cmSourceGroup* sourceGroup =
@@ -398,6 +403,11 @@ void cmLocalVisualStudio6Generator
   for(std::vector<const cmSourceFile *>::const_iterator sf =
         sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
     {
+    if (!(*sf)->GetObjectLibrary().empty())
+      {
+      continue;
+      }
+
     std::string source = (*sf)->GetFullPath();
     const cmCustomCommand *command =
       (*sf)->GetCustomCommand();
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index e8562ca..8bac10d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1401,6 +1401,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
       i != classes.end(); i++)
     {
+    if (!(*i)->GetObjectLibrary().empty())
+      {
+      continue;
+      }
     // Add the file to the list of sources.
     std::string source = (*i)->GetFullPath();
     if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 6759d05..c520f9e 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -202,9 +202,6 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
     // Generate this object file's rule file.
     this->WriteObjectRuleFiles(**si);
     }
-
-  // Add object library contents as external objects.
-  this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 4319f3c..ae3bff4 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -520,17 +520,6 @@ cmNinjaTargetGenerator
     this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
     }
 
-  {
-  // Add object library contents as external objects.
-  std::vector<std::string> objs;
-  this->GeneratorTarget->UseObjectLibraries(objs);
-  for(std::vector<std::string>::iterator oi = objs.begin();
-      oi != objs.end(); ++oi)
-    {
-    this->Objects.push_back(ConvertToNinjaPath(oi->c_str()));
-    }
-  }
-
   this->GetBuildFileStream() << "\n";
 }
 
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 04ae5af..aea6446 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -551,15 +551,16 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files) const
       si != this->Internal->SourceEntries.end(); ++si)
     {
     std::vector<std::string> srcs;
-    cmSystemTools::ExpandListArgument((*si)->ge->GetInput(), srcs);
+    cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile,
+                                        "",
+                                        false,
+                                        this),
+                                      srcs);
+
     for(std::vector<std::string>::const_iterator i = srcs.begin();
         i != srcs.end(); ++i)
       {
       std::string src = *i;
-      if (cmGeneratorExpression::Find(src) != std::string::npos)
-        {
-        continue;
-        }
       cmSourceFile* sf = this->Makefile->GetOrCreateSource(src);
       std::string e;
       src = sf->GetFullPath(&e);
@@ -606,7 +607,14 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
     const char* src = i->c_str();
     if(src[0] == '$' && src[1] == '<')
       {
-      this->ProcessSourceExpression(*i);
+      this->AddSource(src);
+
+      if(cmHasLiteralPrefix(i->c_str(), "$<TARGET_OBJECTS:") &&
+         (*i)[i->size()-1] == '>')
+        {
+        std::string objLibName = i->substr(17, i->size()-18);
+        this->ObjectLibraries.push_back(objLibName);
+        }
       }
     else
       {
@@ -734,28 +742,11 @@ cmSourceFile* cmTarget::AddSource(const std::string& src)
     this->Internal->SourceEntries.push_back(
                           new cmTargetInternals::TargetPropertyEntry(cge));
     }
-  return this->Makefile->GetOrCreateSource(src);
-}
-
-
-
-//----------------------------------------------------------------------------
-void cmTarget::ProcessSourceExpression(std::string const& expr)
-{
-  if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") &&
-     expr[expr.size()-1] == '>')
+  if (cmGeneratorExpression::Find(src) != std::string::npos)
     {
-    std::string objLibName = expr.substr(17, expr.size()-18);
-    this->ObjectLibraries.push_back(objLibName);
-    this->AddSource(expr);
-    }
-  else
-    {
-    cmOStringStream e;
-    e << "Unrecognized generator expression:\n"
-      << "  " << expr;
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+    return 0;
     }
+  return this->Makefile->GetOrCreateSource(src);
 }
 
 //----------------------------------------------------------------------------
@@ -2886,6 +2877,14 @@ const char *cmTarget::GetProperty(const std::string& prop,
           {
           std::string objLibName = li->substr(17, li->size()-18);
 
+          if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+            {
+            ss << sep;
+            sep = ";";
+            ss << *li;
+            continue;
+            }
+
           bool addContent = false;
           bool noMessage = true;
           cmOStringStream e;
@@ -2920,6 +2919,12 @@ const char *cmTarget::GetProperty(const std::string& prop,
             ss << *li;
             }
           }
+        else if (cmGeneratorExpression::Find(*li) == std::string::npos)
+          {
+          ss << sep;
+          sep = ";";
+          ss << *li;
+          }
         else
           {
           cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index bb76b7f..8d10e7c 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1054,6 +1054,19 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
 
   std::vector<cmSourceFile const*> externalObjects;
   this->GeneratorTarget->GetExternalObjects(externalObjects);
+  for(std::vector<cmSourceFile const*>::iterator
+        si = externalObjects.begin();
+      si != externalObjects.end(); )
+    {
+    if (!(*si)->GetObjectLibrary().empty())
+      {
+      si = externalObjects.erase(si);
+      }
+    else
+      {
+      ++si;
+      }
+    }
   if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
     {
     // For VS >= 11 we use LinkObjects to avoid linking custom command
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 66b175a..b506853 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -166,7 +166,7 @@ add_library(imported4 SHARED IMPORTED)
 set_property(TARGET imported4 APPEND PROPERTY
   INCLUDE_DIRECTORIES $<TARGET_PROPERTY:imported3,INTERFACE_INCLUDE_DIRECTORIES>)
 
-add_executable(someexe empty.cpp)
+add_executable(someexe $<1:empty.cpp> $<0:does_not_exist>)
 add_executable(Alias::SomeExe ALIAS someexe)
 
 add_library(Alias::SomeLib ALIAS empty1)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
index a1cac36..859dc3f 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
@@ -1,6 +1,8 @@
 CMake Error at BadSourceExpression1.cmake:1 \(add_library\):
-  Unrecognized generator expression:
+  Error evaluating generator expression:
 
     \$<BAD_EXPRESSION>
+
+  Expression did not evaluate to a known generator expression
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

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

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list