Commit Graph

79 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 089868a244 cmState: Record buildsystem target names in each directory
Maintain in the directory state the list of target names added to be
built.  These are normal, non-imported targets (but do include INTERFACE
libraries).
2016-09-19 10:55:18 -04:00
Daniel Pfeifer 6afd35b98a cmState: remove unused code
Remove the code that was used by cmOutputConverter exclusively.
2016-09-17 19:49:21 +02:00
Daniel Pfeifer a2af850ba6 fix a batch of include-what-you-use violations 2016-08-17 01:08:13 +02:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Tobias Hunger 63c0e92c93 cmState: Expose list of properties of values in the cache 2016-06-10 09:33:41 -04:00
Daniel Pfeifer 618fb23fc9 Pass arguments that are not modified as const&.
Use clang-tidy's performance-unnecessary-value-param checker to find
value parameter declarations of expensive to copy types that are not
modified inside the function.  Ignore findings in kwsys.
After applying the fix-its, manually change `const T&` to `T const&`.
2016-05-26 21:58:51 +02: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
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
Brad King 563bf9dd8a cmState: Remove unused entry point fields from snapshot data
This information is now kept in cmMakefile::Backtrace.
2016-04-18 09:21:19 -04:00
Brad King 7c36d2067b cmListFileBacktrace: Refactor storage to provide efficient value semantics
Since commit v3.4.0-rc1~321^2~2 (Genex: Store a backtrace, not a pointer
to one, 2015-07-08) we treat cmListFileBacktrace instances as
lightweight values.  This was true at the time only because the
backtrace information was kept in the cmState snapshot hierarchy.
However, that forced us to accumulate a lot of otherwise short-lived
snapshots just to have the backtrace fields available for reference by
cmListFileBacktrace instances.  Recent refactoring made backtrace
instances independent of the snapshot hierarchy to avoid accumulating
short-lived snapshots.  This came at the cost of making backtrace values
heavy again, leading to lots of string coying and slower execution.

Fix this by refactoring cmListFileBacktrace to provide value semantics
with efficient shared storage underneath.  Teach cmMakefile to maintain
its call stack using an instance of cmListFileBacktrace.  This approach
allows the current backtrace to be efficiently saved whenever it is
needed.

Also teach cmListFileBacktrace the notion of a file-level scope.  This
is useful for messages about the whole file (e.g. during parsing) that
are not specific to any line within it.  Push the CMakeLists.txt scope
for each directory and never pop it.  This ensures that we always have
some context information and simplifies cmMakefile::IssueMessage.
Push/pop a file-level scope as each included file is processed.  This
supersedes cmParseFileScope and improves diagnostic message context
information in a few places.  Fix the corresponding test cases to expect
the improved output.
2016-04-18 09:21:19 -04:00
Brad King 1f6bd8a93f cmState: Avoid accumulating snapshot storage for backtraces
Changes during post-3.3/pre-3.4 development refactored storage of most
configure-time information, including variable bindings and function
scopes.  All scopes (even short-lived) were kept persistently for
possible future debugging features, causing huge accumulated memory
usage.  This was mostly addressed by commit v3.4.1~4^2 (cmState: Avoid
accumulating snapshot storage for short-lived scopes, 2015-11-24).

Since then we still keep short-lived scopes when they are needed for a
backtrace.  This is because since commit v3.4.0-rc1~378^2
(cmListFileBacktrace: Implement in terms of cmState::Snapshot,
2015-05-29) backtraces have been lightweight objects that simply point
into the snapshot tree.  While the intention of this approach was to
avoid duplicating the call stack file path strings, the cost turned out
to be holding on to the entire call stack worth of scope snapshots,
which is much worse.

Furthermore, since commit v3.4.0-rc2~1^2 (cmIfCommand: Issue CMP0054
warning with appropriate context, 2015-10-20) all conditions used in
`if()` commands hold a backtrace for use in diagnostic messages.  Even
though the backtrace is short-lived it still causes the scope snapshot
to be kept.  This means that code like

    function(foo)
      if(0)
      endif()
    endfunction()

    foreach(i RANGE 1000000)
      foo()
    endforeach()

accumulates storage for the function call scope snapshots.

Fix this by partially reverting commit v3.4.0-rc1~378^2 and saving the
entire call stack during cmListFileBacktrace construction.  This way
we can avoid keeping short-lived scope snapshot storage in all cases.
2016-04-15 10:31:39 -04:00
Brad King 18b6676bff cmState: Add Snapshot method to get bottom of call stack
The bottom of the call stack is always a long-lived snapshot and can be
saved for later use with cmOutputConverter.
2016-04-15 10:31:39 -04:00
Brad King c54ed7813f cmState: Rename CallStack snapshots to IncludeFile 2016-04-12 16:08:24 -04:00
Brad King 9342a4c203 Merge branch 'reduce-cmState-accumulation' into reduce-cmState-accumulation-for-master 2015-11-25 12:33:06 -05:00
Brad King 5f860ebb67 cmState: Avoid accumulating snapshot storage for short-lived scopes
We need to keep only certain snapshot types and their ancestors.
Also keep those needed for backtraces.
2015-11-25 12:30:13 -05:00
Stephen Kelly 55474e6182 cmState: Move GetTargetTypeName from cmTarget. 2015-10-15 00:41:40 +02:00
Stephen Kelly eac15298a8 cmState: Move TargetType enum from cmTarget.
Mostly automated:

 values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType")
 for i in "${values[@]}"; do     git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
2015-10-15 00:41:39 +02:00
Stephen Kelly 2bf7de167f Subdirs: Initialize from parent before configuring.
Add new API for the subdirs command to cmState.

