Commit Graph

229 Commits

Author SHA1 Message Date
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Brad King 07f69bd5cc cmSystemTools: Add strverscmp
Add support for natural string order by comparing non-numerical
character directly and numerical number by firstly collecting contiguous
digits.  The order is defined by the `strverscmp(3)` manual [1].

[1] http://man7.org/linux/man-pages/man3/strverscmp.3.html

Inspired-by: Pierluigi Taddei <pierluigi.taddei@gmail.com>
2016-09-13 11:52:28 -04:00
Daniel Pfeifer a2af850ba6 fix a batch of include-what-you-use violations 2016-08-17 01:08:13 +02:00
Chuck Atkins 02d177c9cc Add additional <= and >= comparison operators
This adds the LESS_EQUAL, GREATER_EQUAL, and associated STR and VERSION
equivalents to use the combined <= and >= functionality.
2016-08-09 09:30:34 -04:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Kitware Robot d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Felix Geyer 49e82c15d5 Fix spelling typos in comments and documentation (#16037)
The Debian package checker tool (lintian) detected several typos in
CMake.
2016-03-29 14:31:02 -04:00
Brad King ffa2a8c967 cmSystemTools: Rename OUTPUT_NORMAL to OUTPUT_FORWARD to clarify its purpose
The OUTPUT_NORMAL value is not really "normal" and has only one caller.
Rename it to OUTPUT_FORWARD to clarify that we are explicitly forwarding
the output.
2016-01-19 15:47:48 -05:00
Brad King ad594de8cc cmSystemTools: Add VersionCompareEqual helper
Wrap a call to VersionCompare with OP_EQUAL.
2016-01-11 13:43:22 -05:00
Gilles Khouzam 61c472a287 cmSystemTools: Add VersionCompareGreater helper
Wrap a call to VersionCompare with OP_GREATER in a signature suitable
for use with std::sort.
2015-10-02 09:43:24 -04:00
Brad King 828c05b9f5 Ninja: Refactor lookup of cmcldeps location
This executable comes with CMake so just compute its location in
cmSystemTools instead of storing it in compiler information modules.
2015-09-18 10:01:25 -04:00
Brad King 907a919be1 cmSystemTools: Drop unused StringEndsWith method
It has no callers and we can inherit one from KWSys SystemTools anyway.
2015-09-02 10:17:21 -04:00
Gilles Khouzam ac0bb4333d VS: Windows Store/Phone package cert thumbprint
Add the PackageCertificateThumbprint property when there is a
certificate on a WindowsStore or Phone app.
2015-08-27 13:35:18 -04:00
Brad King bb7eefe4dd cmOutputConverter: Adopt EscapeWindowsShellArgument method
Move it out of cmSystemTools and into cmOutputConverter.
2015-07-08 09:00:00 -04:00
Brad King 8bf5a80b96 cmSystemTools: Add StringToULong helper
Convert a string to an unsigned integer and reject any extra input.
2015-06-30 10:21:37 -04:00
Brad King 356c26ebdf cmSystemTools: Teach RunSingleCommand to separate stdout and stderr
Extend the RunSingleCommand signature to capture stdout and stderr
separately.  Allow both to be captured to the same std::string
to preserve existing behavior.  Update all call sites to do this
so that this refactoring does not introduce functional changes.
2015-04-20 15:47:50 -04:00
Nils Gladitz d2cc580704 cmake: Teach "-E tar" command a "--format=" option
Allows specifying a libarchive defined archive format currently restricted to
7zip, gnutar, pax, paxr and zip.

The default is "paxr" (pax restricted).
2015-04-10 08:32:31 -04:00
Brad King 69ac6d2755 bootstrap: Enable color Makefile output
Build the needed infrastructure during bootstrap in order to allow
"cmake -E cmake_echo_color" to be used unconditionally during
generation.
2015-02-05 16:44:56 -05:00
Brad King 3a60c899fc cmake: Teach "-E tar" command a "--mtime=" option
Add an option to set the mtime of entries in a tarball so that one can
create a tarball with a consistent content hash (e.g. MD5) for a given
set of files regardless of their current timestamps on disk.  This will
be useful for submission of tarballs to CDash, which tracks content
hashes to avoid duplication.

Inspired-by: Bill Hoffman <bill.hoffman@kitware.com>
2015-01-19 14:16:19 -05:00
Ben Boeckel d811d238ab cmSystemTools: use an enumeration for compression formats
Juggling 3 booleans was unwieldy.
2015-01-12 09:36:25 -05:00
Ben Boeckel df16dcfb44 cmake -E tar: add support for .xz files with 'J' 2015-01-09 10:35:01 -05:00
Ruslan Baratov 97841dad2b file: Use 'long' to represent the parsed LOCK TIMEOUT value
Convert the StringToInt helper into a StringToLong helper with a 'long'
result type.  This will make the helper more useful to other callers
that want to use strtol.

While at it, also check errno after calling strtol in case the
conversion fails with a range error.
2014-12-05 12:59:37 -05:00
Ruslan Baratov 05d6531c7a cmSystemTools: Add StringToInt helper
Convert a string to a signed integer and reject any extra input.

Co-Author: Rolf Eike Beer <eike@sf-mail.de>
2014-12-03 09:47:26 -05:00
Brad King f52b5ae3c4 cmSystemTools: Add callback for Stderr
Factor a common callback type out of StdoutCallback.  Add an equivalent
StderrCallback.  While at it, use "size_t" for the data length instead
of "int".

Teach "ctest --build-and-test" to capture the Stderr callback because
output sent through it is part of the logical CMake process output.
2014-05-15 10:26:30 -04:00
Brad King 73b13f5641 cmSystemTools: Rename ErrorCallback to MessageCallback
Clarify that it is the callback for the cmSystemTools::Message API.
Rename callback clients too.
2014-05-15 10:24:21 -04:00
Ben Boeckel 270eb96df0 strings: Remove cmStdString references
Casts from std::string -> cmStdString were high on the list of things
taking up time. Avoid such implicit casts across function calls by just
using std::string everywhere.

The comment that the symbol name is too long is no longer relevant since
modern debuggers alias the templates anyways and the size is a
non-issue since the underlying methods are generated since it's
inherited.
2014-03-08 13:05:35 -05:00
Ben Boeckel 215b1addf0 stringapi: Take strings in escaping functions 2014-03-08 13:05:35 -05:00
Ben Boeckel 23e9b80f58 stringapi: Use strings for globbing parameters 2014-03-08 13:05:34 -05:00
Ben Boeckel 77f60392d9 stringapi: Accept strings when MD5 hashing data 2014-03-08 13:05:32 -05:00
Brad King 7b1f966a6c Windows: Make file delete/rename retry configurable
Several CMake operations need to replace files in rapid succession.
This commonly fails on Windows due to filesystem lock behavior so
we have retry loops.  No matter how many times we retry or how long
we delay there will inevitably be someone with an environment that
needs more.  Make the retry count and delay configurable in the
Windows Registry keys:

 {HKCU,HKLM}/Software/Kitware/CMake/Config

in DWORD values

 FilesystemRetryCount = Number of tries
 FilesystemRetryDelay = Delay in milliseconds between tries

Leave the feature undocumented for now to see how it goes.
2014-02-12 09:55:41 -05:00
Brad King 0814d0a655 cmSystemTools: Add PrintSingleCommand method
Add a method to print a command line for human reference by simply
double-quoting every argument.
2013-11-15 14:40:55 -05:00
Brad King ee6e4ac841 cmSystemTools: Add RunSingleCommand overload for std::vector<std::string> 2013-11-15 14:40:55 -05:00
Brad King d1526f825e Refactor internal resource location APIs and initialization
Rename cmSystemTools::FindExecutableDirectory to FindCMakeResources.
Teach it to compute the locations of cmake, ctest, cpack, ccmake, and
cmake-gui executables, and the location of CMAKE_ROOT.  Provide this
information from static cmSystemTools::Get<resource>() methods.
Refactor code that needs these locations to use the new APIs.

Teach FindCMakeResources to use the OS X system API to lookup the
executable location.  When running from the CMake build tree itself,
leave a file in the tree that FindCMakeResources can use to read the
location of the source tree.  This avoids the need to compile the source
tree location into a binary that may be installed and used without the
source tree.

Teach the QtDialog on OS X to create a "cmake-gui" symlink in the build
tree next to "cmake" and the other tools, as is already done in the
install tree for the application bundle.  This ensures a consistent set
of executables are available in one directory.
2013-11-12 08:23:35 -05:00
Brad King 765d783972 cmSystemTools: Drop old RunCommand method
All calls to this method have been replaced by newer infrastructure.
Remove it and the supporting cmWin32ProcessExecution class.
2013-10-19 07:25:43 -04:00
Brad King ec6df3675e Teach --help-* options to load documentation from .rst files
Install the Help directory next to Modules to make it available in CMake
distributions.  Use cmRST to read Help .rst documents and print them as
help output.

Add options

 --help-manual-list
 --help-manual

to list available manuals or print one of them.  Implement the options

 --help-commands
 --help-modules
 --help-policies
 --help-properties
 --help-variables

by mapping to the corresponding manual page.  Implement the options

 --help-command-list
 --help-module-list
 --help-policy-list
 --help-property-list
 --help-variable-list

by globbing the available Help .rst documents of the corresponding type
and reading their titles.  Implement the options

 --help-command
 --help-module
 --help-policy
 --help-property
 --help-variable

by globbing the matching Help .rst document(s) and printing them.
2013-10-16 09:22:35 -04:00
Patrick Gansterer 2b473d2eaa Add option to use stdout/stderr of original terminal in cmake --build
Pass the original file handles to the native tool when using the
--use-stderr option in the build command. This enables the
usage of advanced terminal features like colored output.
2013-07-29 08:52:54 +02:00
Pavel Shramov 551d3343cd cmDependsC: Collapse relative include paths
While calculating dependencies collapse sequences such as

 ../../../a/b/c/../../d/e/../../e/f

to avoid total path lengths over the Windows path length limit as much
as possible.
2013-06-26 10:14:31 -04:00
Stephen Kelly ad304a2f7d cmSystemTools: Fix typo in comment. 2013-06-11 09:52:30 +02:00
Brad King 3caf565d07 Merge topic 'rpath-on-mac'
dc1d025 OS X: Add test for rpaths on Mac.
8576b3f OS X: Add support for @rpath in export files.
00d71bd Xcode: Add rpath support in Xcode generator.
94e7fef OS X: Add RPATH support for Mac.
2013-06-03 09:56:44 -04:00
Clinton Stimpson 94e7fef226 OS X: Add RPATH support for Mac.
RPATH support is activated on targets that have the MACOSX_RPATH
property turned on.
For install time, it is also useful to set INSTALL_RPATH to help
find dependent libraries with an @rpath in their install name.

Also adding detection of rpath conflicts when using frameworks.
2013-06-03 09:42:05 -04:00
Andreas Mohr bf019d765d Fix spelling and typos (non-binary) 2013-05-07 08:39:19 -04:00
Clinton Stimpson 52ec845fce cmake-gui: Fix error status when interrupted.
Sometimes it wasn't returning an error and one could continue
with the generate generate as if no errors occurred, and even
with an incomplete configure step.
2012-09-04 08:52:06 -06:00
Brad King b10c5cbb87 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.
2012-04-24 16:56:14 -04:00
David Cole bada88e8e4 Merge branch 'target-include-directories' into ninja-generator 2012-02-22 16:21:48 -05:00
David Cole e65f39a59e Merge topic 'interrupt-bug-12649'
131eed6 cmake-gui: Improve interrupt granularity to fix bug 12649.
2012-02-14 16:14:35 -05:00
Peter Collingbourne 2cd36550b0 Add cmSystemTools::TrimWhitespace function 2012-02-02 23:04:38 +00:00
Stephen Kelly 9bffb3fcf4 Fix typos arguement -> argument. 2012-01-08 15:32:51 +01:00
Clinton Stimpson 131eed6607 cmake-gui: Improve interrupt granularity to fix bug 12649.
Instead of enabling interrupt only when a progress or message callback is called, add a new callback specifically for
interrupt.  This new callback is called from GetFatalErrorOccured() so cmake-gui can immediately report interrupt status
instead of calling queuing a call to cmSystemTools::SetFatalErrorOccured() and waiting for the progress or message
callback to be called to process that queued call.
2012-01-02 11:07:43 -07:00
Johan Björk 642f10066a RunSingleCommand: Add a OUTPUT_NORMAL flag.
OUTPUT_NORMAL does no processing of the output streams, it just passes
them through the same streams as they were received on.
2011-07-28 10:43:09 -04:00