[Cmake-commits] CMake branch, next, updated. v2.8.7-2268-g477edad

Brad King brad.king at kitware.com
Wed Jan 25 14:44:29 EST 2012


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  477edad8eb9f1d13e5e405766c2a363df6a7ecc8 (commit)
       via  f9c1c6225c4366918465b86e4c6976ecc266245f (commit)
       via  ca39c5cdd1ca28516791e00f213d6dee2179c6df (commit)
      from  62d2fd6dcd199f67a0c3ef5c279384d17fdbcfaa (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=477edad8eb9f1d13e5e405766c2a363df6a7ecc8
commit 477edad8eb9f1d13e5e405766c2a363df6a7ecc8
Merge: 62d2fd6 f9c1c62
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jan 25 14:44:16 2012 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jan 25 14:44:16 2012 -0500

    Merge topic 'imported-target-visibility' into next
    
    f9c1c62 Add test covering imported target scope rules
    ca39c5c Optionally allow IMPORTED targets to be globally visible


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9c1c6225c4366918465b86e4c6976ecc266245f
commit f9c1c6225c4366918465b86e4c6976ecc266245f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jan 25 14:04:26 2012 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jan 25 14:43:07 2012 -0500

    Add test covering imported target scope rules

diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt
index 20e6a3a..96b9972 100644
--- a/Tests/CMakeOnly/CMakeLists.txt
+++ b/Tests/CMakeOnly/CMakeLists.txt
@@ -16,3 +16,5 @@ add_CMakeOnly_test(CheckSymbolExists)
 add_CMakeOnly_test(CheckCXXSymbolExists)
 
 add_CMakeOnly_test(AllFindModules)
+
+add_CMakeOnly_test(TargetScope)
diff --git a/Tests/CMakeOnly/TargetScope/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/CMakeLists.txt
new file mode 100644
index 0000000..fa5d8e2
--- /dev/null
+++ b/Tests/CMakeOnly/TargetScope/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required (VERSION 2.8)
+project(TargetScope NONE)
+
+add_subdirectory(Sub)
+
+if(TARGET SubLibLocal)
+  message(FATAL_ERROR "SubLibLocal visible in top directory")
+endif()
+if(NOT TARGET SubLibGlobal)
+  message(FATAL_ERROR "SubLibGlobal not visible in top directory")
+endif()
+
+add_subdirectory(Sib)
diff --git a/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt
new file mode 100644
index 0000000..7f6f4e8
--- /dev/null
+++ b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt
@@ -0,0 +1,6 @@
+if(TARGET SubLibLocal)
+  message(FATAL_ERROR "SubLibLocal visible in sibling directory")
+endif()
+if(NOT TARGET SubLibGlobal)
+  message(FATAL_ERROR "SubLibGlobal not visible in sibling directory")
+endif()
diff --git a/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt
new file mode 100644
index 0000000..27318f5
--- /dev/null
+++ b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(SubLibLocal UNKNOWN IMPORTED)
+add_library(SubLibGlobal UNKNOWN IMPORTED GLOBAL)
+add_subdirectory(Sub)
+if(NOT TARGET SubLibLocal)
+  message(FATAL_ERROR "SubLibLocal not visible in own directory")
+endif()
+if(NOT TARGET SubLibGlobal)
+  message(FATAL_ERROR "SubLibGlobal not visible in own directory")
+endif()
diff --git a/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt
new file mode 100644
index 0000000..a351daa
--- /dev/null
+++ b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt
@@ -0,0 +1,6 @@
+if(NOT TARGET SubLibLocal)
+  message(FATAL_ERROR "SubLibLocal not visible in subdirectory")
+endif()
+if(NOT TARGET SubLibGlobal)
+  message(FATAL_ERROR "SubLibGlobal not visible in subdirectory")
+endif()

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca39c5cdd1ca28516791e00f213d6dee2179c6df
commit ca39c5cdd1ca28516791e00f213d6dee2179c6df
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jan 25 13:39:26 2012 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jan 25 14:42:31 2012 -0500

    Optionally allow IMPORTED targets to be globally visible
    
    Consider the case motivating commit e01cce28 (Allow add_dependencies()
    on imported targets, 2010-11-19).  An imported target references a file
    generated at build time by a custom target on which it depends.  Had the
    file been built directly using add_library or add_executable its target
    name would have been visible globally.  Therefore the imported target
    representing the file should be globally visible also.
    
    Teach the IMPORTED signature of add_(executable|library) to accept a new
    "GLOBAL" option to make the imported target visible globally.

diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index bac2430..6dd8e5c 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -29,6 +29,7 @@ bool cmAddExecutableCommand
   bool use_macbundle = false;
   bool excludeFromAll = false;
   bool importTarget = false;
+  bool importGlobal = false;
   while ( s != args.end() )
     {
     if (*s == "WIN32")
@@ -51,6 +52,11 @@ bool cmAddExecutableCommand
      ++s;
      importTarget = true;
      }
+    else if(importTarget && *s == "GLOBAL")
+      {
+      ++s;
+      importGlobal = true;
+      }
     else
       {
       break;
@@ -92,7 +98,8 @@ bool cmAddExecutableCommand
       }
 
     // Create the imported target.
-    this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE);
+    this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE,
+                                      importGlobal);
     return true;
     }
 
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index f90e826..6834f58 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -92,12 +92,12 @@ public:
       "\n"
       "The add_executable command can also create IMPORTED executable "
       "targets using this signature:\n"
-      "  add_executable(<name> IMPORTED)\n"
+      "  add_executable(<name> IMPORTED [GLOBAL])\n"
       "An IMPORTED executable target references an executable file located "
       "outside the project.  "
       "No rules are generated to build it.  "
       "The target name has scope in the directory in which it is created "
