[Cmake-commits] [cmake-commits] king committed cmMakefile.cxx 1.527 1.528 cmMakefile.h 1.262 1.263 cmOptionCommand.cxx 1.27 1.28 cmPolicies.cxx 1.48 1.49 cmPolicies.h 1.27 1.28 cmSetCommand.cxx 1.38 1.39 cmSetCommand.h 1.24 1.25

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Oct 8 14:56:17 EDT 2009


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

Modified Files:
	cmMakefile.cxx cmMakefile.h cmOptionCommand.cxx cmPolicies.cxx 
	cmPolicies.h cmSetCommand.cxx cmSetCommand.h 
Log Message:
Remove CMake Policy CMP0015 until it is revised

We revert commit "Create CMake Policy CMP0015 to fix set(CACHE)" because
the NEW behavior of the policy breaks a valid use case:

  # CMakeLists.txt
  option(BUILD_SHARED_LIBS "..." ON)
  add_library(mylib ...)
  set(BUILD_SHARED_LIBS OFF) # we want only mylib to be shared
  add_subdirectory(ThirdParty)

  # ThirdParty/CMakeLists.txt
  option(BUILD_SHARED_LIBS "..." ON)
  # uh, oh, with NEW behavior this dir uses shared libs!!!

We'll re-introduce the policy later with a different change in behavior
to resolve the motivating case, which was more subtle but less common.

See issue #9008.


Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C 2 -d -r1.27 -r1.28
*** cmPolicies.h	28 Sep 2009 15:42:48 -0000	1.27
--- cmPolicies.h	8 Oct 2009 18:56:15 -0000	1.28
***************
*** 51,55 ****
      CMP0013, // Duplicate binary directories not allowed
      CMP0014, // Input directories must have CMakeLists.txt
-     CMP0015, // set(CACHE) and option() make CACHE value visible
  
      // Always the last entry.  Useful mostly to avoid adding a comma
--- 51,54 ----

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.48
retrieving revision 1.49
diff -C 2 -d -r1.48 -r1.49
*** cmPolicies.cxx	2 Oct 2009 18:36:47 -0000	1.48
--- cmPolicies.cxx	8 Oct 2009 18:56:15 -0000	1.49
***************
*** 402,436 ****
      "The NEW behavior for this policy is to report an error.",
      2,8,0, cmPolicies::WARN);
- 
-     this->DefinePolicy(
-     CMP0015, "CMP0015",
-     "The set() CACHE mode and option() command make the cache value visible.",
-     "In CMake 2.6 and below the CACHE mode of the set() command and the "
-     "option() command did not expose the value from the named cache entry "
-     "if it was already set both in the cache and as a local variable.  "
-     "This led to subtle differences between first and later configurations "
-     "because a conflicting local variable would be overridden only when the "
-     "cache value was first created.  "
-     "For example, the code\n"
-     "  set(x 1)\n"
-     "  set(before ${x})\n"
-     "  set(x 2 CACHE STRING \"X\")\n"
-     "  set(after ${x})\n"
-     "  message(STATUS \"${before},${after}\")\n"
-     "would print \"1,2\" on the first run and \"1,1\" on future runs."
-     "\n"
-     "CMake 2.8.0 and above prefer to expose the cache value in all cases by "
-     "removing the local variable definition, but this changes behavior in "
-     "subtle cases when the local variable has a different value than that "
-     "exposed from the cache.  "
-     "The example above will always print \"1,2\"."
-     "\n"
-     "This policy determines whether the commands should always expose the "
-     "cache value.  "
-     "The OLD behavior for this policy is to leave conflicting local "
-     "variable values untouched and hide the true cache value.  "
-     "The NEW behavior for this policy is to always expose the cache value.",
-     2,8,0, cmPolicies::WARN);
- 
  }
  
--- 402,405 ----

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.262
retrieving revision 1.263
diff -C 2 -d -r1.262 -r1.263
*** cmMakefile.h	2 Oct 2009 17:52:01 -0000	1.262
--- cmMakefile.h	8 Oct 2009 18:56:15 -0000	1.263
***************
*** 287,295 ****
  
    /**
-    * Update the variable scope to make the cache definition visible.
-    */
-   void UseCacheDefinition(cmCacheManager::CacheIterator const& it);
- 
-   /**
     * Add bool variable definition to the build. 
     */
--- 287,290 ----

