Commit Graph

547 Commits

Author SHA1 Message Date
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 b6ed71b17c cmMakefile: Move cmMakefileCall to .cxx file 2016-04-15 08:32:15 -04:00
Brad King 0e44f4894f Rename local target lookup methods to clarify purpose
Rename methods:

* `cmMakefile::Find{ => LocalNonAlias}Target`
* `cmLocalGenerator::Find{ => LocalNonAlias}GeneratorTarget`

These names clarify that they are for directory-local target names
and do not consider alias targets.
2016-04-01 15:44:16 -04:00
Brad King bc30f8b5e6 Fix lookup of an ALIAS target outside aliased target's directory (#16044)
Refactoring in commit v3.5.0-rc1~272^2~11 (cmTarget: Implement ALIAS in
terms of name mapping, 2015-10-25) accidentally introduced logic that
assumes ALIAS targets always reference targets in their own directory.
Fix this and add a test case.

The configure-step fix is that `cmMakefile::FindTarget` should not consider
aliases.  The purpose of this method is just to look up targets local to
a directory.  Since ALIAS and normal targets share a namespace we know a
locally defined target will never collide with an ALIAS target anyway.
The method has 3 call sites, and this change is safe for all of them:

* `cmInstallCommand::HandleTargetsMode`: Rejects aliases before the call.
* `cmFLTKWrapUICommand::FinalPass`: Should never have considered aliases.
* `cmMakefile::FindTargetToUse`: Falls back to a global lookup anyway.

The generate-step fix is that `cmLocalGenerator::FindGeneratorTarget`
should not consider aliases.  This method is the generate-step
equivalent to the above.  The method has 2 call sites, and this change
is safe for both of them:

* `cmInstallTargetGenerator::Compute`: Never uses an alias target name.
* `cmLocalGenerator::FindGeneratorTargetToUse`: Falls back to global lookup.

Reported-by: Matteo Settenvini <matteo@member.fsf.org>
2016-04-01 15:44:16 -04:00
Michael Scott deec3a3f06 Make message suppression more consistent.
Make the message suppression more consistent, by adding a check
for the message related CMake variables in cmake::IssueMessage,
which allows callers of IssueMessage other than the message
command to behave as expected. Also added a check for
CMAKE_SUPPRESS_DEVELOPER_WARNINGS in the message command to
mirror the deprecated message type behaviour.

Added a 'force' flag to the cmake::IssueMessage method, to
make the message suppression consistent, when setting the
message related CMake variables directly in a CMake file.

