Commit Graph

174 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 797f7ad87d Merge topic 'else-after-return'
7b6349da CMake: don't use else after return
50ad1e0a CTest: don't use else after return
7f97a6c9 CPack: don't use else after return
4988b914 CursesDialog: don't use else after return
2016-08-23 09:00:00 -04:00
Daniel Pfeifer f29d184773 fix a batch of include-what-you-use violations 2016-08-23 08:56:59 -04:00
Daniel Pfeifer 7b6349da4d CMake: don't use else after return 2016-08-18 20:36:29 +02:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Brad King 473634eb1c Merge topic 'expose-cache-properties'
63c0e92c cmState: Expose list of properties of values in the cache
6eee2463 cmCacheEntry: Retrieve all properties of cache entries
120899c6 cmPropertyList: Add a way to retrieve all properties
7066218e cmake: Kill cmake::CacheManager and its getter
2016-06-13 10:03:05 -04:00
Daniel Pfeifer a16bf141bc Add missing braces around statements.
Apply fixits of clang-tidy's readability-braces-around-statements
checker.
2016-06-10 18:36:24 +02:00
Tobias Hunger 6eee24634b cmCacheEntry: Retrieve all properties of cache entries 2016-06-10 09:33:41 -04:00
Daniel Pfeifer 7f6b8d3399 Simplify boolean expressions
Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
2016-06-02 08:24:04 -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 0ac18d40c8 Remove `//------...` horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King 64b5520346 Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.

Find blocks of the form

    os <<
      "...\n"
      "...\n"
      ;

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'

Find blocks of the form

    os << "...\n"
       << "...\n"
       << "...\n";

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'

Surround such blocks with the pair

    /* clang-format off */
    ...
    /* clang-format on */