Index: cmSetCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetCommand.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C 2 -d -r1.24 -r1.25
*** cmSetCommand.h	28 Sep 2009 15:42:49 -0000	1.24
--- cmSetCommand.h	8 Oct 2009 18:56:15 -0000	1.25
***************
*** 65,72 ****
        "      [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])\n"
        "Within CMake sets <variable> to the value <value>.  <value> is expanded"
!       "  before <variable> is set to it.  If CACHE is present and <variable> "
!       "is not yet in the cache, then <variable> is put in the cache. If it is "
!       "already in the cache, <variable> is assigned the value stored in the "
!       "cache.  If CACHE is present, also <type> and <docstring> are "
        "required. <type> is used by the CMake GUI to choose a widget with "
        "which the user sets a value.  The value for <type> may be one of\n"
--- 65,70 ----
        "      [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])\n"
        "Within CMake sets <variable> to the value <value>.  <value> is expanded"
!       "  before <variable> is set to it.  If CACHE is present, then the "
!       "<variable> is put in the cache. <type> and <docstring> are then "
        "required. <type> is used by the CMake GUI to choose a widget with "
        "which the user sets a value.  The value for <type> may be one of\n"

Index: cmSetCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetCommand.cxx,v
retrieving revision 1.38
retrieving revision 1.39
diff -C 2 -d -r1.38 -r1.39
*** cmSetCommand.cxx	28 Sep 2009 15:42:49 -0000	1.38
--- cmSetCommand.cxx	8 Oct 2009 18:56:15 -0000	1.39
***************
*** 156,160 ****
      if(cache && type != cmCacheManager::INTERNAL && !force)
        {
-       this->Makefile->UseCacheDefinition(it);
        return true;
        }
--- 156,159 ----

Index: cmOptionCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmOptionCommand.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -C 2 -d -r1.27 -r1.28
*** cmOptionCommand.cxx	28 Sep 2009 15:42:48 -0000	1.27
--- cmOptionCommand.cxx	8 Oct 2009 18:56:15 -0000	1.28
***************
*** 54,58 ****
        {
        it.SetProperty("HELPSTRING", args[1].c_str());
-       this->Makefile->UseCacheDefinition(it);
        return true;
        }
--- 54,57 ----

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.527
retrieving revision 1.528
diff -C 2 -d -r1.527 -r1.528
*** cmMakefile.cxx	7 Oct 2009 18:37:19 -0000	1.527
--- cmMakefile.cxx	8 Oct 2009 18:56:15 -0000	1.528
***************
*** 1643,1697 ****
  }
  
- //----------------------------------------------------------------------------
- void cmMakefile::UseCacheDefinition(cmCacheManager::CacheIterator const& it)
- {
-   // Check for a local definition that might hide the cache value.
-   const char* name = it.GetName();
-   const char* def = this->Internal->VarStack.top().Get(name);
-   if(!def)
-     {
-     return;
-     }
- 
-   // If the visible value will change then check policy CMP0015.
-   const char* cache = it.GetValue();
-   if(strcmp(def, cache) != 0)
-     {
-     cmOStringStream e;
-     switch (this->GetPolicyStatus(cmPolicies::CMP0015))
-       {
-       case cmPolicies::WARN:
-         e << "Local variable \"" << name << "\" is set to\n"
-           << "  " << def << "\n"
-           << "but the CACHE entry of the same name is set to\n"
-           << "  " << cache << "\n"
-           << "The local variable is hiding the cache value."
-           << "\n"
-           << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0015);
-         this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
-       case cmPolicies::OLD:
-         // OLD behavior is to leave local definition.
-         return;
-       case cmPolicies::REQUIRED_IF_USED:
-       case cmPolicies::REQUIRED_ALWAYS:
-         e << "Local variable \"" << name << "\" is set to\n"
-           << "  " << def << "\n"
-           << "but the CACHE entry of the same name is set to\n"
-           << "  " << cache << "\n"
-           << "This command is removing the local variable to expose "
-           << "the cache value."
-           << "\n"
-           << this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0015);
-         this->IssueMessage(cmake::FATAL_ERROR, e.str());
-       case cmPolicies::NEW:
-         // NEW behavior is to remove local definition (done below).
-         break;
-       }
-     }
- 
-   // Remove the local definition to make the cache value visible.
-   this->RemoveDefinition(name);
- }
- 
  
  void cmMakefile::AddCacheDefinition(const char* name, const char* value,
--- 1643,1646 ----



More information about the Cmake-commits mailing list