This fixes a regression introduced in commit f716460e (cmMakefile: Move
invokation to initialize snapshot., 2015-10-06).
2015-10-14 00:34:11 +02:00
Stephen Kelly 20b95ef8c8 cmState: Initialize default definitions immediately.
Don't leave this as cmMakefile responsibility.
2015-10-14 00:16:20 +02:00
Stephen Kelly 2c219bafc0 cmState: Initialize top level source directories immediately.
Don't leave this as cmMakefile responsibility.
2015-10-14 00:16:07 +02:00
Stephen Kelly 79a309d786 cmState: Port away from cmake instance. 2015-10-10 15:42:02 +02:00
Stephen Kelly e2eecae205 cmState: Move ParseCacheEntry from cmCacheManager. 2015-10-10 15:36:59 +02:00
Stephen Kelly b5212c68de cmState: Add API for cache version. 2015-10-10 15:36:58 +02:00
Stephen Kelly 6f02034e66 cmState: Make AddCacheEntry method private. 2015-10-10 15:36:58 +02:00
Stephen Kelly 062ed22ec4 cmState: Add cache file manipulation wrappers. 2015-10-10 15:36:58 +02:00
Stephen Kelly 28749903b6 cmState: Internalize the initialization of a snapshot from its parent. 2015-10-07 20:19:42 +02:00
Brad King 0d0b9b52f8 Merge topic 'cmState-ProjectName'
637c56b4 cmGlobalGenerator: Implement FillProjectMap in terms of cmState.
b3f2299e cmState: Move ProjectName from cmMakefile.
6ce940ac cmMakefile: Use std::string in ProjectName API.
e8c0341d cmMakefile: Out-of-line GetProjectName.
2015-08-27 10:04:09 -04:00
Brad King 6904b6efdc Merge topic 'rm-cmLocalGenerator-Children'
867b5be8 cmLocalGenerator: Remove unused Children member.
6c832219 cmLocalGenerator: Implement child traversal in terms of cmState.
3fcf3837 Makefiles: Remove valueless cast.
223f4a66 cmLocalGenerator: Simplify condition.
ae026f54 cmState: Store Children states in parent state.
2015-08-27 10:04:07 -04:00
Stephen Kelly b3f2299e06 cmState: Move ProjectName from cmMakefile. 2015-08-25 19:57:42 +02:00
Stephen Kelly ae026f5458 cmState: Store Children states in parent state. 2015-08-24 20:05:37 +02:00
Stephen Kelly af9fc27753 cmState: Make Snapshot EqualityComparable. 2015-08-24 20:03:29 +02:00
Stephen Kelly f4150bd88d cmState: Move directory Properties from cmMakefile. 2015-08-24 20:02:21 +02:00
Brad King 2370a99400 Merge topic 'cmState-definitions'
bff27391 cmState: Host variable definitions.
6954c893 cmState: Add a VariableScope snapshot type.
1fc645bd cmState: Add a Base snapshot type.
0f070dd3 cmMakefile: Decouple the container of cmDefinitions from scoping logic.
25e04ddf cmDefinitions: Implement in terms of cmLinkedTree.
4bbe261c cmMakefile: Extract InitializeVarScope method.
2015-08-24 10:07:04 -04:00
Stephen Kelly bff27391a9 cmState: Host variable definitions. 2015-08-23 19:05:11 +02:00
Stephen Kelly 55e3927634 cmState: Make it possible to order cmState::Snapshot. 2015-08-23 18:05:13 +02:00
Stephen Kelly 6954c8936f cmState: Add a VariableScope snapshot type.
Match the scopes currently used in cmMakefile for definitions.
2015-08-23 17:08:54 +02:00
Stephen Kelly 1fc645bd9c cmState: Add a Base snapshot type.
For completeness mostly.
2015-08-23 17:08:54 +02:00
Stephen Kelly 757a1f5408 cmState: Move PolicyState from cmMakefile.
Implement lexical scope checking in terms of the state stack instead
of barriers.
2015-08-02 08:56:57 +02:00
Stephen Kelly 348354333a cmState: Add Type for policy scope. 2015-08-02 08:56:57 +02:00
Stephen Kelly 0a01e6c6e7 cmState: Add Snapshot Type accessor. 2015-08-01 07:18:34 +02:00
Stephen Kelly 6ed9c7e024 cmState: Host buildsystem properties for directories. 2015-07-25 14:53:05 +02:00
Brad King 8f0a5d84e3 cmState: Fix compilation on IBM XL compiler
Delay use of the PositionType constructor until after SnapshotDataType
is fully defined.
2015-07-25 14:52:05 +02:00
Stephen Kelly 9ebc7502b2 cmState: Extract a Directory class.
Move Directory-scoped state accessors to it.  This will be expanded
with directory property state soon.
2015-07-18 19:37:58 +02:00
Stephen Kelly 27ec21dbb2 cmState: Forward-declare a type earlier. 2015-07-18 19:09:51 +02:00
Stephen Kelly 6361f68056 cmState: Store execution context.
Extend snapshot creation API to store the file being executed and the
entry point to get to that context.
2015-07-06 01:37:15 +02:00
Stephen Kelly 94704d759c cmState: Add GetCallStackParent method. 2015-07-05 16:56:36 +02:00
Stephen Kelly a8e5446024 cmState: Store snapshots for more different types.
Adjust cmMakefile implementation to create the snapshots.
2015-07-04 11:51:27 +02:00
Stephen Kelly 217c243db0 cmake: Update the current snapshot when Resetting.
This will matter when definitions are stored in the cmState.
2015-06-21 20:19:53 +02:00