-      "and below.  "
+      "and below, but the GLOBAL option extends visibility.  "
       "It may be referenced like any target built within the project.  "
       "IMPORTED executables are useful for convenient reference from "
       "commands like add_custom_command.  "
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index efa29e6..9a776fb 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -31,6 +31,7 @@ bool cmAddLibraryCommand
     }
   bool excludeFromAll = false;
   bool importTarget = false;
+  bool importGlobal = false;
 
   std::vector<std::string>::const_iterator s = args.begin();
 
@@ -79,6 +80,11 @@ bool cmAddLibraryCommand
       ++s;
       importTarget = true;
       }
+    else if(importTarget && *s == "GLOBAL")
+      {
+      ++s;
+      importGlobal = true;
+      }
     else
       {
       break;
@@ -124,7 +130,7 @@ bool cmAddLibraryCommand
       }
 
     // Create the imported target.
-    this->Makefile->AddImportedTarget(libName.c_str(), type);
+    this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal);
     return true;
     }
 
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index 07fbb06..edca1bb 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -96,12 +96,13 @@ public:
       "\n"
       "The add_library command can also create IMPORTED library "
       "targets using this signature:\n"
-      "  add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED)\n"
+      "  add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED\n"
+      "              [GLOBAL])\n"
       "An IMPORTED library target references a library file located "
       "outside the project.  "
       "No rules are generated to build it.  "
       "The target name has scope in the directory in which it is created "
-      "and below.  "
+      "and below, but the GLOBAL option extends visibility.  "
       "It may be referenced like any target built within the project.  "
       "IMPORTED libraries are useful for convenient reference from "
       "commands like target_link_libraries.  "
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 124519a..8dce053 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1666,6 +1666,11 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name)
       {
       return i->second;
       }
+    i = this->ImportedTargets.find(name);
+    if ( i != this->ImportedTargets.end() )
+      {
+      return i->second;
+      }
     }
   return 0;
 }
@@ -2046,10 +2051,16 @@ cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target)
   return this->TargetDependencies[&target];
 }
 
-void cmGlobalGenerator::AddTarget(cmTargets::value_type &v)
+void cmGlobalGenerator::AddTarget(cmTarget* t)
 {
-  assert(!v.second.IsImported());
-  this->TotalTargets[v.first] = &v.second;
+  if(t->IsImported())
+    {
+    this->ImportedTargets[t->GetName()] = t;
+    }
+  else
+    {
+    this->TotalTargets[t->GetName()] = t;
+    }
 }
 
 void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index ded3345..1a0e41a 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -230,7 +230,7 @@ public:
   std::set<cmStdString> const& GetDirectoryContent(std::string const& dir,
                                                    bool needDisk = true);
 
-  void AddTarget(cmTargets::value_type &v);
+  void AddTarget(cmTarget* t);
 
   virtual const char* GetAllTargetName()         const { return "ALL_BUILD"; }
   virtual const char* GetInstallTargetName()       const { return "INSTALL"; }
@@ -333,6 +333,7 @@ protected:
 
   // All targets in the entire project.
   std::map<cmStdString,cmTarget *> TotalTargets;
+  std::map<cmStdString,cmTarget *> ImportedTargets;
 
   virtual const char* GetPredefinedTargetsFolder();
   virtual bool UseFolderProperty();
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7939d73..fdf5b31 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1937,7 +1937,7 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
   cmTarget& target = it->second;
   target.SetType(type, name);
   target.SetMakefile(this);
-  this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it);
+  this->LocalGenerator->GetGlobalGenerator()->AddTarget(&it->second);
   return &it->second;
 }
 
@@ -3894,7 +3894,8 @@ void cmMakefile::DefineProperties(cmake *cm)
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type)
+cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
+                              bool global)
 {
   // Create the target.
   cmsys::auto_ptr<cmTarget> target(new cmTarget);
@@ -3904,6 +3905,10 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type)
 
   // Add to the set of available imported targets.
   this->ImportedTargets[name] = target.get();
+  if(global)
+    {
+    this->LocalGenerator->GetGlobalGenerator()->AddTarget(target.get());
+    }
 
   // Transfer ownership to this cmMakefile object.
   this->ImportedTargetsOwned.push_back(target.get());
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 1236787..1c46a73 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -203,7 +203,8 @@ public:
   void RemoveDefineFlag(const char* definition);
 
   /** Create a new imported target with the name and type given.  */
-  cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type);
+  cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type,
+                              bool global);
 
   cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
 

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

Summary of changes:
 Source/cmAddExecutableCommand.cxx                  |    9 ++++++++-
 Source/cmAddExecutableCommand.h                    |    4 ++--
 Source/cmAddLibraryCommand.cxx                     |    8 +++++++-
 Source/cmAddLibraryCommand.h                       |    5 +++--
 Source/cmGlobalGenerator.cxx                       |   17 ++++++++++++++---
 Source/cmGlobalGenerator.h                         |    3 ++-
 Source/cmMakefile.cxx                              |    9 +++++++--
 Source/cmMakefile.h                                |    3 ++-
 Tests/CMakeOnly/CMakeLists.txt                     |    2 ++
 Tests/CMakeOnly/TargetScope/CMakeLists.txt         |   13 +++++++++++++
 Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt     |    6 ++++++
 Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt     |    9 +++++++++
 Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt |    6 ++++++
 13 files changed, 81 insertions(+), 13 deletions(-)
 create mode 100644 Tests/CMakeOnly/TargetScope/CMakeLists.txt
 create mode 100644 Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt
 create mode 100644 Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt
 create mode 100644 Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list