Expand message command tests to cover the AUTHOR_WARNING message
type as well.
2015-11-30 15:00:08 -05: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 d85c9176ae cmMakefile: Remove unused PolicyPushPop interfaces
The PolicyPushPop constructor arguments and Quiet method were used to
pass non-default arguments to PushPolicy and PopSnapshot, but no clients
use them anymore.
2015-11-24 19:38:33 -05:00
Brad King 8e1be7bf68 cmMakefile: Clarify purpose of method that pops a scope snapshot
The `PopPolicyBarrier` method is actually responsible for closing any
scope opened by creating a snapshot.  Rename it to `PopSnapshot` and add
a comment explaining the purpose of the poilcy-scope-specific part of
the method.
2015-11-24 19:38:31 -05:00
Stephen Kelly 7a6caae1a7 cmMakefile: Add imported target accessor 2015-10-27 07:44:25 +01:00
Stephen Kelly def6da616b cmLocalGenerator: Port FindGeneratorTarget away from GetGeneratorTarget 2015-10-27 07:44:24 +01:00
Stephen Kelly a67231ac11 cmTarget: Implement ALIAS in terms of name mapping
Remove mapping to cmTarget.
2015-10-27 07:44:24 +01:00
Stephen Kelly 780bff5279 cmake: Store hardcoded lists of sources and headers
Don't duplicate this in each cmMakefile.
2015-10-27 07:44:22 +01:00
Brad King d31d92bf1d Merge topic 'inline-cmMakeDepend-content'
c0969b10 cmMakeDepend: Inline into inheriting class.
6a1e7328 cmMakeDepend: Inline into only user.
00f50b00 cmMakeDepend: Inline into header.
3df749af Remove vestigial declarations.
3029c27e cmMakeDepend: Use public cmMakefile API.
2015-10-21 09:16:58 -04:00
Brad King e2d4bfef3f Merge topic 'fix-CMP0054-elseif-warning'
d6a03b47 cmIfCommand: Issue CMP0054 warning with appropriate context. (#15802)
2015-10-21 09:16:49 -04:00
Stephen Kelly 3df749af55 Remove vestigial declarations. 2015-10-21 00:19:57 +02:00
Stephen Kelly d6a03b475e cmIfCommand: Issue CMP0054 warning with appropriate context. (#15802)
Commit v3.4.0-rc1~494^2~4 (cmMakefile: Add API for elseif to create
backtrace., 2015-05-29) removed the use of cmMakefileCall to push/pop
execution context in favor of a new way to create backtraces.

However, a call to cmMakefile::GetExecutionContext is still invoked to
issue a contextual CMP0054 warning through cmConditionEvaluator.  As
the elseif is not part of the call stack, this resulted in trying to
access an empty vector.

Avoid the attempt at getting execution context when evaluating elseif by
constructing a context and backtrace on behalf of the cmConditionEvaluator
in all cases.
2015-10-20 23:40:12 +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 482b3811e4 cmTarget: Move link type enum out.
Remove a reason for generate time code to depend on the cmTarget header/type.
2015-10-15 00:41:22 +02:00
Brad King ad3ff60f4a Merge topic 'genex-generator-objects'
2293d43d cmLocalGenerator: Store cmGeneratorTargets.
488723f5 cmMakefile: Store container of cmExportBuildFileGenerators.
15834405 cmGeneratorExpression: Port interface to cmGeneratorTarget.
11165525 cmGeneratorExpression: Port to cmLocalGenerator.
2015-10-14 13:35:59 -04:00
Stephen Kelly 2293d43d00 cmLocalGenerator: Store cmGeneratorTargets.
Relieve cmMakefile of this responsibility.
2015-10-14 13:32:09 -04:00
Stephen Kelly 488723f5cd cmMakefile: Store container of cmExportBuildFileGenerators.
Set a cmLocalGenerator on each instance at compute time.  That will
soon be needed to access cmGeneratorTarget instances.

If a cmExportBuildFileGenerator is processed early during configure time as a
result of CMP0024 it must be removed from the list to process later at generate
time.
2015-10-14 13:32:09 -04: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 53d3a1c95a cmMakefile: Remove unused GetProjectName calls. 2015-10-09 00:00:18 +02:00
Stephen Kelly 6c02f62f75 Remove now-unused directory setters. 2015-10-07 20:19:42 +02:00
Stephen Kelly 203eada65e cmMakefile: Remove Configured state.
It is vestigial.
2015-09-27 12:08:07 +02:00
Stephen Kelly 83b8a927e5 cmMakefile: Remove cmLocalGenerator member. 2015-08-28 18:44:38 +02:00
Brad King 445077cbd2 Merge topic 'minor-cleanups'
7f551b4f cmGlobalGenerator: Implement VS6 check without virtual method.
cd6293cd cmMakefile: Fix style.
de6b2895 cmTarget: Remove vestigal method declaration.
e35ee02d cmTarget: Fix indentation.
00f2298f Reduce uses of cmMakefile::GetGlobalGenerator.
6254ba95 cmMakefile: Remove Internal class.
cf0a78dc cmGeneratorTarget: Issue messages through the local generator.
2015-08-27 10:04:12 -04:00
Stephen Kelly 6254ba9578 cmMakefile: Remove Internal class.
Move only remaining state to the direct class.
2015-08-25 22:19:57 +02:00
Stephen Kelly b3f2299e06 cmState: Move ProjectName from cmMakefile. 2015-08-25 19:57:42 +02:00
Stephen Kelly 6ce940ac97 cmMakefile: Use std::string in ProjectName API. 2015-08-25 19:55:34 +02:00
Stephen Kelly e8c0341d86 cmMakefile: Out-of-line GetProjectName. 2015-08-25 19:55:32 +02:00
Stephen Kelly f4150bd88d cmState: Move directory Properties from cmMakefile. 2015-08-24 20:02:21 +02:00
Gregor Jasny 744e6c497c Fix iOS Bundle layouts (#15669)
In contrast to Mac OS X App bundle layout the iOS one lacks the
Contents/MacOSX structure.  See also the Bundle Structures documentation
in Mac Developer Library:

  https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html

For now detect iOS targets by checking the SDK name/path.
2015-08-24 09:50:20 -04:00
Stephen Kelly 1689c91d8d cmMakefile: Remove unused method. 2015-08-07 00:32:15 +02:00
Brad King 73e3de381d Merge topic 'cmState-policies'
757a1f54 cmState: Move PolicyState from cmMakefile.
52dbe654 cmState: Record the end position of each directory.
65a5e0c6 cmLinkedTree: Add Clear API.
34835433 cmState: Add Type for policy scope.
af0de01c cmState: Remove call stack parent tracking.
6ae8b30b cmMakefile: Move policy barriers inside cmState scopes.
a5fc17b5 cmMakefile: Re-order policy entries and barriers.
0a01e6c6 cmState: Add Snapshot Type accessor.
f0005bb4 Tests: Verify generate-time policy scope behavior.
2015-08-06 09:38:24 -04: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 6c0e9ee276 cmMakefile: Store EvaluationFiles.
Relieve the cmGlobalGenerator of this responsibility.  Evaluate
the generator expressions in the context of the cmLocalGenerator.
2015-08-01 13:07:11 +02:00
Stephen Kelly 34b902a5a6 cmMakefile: Move method out of line. 2015-07-29 10:43:31 -04:00
Brad King aaa322a5cb cmMakefile: Return target from all AddUtilityCommand signatures 2015-07-29 10:43:31 -04:00
Brad King 98d6e9ec2d Merge topic 'use-generator-target'
57f03e59 Port some of the cmExportFileGenerator API to cmGeneratorTarget.
57ab0f70 Port cmExportBuildFileGenerator to cmGeneratorTarget.
570938cb cmExportTryCompileFileGenerator: Create cmGeneratorTargets.
ec38e4c8 Move GetFullPath to cmGeneratorTarget
dfb025bf Move GetLocationForBuild to cmGeneratorTarget.
9f2dca80 Move GetLocation to cmGeneratorTarget.
c7a8e74b Always access target location from a cmGeneratorTarget instance.
5b60eaf6 cmTarget: Restore the ImportedGetLocation method.
50b17a61 cmIncludeCommand: Populate the cmGeneratorTargets in deprecated path.
ba266858 cmTarget: Create cmGeneratorTargets before reading deprecated LOCATION.
5ab3a946 cmTarget: Inline GetLocation into deprecated callers.
496f4cd0 cmGlobalGenerator: Create cmGeneratorTargets before QtAutomoc.
de80993a cmGlobalGenerator: Create cmGeneratorTargets earlier.
611220f7 cmTarget: Use reliable test for CMP0024 and CMP0026 OLD.
bbad6ba5 cmLocalGenerator: Remove unused AddCustomCommandToCreateObject method.
e4dc83ad cmLocalGenerator: Remove unused AddBuildTargetRule method.
...
2015-07-28 10:08:50 -04:00
Stephen Kelly 496f4cd07d cmGlobalGenerator: Create cmGeneratorTargets before QtAutomoc.
Add cmGeneratorTargets as needed in the QtAutomoc processing.
2015-07-27 21:58:49 +02:00
Brad King cb21c548db Merge topic 'policy-refactor'
8329fc01 cmPolicies: Replace unused include.
5447ca1a cmMakefile: Remove CMP0001 handling to callers.
d0dcce15 cmMakefile: Simplify computation of ancient policy status.
658bfc5c cmMakefile: Remove redundant condition from policy status computation.
f4a25874 cmMakefile: Inline internal policy status method.
3c45471c cmPolicies: Enable RVO for internal method.
71e69fc9 cmPolicies: Store only state that users can set.
84e18056 cmMakefile: Convert recursion to loop.
2015-07-27 09:31:18 -04:00
Stephen Kelly 6ed9c7e024 cmState: Host buildsystem properties for directories. 2015-07-25 14:53:05 +02:00
Stephen Kelly f4a25874a2 cmMakefile: Inline internal policy status method. 2015-07-25 14:48:36 +02:00
Stephen Kelly 8d336875b3 cmMakefile: Use Ranges for buildsystem property access.
Don't return vector copies.
2015-07-22 20:25:48 +02:00
Stephen Kelly c7b39d06f9 cmMakefile: Split accessors for include directories and origins. 2015-07-22 20:25:47 +02:00
Stephen Kelly b2de25aded cmMakefile: Split accessors for compile options and origins. 2015-07-22 20:25:46 +02:00
Stephen Kelly d6239507b2 cmMakefile: Split accessors for compile definitions and origins. 2015-07-22 20:25:45 +02:00
Stephen Kelly ef17bbefd7 cmMakefile: Separate storage of buildsystem properties and their origins.
This simplifies some existing and upcoming algorithms.
2015-07-22 20:25:43 +02:00
Stephen Kelly a89c02ce3d cmMakefile: Out of line some API. 2015-07-22 20:06:23 +02:00