in order to protect them from update by clang-format.  Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
2016-05-06 14:25:55 -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
Brad King 180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Ashley Whetter 77cd74a3ea Print line number of cache parse errors (#11109)
Track the line number while parsing `CMakeCache.txt` files and include
it in a parse failure error message.
2016-01-19 10:19:42 -05:00
Stephen Kelly e2eecae205 cmState: Move ParseCacheEntry from cmCacheManager. 2015-10-10 15:36:59 +02:00
Stephen Kelly 435a2f3ccb cmCacheManager: Port away from cmake instance. 2015-10-10 15:36:58 +02:00
Stephen Kelly a02e53eb94 Inline unary LoadCache. 2015-10-10 15:36:57 +02:00
Stephen Kelly bec3487fa9 cmCacheManager: Remove cmMakefile dependency.
Update comment.
2015-10-10 15:36:57 +02:00
Stephen Kelly 5181fae264 cmPropertyMap: Remove chaining logic.
The chaining logic doesn't belong to the container, and the
CMakeInstance pointer doesn't need to be in cmPropertyMap.

Size goes from 56 to 48 bytes with GNU libstdc++-5.1.
2015-06-07 09:29:31 +02:00
Stephen Kelly 7c0aa672fe cmPropertyMap: Remove scope parameter from API where not used. 2015-06-07 09:29:30 +02:00
Brad King 6fbd4cae0d Use cmSystemTools::GetCMakeCommand() to get path to cmake internally
This is much simpler than finding a way to lookup "CMAKE_COMMAND"
everywhere.
2015-05-20 11:20:42 -04:00
Stephen Kelly f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Stephen Kelly 77f2807ce5 cmCacheManager: Rename GetCacheValue to GetInitializedCacheValue.
Being initialized is a requirement for this method to return something,
and is what differentiates it from using GetIterator with it.GetValue.
2015-04-07 23:25:44 +02:00
Brad King d3823263b2 Merge topic 'refactor-cache-api'
3347c5e4 Revert topic 'refactor-cache-api'
2015-04-07 17:15:52 -04:00
Brad King 3347c5e4f9 Revert topic 'refactor-cache-api'
This topic was never tested without some follow-up commits.  The
GetCacheEntryValue API returns a pointer to memory freed on return.
It will have to be revised along with the rest of the original topic.
2015-04-07 17:15:04 -04:00
Brad King 678493d60f Merge topic 'refactor-cache-api'
9410e24a cmCacheManager: Port consumers to non-iterator API.
7b7ae3b1 Port QtDialog to non-iterator cache API.
228c629c Port CursesDialog to non-iterator cache API.
2e50f5e7 cmMakefile: Port away from CacheEntry.Initialized.
e6224367 cmCacheManager: Add non-iterator-based API.
9ada4c04 cmCacheManager: Rename GetCacheValue to GetInitializedCacheValue.
1fe7f24c Add API for cache loading, deleting and saving to the cmake class.
08c642c6 cmMakefile: Remove cache version accessors.
cec8f97e cmMakefile: Simplify GetDefinitions implementation.
2015-04-07 16:04:05 -04:00
Stephen Kelly 9ada4c0433 cmCacheManager: Rename GetCacheValue to GetInitializedCacheValue.
Being initialized is a requirement for this method to return something,
and is what differentiates it from using GetIterator with it.GetValue.
2015-04-06 17:58:55 +02:00
Stephen Kelly c22f6c1504 Remove unused includes. 2015-04-06 14:41:05 +02:00
Stephen Kelly c37cf7fa9e cmCacheManager: Remove unused method 2015-04-05 10:26:10 +02:00
Stephen Kelly 64556e3dfa cmCacheManager: Remove unused overloads. 2015-04-05 10:26:10 +02:00
Stephen Kelly 23bb5d225b cmCacheManager: Remove use of intermediate overload. 2015-04-05 10:26:10 +02:00
Stephen Kelly 76207b0861 cmCacheManager: Replace loop with algorithm. 2015-02-20 21:26:18 +01:00
Stephen Kelly fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Brad King 2e953c7657 Merge topic 'fix--D-command-line-parsing'
aee7e4a0 cmCacheManager: parse -D flags more strictly
368e8de4 Tests: test -D parsing on the command line
2014-10-30 14:11:48 -04:00
Ben Boeckel aee7e4a03b cmCacheManager: parse -D flags more strictly
In the case of:

    -DCACHE_VARS=-DEXTERNAL_PROJECT_CMAKE_ARG:BOOL=TRUE

the variable is parsed out as:

    CACHE_VARS=-DEXTERNAL_PROJECT_CMAKE_ARG

because the parser allows '=' in the variable name. Disallow such a name
on the command line.
2014-10-20 12:17:19 -04:00
Nils Gladitz cc1139cc30 strings: Remove redundant calls to std::string::c_str()
Replacements were detected and performed by the clang tool
remove-cstr-calls on a linux build.
2014-10-15 14:54:05 +02:00
Brad King af34639724 Merge topic 'fix-cache-self-assignment'
1cd37527 cmCacheManager: Avoid cache entry self-assignment
326d15a3 cmake: Tolerate missing HELPSTRING on compiler change
2014-05-28 12:34:30 -04:00
Brad King 1cd3752729 cmCacheManager: Avoid cache entry self-assignment
Since commit bef93dc5 (Couple of changes: cache variables now have a map
of properties, 2002-09-11) the cmCacheManager::AddCacheDefinition method
accesses its map entry by reference.  However, the commit left the
original entry assignment at the end of the method.  With Apple Clang
5.1 and libc++ this self-assignment destroys the cache entry property
map.

Drop the self assignment.  Also drop the condition around the call to
UnwatchUnusedCli since it was a self-comparison that must always have
been true.
2014-05-27 16:12:05 -04:00
Stephen Kelly af8a1643c1 Remove c_str calls when using stream APIs.
Use an ad-hoc clang tool for matching the calls which should be
ported.
2014-03-11 15:03:50 +01:00
Ben Boeckel b3bf31a548 stringapi: Miscellaneous char* parameters 2014-03-08 13:05:37 -05: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 f3efa3cd16 stringapi: Use strings for cache paths as arguments 2014-03-08 13:05:32 -05:00
Ben Boeckel 3742bb0d32 stringapi: Use strings for variable names
Variable names are always generated by CMake and should never be NULL.
2014-03-08 13:05:28 -05:00
Ben Boeckel ec97ed7d0c stringapi: Use strings for property names
Property names are always generated by CMake and should never be NULL.
2014-03-08 13:05:28 -05:00
Brad King d2059d2511 cmVersion: Fix CMake_VERSION_ENCODE for date in patch level
Use a uint64_t to store encoded version numbers so we have plenty of
bits available.  Encode with room for up to 1000 minor releases between
major releases and to encode dates until the year 10000 in the patch
level.  This is necessary because CMake development versions prior to
release 2.8.0 used the date in the patch level, and this practice may be
restored after the 3.0 release.
2014-02-10 15:32:32 -05:00
Clinton Stimpson 5730710c86 Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.
Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
2014-01-07 09:27:44 -05:00
Brad King 399e9c46d8 Drop builtin property documentation
Drop all DefineProperty calls for non-chained properties.  Drop the
documentation from the chained ones.  The documentation for all
properties is now in Help/prop_*/*.rst files.
2013-10-16 09:22:36 -04:00
Stephen Kelly 273ecab96d CLI: Suppress the unused warning if the key value pair is cached.
It is common to specify a CMAKE_TOOLCHAIN_FILE and get a warning
for using it despite it not being used.

The WarnUnusedCliUnused test relies on the warning being emitted
each time cmake is run on an existing build. That behavior is changed
by this patch to warn only on the first invokation of CMake, and not
on subsequent invokations (because the variable is in the cache with
the same value). For that test, a clean target is added which clears
the cache and cause the warning to be emitted each time.

As the Ninja generator does not support the feature needed to test
this, it is not tested with that generator.
2013-06-04 12:38:56 +02:00
Andreas Mohr ddac8d3d2d Fix spelling and typos (affecting binary data / module messages) 2013-05-07 08:39:19 -04:00