[cmake-commits] king committed cmAddExecutableCommand.cxx 1.26 1.27 cmAddExecutableCommand.h 1.14 1.15 cmAddLibraryCommand.cxx 1.24 1.25 cmAddLibraryCommand.h 1.15 1.16 cmMakefile.cxx 1.356 1.357 cmMakefile.h 1.192 1.193

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Oct 2 11:14:02 EDT 2006


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv23561/Source

Modified Files:
	cmAddExecutableCommand.cxx cmAddExecutableCommand.h 
	cmAddLibraryCommand.cxx cmAddLibraryCommand.h cmMakefile.cxx 
	cmMakefile.h 
Log Message:
ENH: Added NOT_IN_ALL option for ADD_LIBRARY and ADD_EXECUTABLE to avoid building the targets by default.


Index: cmAddLibraryCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddLibraryCommand.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- cmAddLibraryCommand.h	15 Mar 2006 16:01:58 -0000	1.15
+++ cmAddLibraryCommand.h	2 Oct 2006 15:13:56 -0000	1.16
@@ -61,7 +61,7 @@
   virtual const char* GetFullDocumentation()
     {
     return
-      "  ADD_LIBRARY(libname [SHARED | STATIC | MODULE]\n"
+      "  ADD_LIBRARY(libname [SHARED | STATIC | MODULE] [NOT_IN_ALL]\n"
       "              source1 source2 ... sourceN)\n"
       "Adds a library target.  SHARED, STATIC or MODULE keywords are used "
       "to set the library type.  If the keyword MODULE appears, the library "
@@ -69,7 +69,10 @@
       "without dyld, MODULE is treated like SHARED.  If no keywords appear "
       " as the second argument, the type defaults to the current value of "
       "BUILD_SHARED_LIBS.  If this variable is not set, the type defaults "
-      "to STATIC.";
+      "to STATIC.\n"
+      "If NOT_IN_ALL is given the target will not be built by default. "
+      "It will be built only if the user explicitly builds the target or "
+      "another target that requires the target depends on it.";
     }
   
   cmTypeMacro(cmAddLibraryCommand, cmCommand);

Index: cmAddLibraryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddLibraryCommand.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cmAddLibraryCommand.cxx	15 Mar 2006 16:01:58 -0000	1.24
+++ cmAddLibraryCommand.cxx	2 Oct 2006 15:13:56 -0000	1.25
@@ -28,6 +28,7 @@
   // otherwise it defaults to static library.
   int shared = 
     !cmSystemTools::IsOff(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"));
+  bool in_all = true;
   
   std::vector<std::string>::const_iterator s = args.begin();
 
@@ -56,6 +57,11 @@
       ++s;
       shared = 2;
       }
+    else if(*s == "NOT_IN_ALL")
+      {
+      ++s;
+      in_all = false;
+      }
     }
 
   if (s == args.end())
@@ -74,7 +80,8 @@
     ++s;
     }
 
-  this->Makefile->AddLibrary(this->LibName.c_str(), shared, srclists);
+  this->Makefile->AddLibrary(this->LibName.c_str(), shared, srclists,
+                             in_all);
   
   return true;
 }

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- cmMakefile.h	28 Sep 2006 17:55:26 -0000	1.192
+++ cmMakefile.h	2 Oct 2006 15:13:57 -0000	1.193
@@ -176,7 +176,8 @@
    * Add an executable to the build.
    */
   cmTarget* AddExecutable(const char *exename, 
-                          const std::vector<std::string> &srcs);
+                          const std::vector<std::string> &srcs,
+                          bool in_all = true);
 
   /**
    * Add a utility to the build.  A utiltity target is a command that
@@ -285,7 +286,8 @@
    * Set the name of the library.
    */
   void AddLibrary(const char *libname, int shared,
-                  const std::vector<std::string> &srcs);
+                  const std::vector<std::string> &srcs,
+                  bool in_all = true);
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.356
retrieving revision 1.357
diff -u -d -r1.356 -r1.357
--- cmMakefile.cxx	2 Oct 2006 14:20:52 -0000	1.356
+++ cmMakefile.cxx	2 Oct 2006 15:13:56 -0000	1.357
@@ -1281,7 +1281,8 @@
 
 
 void cmMakefile::AddLibrary(const char* lname, int shared,
-                            const std::vector<std::string> &srcs)
+                            const std::vector<std::string> &srcs,
+                            bool in_all)
 {
   cmTarget target;
   switch (shared)
@@ -1303,7 +1304,7 @@
   // over changes in CMakeLists.txt, making the information stale and
   // hence useless.
   target.ClearDependencyInformation( *this, lname );
-  target.SetInAll(true);
+  target.SetInAll(in_all);
   target.GetSourceLists() = srcs;
   target.SetMakefile(this);
   this->AddGlobalLinkInformation(lname, target);
@@ -1313,11 +1314,12 @@
 }
 
 cmTarget* cmMakefile::AddExecutable(const char *exeName, 
-                                    const std::vector<std::string> &srcs)
+                                    const std::vector<std::string> &srcs,
+                                    bool in_all)
 {
   cmTarget target;
   target.SetType(cmTarget::EXECUTABLE, exeName);
-  target.SetInAll(true);
+  target.SetInAll(in_all);
   target.GetSourceLists() = srcs;
   target.SetMakefile(this);
   this->AddGlobalLinkInformation(exeName, target);

Index: cmAddExecutableCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddExecutableCommand.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cmAddExecutableCommand.h	10 Mar 2006 18:06:25 -0000	1.14
+++ cmAddExecutableCommand.h	2 Oct 2006 15:13:56 -0000	1.15
@@ -62,8 +62,8 @@
   virtual const char* GetFullDocumentation()
     {
     return
-      "  ADD_EXECUTABLE(exename [WIN32] [MACOSX_BUNDLE] source1\n"
-      "                 source2 ... sourceN)\n"
+      "  ADD_EXECUTABLE(exename [WIN32] [MACOSX_BUNDLE] [NOT_IN_ALL]\n"
+      "                 source1 source2 ... sourceN)\n"
       "This command adds an executable target to the current directory.  "
       "The executable will be built from the list of source files "
       "specified.\n"
@@ -86,6 +86,9 @@
       "  MACOSX_BUNDLE_SHORT_VERSION_STRING\n"
       "  MACOSX_BUNDLE_BUNDLE_VERSION\n"
       "  MACOSX_BUNDLE_COPYRIGHT\n"
+      "If NOT_IN_ALL is given the target will not be built by default. "
+      "It will be built only if the user explicitly builds the target or "
+      "another target that requires the target depends on it."
       ;
     }
 

Index: cmAddExecutableCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddExecutableCommand.cxx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmAddExecutableCommand.cxx	10 May 2006 17:50:44 -0000	1.26
+++ cmAddExecutableCommand.cxx	2 Oct 2006 15:13:56 -0000	1.27
@@ -31,6 +31,7 @@
   ++s;
   bool use_win32 = false;
   bool use_macbundle = false;
+  bool in_all = true;
   while ( s != args.end() )
     {
     if (*s == "WIN32")
@@ -43,6 +44,11 @@
       ++s;
       use_macbundle = true;
       }
+    else if(*s == "NOT_IN_ALL")
+      {
+      ++s;
+      in_all = false;
+      }
     else
       {
       break;
@@ -57,7 +63,8 @@
     }
 
   std::vector<std::string> srclists(s, args.end());
-  cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists); 
+  cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists,
+                                                in_all);
   if ( use_win32 )
     {
     tgt->SetProperty("WIN32_EXECUTABLE", "ON");



More information about the Cmake-commits mailing list