CTest: Simplify environment save/restore

Replace use of AppendEnv/RestoreEnv pairs with instances of
SaveRestoreEnvironment.  Simplify the signature of AppendEnv and use it
in place of similar loops elsewhere.  Move the RestoreEnv implementation
inside the SaveRestoreEnvironment destructor which is the only place
left that calls it.
KWSys: Remove DateStamp

KWSys is no longer shared in projects via a server-side directory
symlink in CVS.  An automated nightly date stamp commit can no longer be
shared by multiple projects directly.  It needs a per-project replay
robot so the nightly commits end up needing N+1 robots instead of N.
Remove the DateStamp feature because it is no longer useful or
maintained by nightly commits.
ExternalProject: Avoid unnecessary git clones (#12564)

In the case of git, only track the repository in the
repository info dependency tracking file. Not the tag.

The download step should only re-run if the repository changes.
The download step should NOT re-run if the tag changes.

The update step is an 'always' re-running step, and so should
already re-run, unless it's been eliminated by use of

  UPDATE_COMMAND ""
try_compile: Cleanup temporary directories (#13160)

Since commit 4fbdce2b (try_compile: Use random executable file name,
2012-02-13) a different <target>.dir is used for each try-compile.
Cleanup the directories as well as their content to avoid accumulating
leftover temporary directories.
setup-stage: Optionally reconfigure topic stage

When the topic stage has already been configured present the current
configuration and prompt for optional reconfiguration.  While at it,
make the topic stage remote name configurable by the project.
Merge branch 'setup' into developer-setup
CTest: Escape MemCheck test output for XML (#13124)

Any output that goes through CleanTestOutput must be printed through
cmXMLSafe.
Documentation: Fix HTML anchor ranges

Generate anchors of the form

  <a name="..."></a>

instead of

  <a name="..."/>

to ensure browsers know that the anchor contains no text and do not try
to guess an end of the range.  Also make the "section_Index" and item
label anchors empty instead of containing the section header or label
text.  This ensures that the text associated with target anchors is not
rendered as if it were a hyperlink.
Require CMake 2.8.2 or higher to build CMake

Update the requirement specified in the top-level CMakeLists.txt file.
Drop the special-case minimum required version of 2.8.0 because the new
minimum subsumes it.

Revert commit 6c611c6b (libarchive: Restore CMake 2.6.3 as minimum
version, 2012-01-05) since our requirement now subsumes libarchive's.
Check{C,CXX}CompilerFlag: catch more Intel warning types (#12576)

Patch provided by Szilárd Páll.
KWSys: Fix SystemTools environment memory handling (#13156)

The SystemTools::PutEnv function tries to provide the "putenv" API
without leaking memory.  However, the kwsysDeletingCharVector singleton
frees memory that may still be referenced by the environment table,
having been placed there by putenv.  If any static destruction or
processing by an external tool happens after the singleton is destroyed
and accesses the environment it will read invalid memory.

Replace use of putenv with setenv/unsetenv when available.  The latter
manage internal copies of the values passed instead of referencing the
original memory.  When setenv/unsetenv are not available use putenv with
a singleton that removes its values from the environment before freeing
their memory.  This requires an "unputenv" implementation.  On at least
some platforms it must be written in terms of "putenv" because other
APIs are not available and direct modification of the "environ" global
is not safe (e.g. on Windows there is interaction with "wenviron").
Fortunately either putenv("A=") or putenv("A") will remove "A" from the
environment on these platforms.  On other platforms fall back to direct
manipulation of "environ".

Also add UnPutEnv to the API and add a test for the behavior of both.
VS10: Refactor custom commands to use WriteSource

All other source file elements are already written through WriteSource.
Refactor custom command source element generation into WriteSource too.
VS10: Simplify vcxproj.filter file generation

Remove the duplicate source file classification logic used to generate
the filter files.  Instead record during the main vcxproj file
generation the source files generated for each tool.  Also record
whether or not each source file is converted to a relative path.  Use
the recorded result during filter generation to ensure consistency
between the project file and filter file.
VS10: Convert paths normally unless forced to relative

Most CMake generators produce relative paths within the build tree and
full paths to files outside the build tree.  Make VS 10 and VS 11
project files consistent with this approach except for paths forced to
be relative to work around a VS 10 bug.
VS11: Do not use source path conversion workaround specific to VS 10

CMake <= 2.8.4 generated VS 10 project files with a relative path to
source files.  Then commit ed0075bd (Use relative paths for custom command
inputs, 2011-06-22) switched to using relative paths only for source files
holding custom commands and full paths for other sources.  This behavior
was inhereted by the VS 11 generator but is not needed so use the
workaround only for exactly VS 10.  Explain the behavior in comments.
VS10: Generate relative source paths when possible (#12570)

Since commit ed0075bd (Use relative paths for custom command inputs,
2011-06-22) CMake generates full paths to source files in VS 10 project
files to avoid trouble with deep source/build tree paths.  However, the VS
10 IDE will not populate the source file property dialog for a file
referenced by full path.  Instead use a relative path when possible.  When
not possible produce a detailed warning explaining the problem and
suggesting use of shorter directory paths.
ExternalProject: Refactor repeated code into function (#12564)

Add "private/internal-use-only" function _ep_get_step_stampfile
to get the name of the stamp file for a given step.

The functionality provided by this commit should be identical
to its parent commit.
ExternalProject: Avoid repeated git clone operations (#12564)

By tracking a stamp file within the git clone script itself.

Avoids a 2nd git clone operation after switching from Debug
to Release builds in Visual Studio, or vice-versa.
Intel: On Windows use /RTC1 instead of deprecated /GZ (#13174)
Support building shared libraries or modules without soname (#13155)

Add a boolean target property NO_SONAME which may be used to disable
soname for the specified shared library or module even if the platform
supports it.  This property should be useful for private shared
libraries or various plugins which live in private directories and have
not been designed to be found or loaded globally.

Replace references to <CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG> and
hard-coded -install_name flags with a conditional <SONAME_FLAG> which is
expanded to the value of the CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG
definition as long as soname supports is enabled for the target in
question.  Keep expanding CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG in
rules in case third party projects still use it.  Such projects would
not yet use NO_SONAME so the adjacent <TARGET_SONAME> will always be
expanded.  Make <TARGET_INSTALLNAME_DIR> NO_SONAME aware as well.  Since
-install_name is soname on OS X, this should not be a problem if this
variable is expanded only if soname is enabled.

The Ninja generator performs rule variable substitution only once
globally per rule to put its own placeholders.  Final substitution is
performed by ninja at build time.  Therefore we cannot conditionally
replace the soname placeholders on a per-target basis.  Rather than
omitting $SONAME from rules.ninja, simply do not write its contents for
targets which have NO_SONAME.  Since 3 variables are affected by
NO_SONAME ($SONAME, $SONAME_FLAG, $INSTALLNAME_DIR), set them only if
soname is enabled.