Commit Graph

667 Commits

Author SHA1 Message Date
Stephen Kelly dd11f72ced cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. 2015-08-07 00:32:15 +02:00
Brad King 370e2c6785 Merge topic 'refactor-evaluation-files'
12c3f248 cmGeneratorExpressionEvaluationFile: Require generator context.
6c0e9ee2 cmMakefile: Store EvaluationFiles.
2015-08-06 09:38:22 -04:00
Brad King 25ec835571 Merge topic 'fix-windows-version-detection'
d4736d53 Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1 (#15674)
2015-08-03 09:11:30 -04: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
Brad King d4736d53cd Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1 (#15674)
The GetVersionEx API is deprecated, so try RtlGetVersion first.

Co-Author: Christian Maaser
2015-07-31 09:12:41 -04:00
Stephen Kelly e5e5297018 cmInstallGenerator: Add a Compute() virtual hook. 2015-07-30 08:28:31 +02:00
Stephen Kelly 0368552d7f cmGlobalGenerator: Move QtAutogen handling to Compute(). 2015-07-30 08:28:31 +02:00
Stephen Kelly ff1019bfac cmGlobalGenerator: Move generation object creation to Compute(). 2015-07-30 08:28:30 +02:00
Stephen Kelly 2e94cba356 cmGlobalGenerator: Move FinalizeTargetCompileInfo to Compute(). 2015-07-29 10:43:33 -04:00
Stephen Kelly fb9355c50e cmGlobalGenerator: Return from Compute whether to generate. 2015-07-29 10:43:33 -04:00
Stephen Kelly 29e8b7bfcc cmGlobalGenerator: Create a new Compute step before generation.
Replace the DoGenerate method.
2015-07-29 10:43:33 -04:00
Stephen Kelly 1ef9b2b600 cmGlobalGenerator: Remove the TargetManifest member. 2015-07-29 10:43:32 -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 570938cbfd cmExportTryCompileFileGenerator: Create cmGeneratorTargets.
This is not a deprecated behavior, but only requires IMPORTED targets
be made.
2015-07-27 21:59:03 +02: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
Stephen Kelly de80993a20 cmGlobalGenerator: Create cmGeneratorTargets earlier. 2015-07-27 21:58:49 +02:00
Stephen Kelly 58811998fb cmGlobalGenerator: Add global targets at the end of Configure.
Rather than at the start of Generate.
2015-07-27 21:57:28 +02:00
Stephen Kelly 57a69f9341 cmGlobalGenerator: Extract method to create generator objects. 2015-07-27 20:09:39 +02:00
Stephen Kelly 0e0258c8b9 cmGlobalGenerator: Split creation of generator object from initialization. 2015-07-27 20:09:38 +02:00
Stephen Kelly a8e5d838ed cmCPackPropertiesGenerator: Require cmLocalGenerator in API. 2015-07-27 20:09:38 +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 d6239507b2 cmMakefile: Split accessors for compile definitions and origins. 2015-07-22 20:25:45 +02:00
Brad King ef97d4429f Merge topic 'use-generator-target'
d4a8a554 cmGlobalGenerator: Map local generators to generator targets.
faec4e61 cmComputeTargetDepends: Change API to use cmGeneratorTarget.
2015-07-02 09:06:17 -04:00
Stephen Kelly d4a8a554ea cmGlobalGenerator: Map local generators to generator targets. 2015-07-01 19:46:19 +02:00
Stephen Kelly faec4e611d cmComputeTargetDepends: Change API to use cmGeneratorTarget. 2015-07-01 19:46:19 +02:00
Stephen Kelly f346d88d10 cmMakefile: Avoid invoking EnforceDirectoryLevelRules.
This is part of the CMP0000 implementation and only needs to be invoked
for top-level buildsystem files currently.
2015-06-30 23:14:20 +02:00
Brad King 327490e698 enable_language: Allow CMakeDetermine<LANG>Compiler module to fail early
If the module reports a FATAL_ERROR, skip the rest of the steps to
enable the language to avoid unnecessary following error messages.
2015-06-29 16:18:32 -04:00
Stephen Kelly a3b210fd6c cmGeneratorTarget: Require a cmLocalGenerator to construct. 2015-06-22 13:23:45 -04:00
Stephen Kelly 8ec60c675a cmGlobalGenerator: Create GeneratorTargets with a local generator. 2015-06-22 13:23:45 -04:00
Stephen Kelly 0efe4944e1 cmGlobalGenerator: Add ComputeHomeRelativeOutputPath method.
Fix generation of tgt/fast build targets.

Commit 363caa2f (cmLocalGenerator: De-virtualize Configure().,
2015-05-30) moved the computation of HomeRelativeOutputPath from
Configure-time to Generate-time, because it is only used at
Generate-time.  However, that commit caused the member for one
local generator to be computed immediately before generating with
that local generator, whereas previously the members of all local
generators were computed before generating any of them.

The HomeRelativeOutputPath is used by the GetRelativeTargetDirectory
method, which is called by the
cmGlobalUnixMakefileGenerator3::WriteConvenienceRules method.  That
method is called by the
cmLocalUnixMakefileGenerator3::WriteLocalMakefile method when generating
for the top-most (ie, the first) local generator.  At that point,
the HomeRelativeOutputPath is not yet computed.

Fix that by computing the member just before generating anything.
This will eventually be done in the cmLocalUnixMakefileGenerator3
constructor instead, but further refactoring is needed to make
that possible.
2015-06-13 08:38:27 +02:00
Stephen Kelly 22d09ecf33 cmLocalGenerator: Remove ConfigureFinalPass.
Call the cmMakefile implementation directly.  This is a configure-time
construct.
2015-06-09 23:42:13 +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
Brad King 0886880e3b Merge topic 'cmMakefile-Configure'
7657e8b1 cmMakefile: Introduce a local cmMakefile variable.
4e8f242d cmMakefile: Store unconfigured cmMakefiles.
d65e0123 cmMakefile: Implement ConfigureSubDirectory in terms of cmMakefile.
f059ed16 cmMakefile: Move Configure responsibility from cmLocalGenerator.
a653611d cmake: Replace CurrentLocalGenerator concept with CurrentMakefile.
69a038a9 cmMakefile: Refactor directories specified with the subdirs command.
08637970 cmLocalGenerator: ComputeObjectMaxPath just before generating.
27e11c6f Merge Configure state with GeneratingBuildSystem state.
363caa2f cmLocalGenerator: De-virtualize Configure().
2015-06-04 09:13:35 -04:00
Stephen Kelly f059ed165b cmMakefile: Move Configure responsibility from cmLocalGenerator.
The generator should only have a function at generate time.
2015-06-04 09:06:41 -04:00
Stephen Kelly a653611db0 cmake: Replace CurrentLocalGenerator concept with CurrentMakefile. 2015-06-04 09:06:41 -04:00
Stephen Kelly 0863797037 cmLocalGenerator: ComputeObjectMaxPath just before generating. 2015-06-04 09:06:41 -04:00
Stephen Kelly 27e11c6fea Merge Configure state with GeneratingBuildSystem state. 2015-06-04 09:06:40 -04:00
Stephen Kelly 80b433b05e cmGlobalGenerator: Don't use else after a return. 2015-06-03 01:04:00 +02:00
Stephen Kelly 3b880a0741 cmLocalGenerator: Require a valid cmState::Snapshot in the ctor.
Refactor the local generator creation API to accept a
cmState::Snapshot.  Adjust MakeLocalGenerator to use the 'current'
snapshot in cases where there is no parent.  Create the snapshot
for subdirectories in cmMakefile::AddSubdirectory.

This means that snapshots are now created at the point of extending the tree,
as appropriate, and independently of the cmLocalGenerator and cmMakefile they
represent the state for.
2015-05-27 09:18:32 -04:00
Stephen Kelly e12afe766e cmState: Host some state from the cmGlobalGenerator. 2015-05-27 09:18:31 -04:00
Stephen Kelly c7b79aa16a cmGlobalGenerator: Require a cmake instance in ctor.
It is required anyway, so this makes it explicit.
2015-05-27 09:18:31 -04: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
Brad King 594dd9b36a Merge topic 'use-std-unordered_map'
d7923b82 Use std::unordered_map instead of hash_map where available.
820777af Tests: Don't rely on ordering of targets in maps.
921d74d8 AutoGen: Don't iterate over a container while populating it.
2015-05-19 11:30:21 -04:00
Stephen Kelly 921d74d855 AutoGen: Don't iterate over a container while populating it.
The InitializeAutogenTarget creates new targets and adds them to the
Targets container on the makefile.  In this method, we have a reference
to that container and we are iterating over it.  That happens to work
with hash_map, but it fails with undefined behavior when using the
std::unordered_map from libstdc++-4.9 (and likely others).
2015-05-16 06:54:31 +02:00
Stephen Kelly b659d161da cmGlobalGenerator: Add NVI wrapper to create local generator. 2015-05-16 05:18:25 +02:00
Stephen Kelly b17686d2bb cmGlobalGenerator: Move some flags from cmLocalGenerator.
These flags are global, and so they belong here instead of being
set on each local generator.
2015-05-14 20:36:28 +02:00
Stephen Kelly 34c9ee2ed7 cmLocalGenerator: Require a global generator in the constructor.
Port generator factory methods to pass it.
2015-05-14 20:36:27 +02:00
Brad King 957c2aac7f RC: Simplify selection of resource compiler based on C/C++ toolchain
Revert the refactoring by commit v2.8.11~105^2~1 (Ninja: use MinGW
generator code in EnableLanguage, 2013-03-09) and move the MinGW-
specific logic back to the "MinGW Makefiles" generator.  Instead teach
the platform information modules for GNU and MSVC on Windows to set the
preferred RC compiler just before enabling the RC language.  This way
we choose the RC compiler based on the C/C++ toolchain that is actually
enabled.
2015-05-07 11:43:02 -04:00
Stephen Kelly de21168612 Port to static cmPolicies API. 2015-05-04 22:32:20 +02:00
Brad King a588d1ee99 Merge topic 'fix-cmState-try_compile-languages'
27343e3b cmGlobalGenerator: Finish storing enabled languages in cmState
2015-05-01 13:16:12 -04:00
Brad King 27343e3b68 cmGlobalGenerator: Finish storing enabled languages in cmState
In commit 74de9a73 (cmGlobalGenerator: Delegate storage of enabled
languages to cmState, 2015-04-11) the original LanguageEnabled
member of cmGlobalGenerator was left behind by mistake.  One use
of it in EnableLanguagesFromGenerator (for try_compile) was left,
but the member is not populated anymore.  Drop the member and
teach EnableLanguagesFromGenerator to copy the list of enabled
languages from one cmState to the other.

Reported-by: Matt McCormick <matt.mccormick@kitware.com>
2015-04-30 09:08:25 -04:00
Stephen Kelly a48aebcb67 cmLocalGenerator: Require a parent in the constructor.
Pass the parent though cmGlobalGenerator::CreateLocalGenerator.

This will make it easy to initialize state scopes independent of
cmMakefile.
2015-04-28 07:50:52 +02:00
Brad King 5a5ef00106 Merge topic 'clean-up-cmMakefile'
8dc3a67c cmMakefile: Out-of-line the directory methods.
0f3c8cfa cmMakefile: Use method abstraction to access directories.
b288a997 cmMakefile: Rename SetStart* directory API to SetCurrent*.
932d53bc cmMakefile: Remove redundant method duplication.
32b8f03a cmMakefile: Port users of GetStart* methods to new names.
54d6a918 cmMakefile: Rename GetCurrent{Output,Binary}Directory.
55d80d0a cmMakefile: Rename GetCurrent{,Source}Directory.
b23cf06f cmake: Remove redundant start directories.
fcf246ac cmMakefile: Populate Home directories on initialize.
8878bea7 cmake: Initialize Home directories on cmake for find-package mode.
044dc815 Use the Home directories from the cmake class where intended.
d67e8f24 cmake: Fix directory used to find the cache
1ea085d1 cmMakefile: Initialize dir definitions early.
f034bb2f Remove redundant calls to MakeStartDirectoriesCurrent.
3a68c323 cmMakefile: Fix wrong parameter names.
2015-04-21 09:42:07 -04:00
Stephen Kelly 32b8f03acc cmMakefile: Port users of GetStart* methods to new names. 2015-04-21 00:15:20 +02:00
Stephen Kelly 55d80d0a85 cmMakefile: Rename GetCurrent{,Source}Directory.
Match the names used in cmake code.
2015-04-21 00:12:52 +02:00
Stephen Kelly 044dc81504 Use the Home directories from the cmake class where intended. 2015-04-21 00:12:51 +02:00
Stephen Kelly f034bb2f54 Remove redundant calls to MakeStartDirectoriesCurrent.
The SetStart{,Output}Directory methods do what it does.
2015-04-21 00:12:51 +02: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
Stephen Kelly 6e23a4bddd cmMakefile: Remove always-null first parameter to ReadListFile. 2015-04-18 15:31:18 +02:00
Stephen Kelly 5d056c0dd8 Port Global property interaction to cmState. 2015-04-15 11:43:50 -04:00
Stephen Kelly 74de9a734c cmGlobalGenerator: Delegate storage of enabled languages to cmState. 2015-04-13 20:19:58 +02:00
Brad King 62c5e6f1a1 Merge topic 'introduce-cmState'
f081c5bd cmState: Move CacheEntryType enum from cmCacheManager.
f71fdf0e cmMakefile: Remove unused CacheManager accessor.
ff7169a0 Port to cmState.
a6b1ad13 Introduce cmState class.
2015-04-13 11:45:02 -04:00
Stephen Kelly f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Stephen Kelly ff7169a03c Port to cmState. 2015-04-13 11:44:15 -04:00
Stephen Kelly 55ecd818f6 cmGlobalGenerator: Store languages as vector, not map.
The second component of the map is never used.
2015-04-12 20:08:42 +02:00
Stephen Kelly ba404938a2 cmCacheManager: Port consumers to non-iterator API.
This simplifies reasoning about the follow-up commit which ports
away from cmCacheManager to a class with the same method names.
2015-04-08 18:47:00 +02: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 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
Stephen Kelly 9410e24a4a cmCacheManager: Port consumers to non-iterator API.
This simplifies reasoning about the follow-up commit which ports
away from cmCacheManager to a class with the same method names.
2015-04-06 17:58:55 +02: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 510562e3e7 cmGlobalGenerator: Don't fetch the cache manager in a loop.
It doesn't change from Makefile to Makefile.
2015-04-05 10:26:10 +02:00
Brad King f25aa204a2 Merge topic 'vs-express-build-output'
94887cb6 cmake: Teach --build to get VCExpress output (#15437)
2015-03-12 15:26:39 -04:00
Stephen Kelly 7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Brad King 94887cb6f1 cmake: Teach --build to get VCExpress output (#15437)
VCExpress does not produce output if its pipes are connected to
an interactive terminal.  Add a special case to 'cmake --build'
to capture the output through a pipe and re-print it instead of
sharing output pipes with VCExpress.
2015-03-10 08:42:18 -04:00
Gregor Jasny ce935ebe50 cmake: Teach --build to honor CMAKE_VERBOSE_MAKEFILE for Ninja
The Ninja build system does not support a in-file verbositiy switch.
Instead teach 'cmake --build' to extract the CMAKE_VERBOSE_MAKEFILE
setting and pass it as an optional '-v' argument to Ninja.  This can
serve as a reasonable fallback.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2015-02-26 09:51:11 -05:00
Stephen Kelly 21b0654ace cmGlobalGenerator: Convert set insert algorithm to vector algorithms.
Adjust test for new error output.
2015-02-20 21:36:57 +01:00
Stephen Kelly 37b88d348a cmAlgorithms: Add cmWrap.
Port some existing cmJoin to use it.

cmJoin is cumbersome to use in cases where the objective is to
somehow 'quote' each item and then join it with a separator.  In that
case, the joiner string is harder to read and reason about.  cmWrap
aims to solve that.

Provide an overload taking char wrappers to simplify the case
of surrounding every element in quotes without needing to escape
the quote character.
2015-02-20 21:35:58 +01:00
Stephen Kelly 60c3bb73e3 cmGlobalGenerator: Replace loop with algorithm. 2015-02-20 21:26:18 +01:00
Stephen Kelly 9c22576787 cmGlobalGenerator: Replace set::insert algorithm with cmRemoveDuplicates. 2015-02-19 00:59:19 +01:00
Stephen Kelly 6010f93632 Revert "cmGlobalGenerator: Fix value type pushed into autogens vector"
This reverts commit ae6fc555a7.

Use the more-natural make_pair algorithm.  The compiler motivating
the need for this is not supported as a host anymore.
2015-02-17 19:19:06 +01:00
Stephen Kelly 62429a1e54 cmGlobalGenerator: Remove unneeded pointer check.
Deleting nullptr is ok.
2015-02-17 19:18:11 +01:00
Brad King ab9fa54d48 Xcode: Switch to internal CMAKE_MAKE_PROGRAM lookup by generator (#15324)
The "cmakexbuild" wrapper is not needed for Xcode 4 and above, and the
path to it may change when CMake moves.  Avoid storing a specific path
to a build program in CMakeCache.txt and instead compute the value for
CMAKE_MAKE_PROGRAM on demand.  However, if a user does set the value
explicitly then honor it.

This does for Xcode what commit v3.0.0-rc1~260^2~4 (VS: Switch to
internal CMAKE_MAKE_PROGRAM lookup by generators, 2013-11-15) did for
Visual Studio generators.
2015-01-29 09:11:11 -05:00
Sylvain Joubert bbffaa0e6c Configure some CMake-provided targets with USES_TERMINAL (#14915)
This will make them use the 'console' pool with the Ninja generator.
Impacted targets are:
- Built-in targets: install, install/local, install/strip, tests,
  package, package_source, rebuild_cache
- Targets provided by the CTestTargets module: Nightly, Continuous,
  Experimental,
  and all their variants (*Start, *Configure, ...)
2015-01-27 11:16:48 -05:00
Brad King 0238d0c397 cmake: Generate an internal 'Labels.json' file next to 'Labels.txt'
In each internal target directory we generate a "Labels.txt" file
containing labels for that target and its sources, but it uses an
internal format.  In order to make the list of labels easier to
publish, use a json format and call it "Labels.json".

Since we now use jsoncpp headers, link CMakeLib to the jsoncpp library.
2015-01-20 09:31:11 -05:00
Brad King 9de2ab7fce Merge topic 'consistent-empty-method'
5f69314e Replace foo.length() pattern with !foo.empty().
fd0c036c Replace 'foo.length() >= 1' pattern with !foo.empty()
f09fde2d Replace 'foo.length() > 0' pattern with !foo.empty().
86b5bdfa Replace 'foo.length() == 0' pattern with foo.empty().
fd7b3712 Replace foo.size() pattern with !foo.empty().
aa773035 Replace !foo.size() pattern with foo.empty().
64592633 cmListCommand: Use empty() and expand whitespace.
607e1938 Replace 'foo.size() != 0' pattern with !foo.empty().
930bd478 Replace 'foo.size() == 0' pattern with foo.empty().
d92887ef Replace 'foo.size() > 0' pattern with !foo.empty().
2015-01-19 09:43:28 -05:00
Stephen Kelly fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly 930bd47816 Replace 'foo.size() == 0' pattern with foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly d92887efab Replace 'foo.size() > 0' pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly 681d965df1 Use the cmDeleteAll algorithm for types derived from std::map. 2015-01-17 16:22:58 +01:00
Stephen Kelly 4a6e795b0c Use the cmDeleteAll algorithm instead of trivial raw loops. 2015-01-13 23:00:17 +01:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Brad King ce331bab92 find_library: Fix repeat call after changing directory content (#15293)
We use cmGlobalGenerator::GetDirectoryContent to avoid repeating
directory listings.  However, GetDirectoryContent loads content from
disk at most once.  This breaks find_library calls that occur when disk
content has changed since preceding find_library calls.

Teach cmGlobalGenerator::GetDirectoryContent to save the directory
modification time when content is loaded and re-load content if it
changes.

Create a RunCMake.find_library test with a case covering this.
2014-12-08 15:35:50 -05:00
Brad King 4987b37165 Merge topic 'remove-c_str'
5eb4d759 Remove some unneeded c_str calls.
2014-11-25 10:18:49 -05:00
Stephen Kelly 5eb4d7590e Remove some unneeded c_str calls. 2014-11-23 11:09:54 +01:00
Brad King e15a7075b5 Add an option for explicit BYPRODUCTS of custom commands (#14963)
A common idiom in CMake-based build systems is to have custom commands
that generate files not listed explicitly as outputs so that these
files do not have to be newer than the inputs.  The file modification
times of such "byproducts" are updated only when their content changes.
Then other build rules can depend on the byproducts explicitly so that
their dependents rebuild when the content of the original byproducts
really does change.

This "undeclared byproduct" approach is necessary for Makefile, VS, and
Xcode build tools because if a byproduct were listed as an output of a
rule then the rule would always rerun when the input is newer than the
byproduct but the byproduct may never be updated.

Ninja solves this problem by offering a 'restat' feature to check
whether an output was really modified after running a rule and tracking
the fact that it is up to date separately from its timestamp.  However,
Ninja also stats all dependencies up front and will only restat files
that are listed as outputs of rules with the 'restat' option enabled.
Therefore an undeclared byproduct that does not exist at the start of
the build will be considered missing and the build will fail even if
other dependencies would cause the byproduct to be available before its
dependents build.

CMake works around this limitation by adding 'phony' build rules for
custom command dependencies in the build tree that do not have any
explicit specification of what produces them.  This is not optimal
because it prevents Ninja from reporting an error when an input to a
rule really is missing.  A better approach is to allow projects to
explicitly specify the byproducts of their custom commands so that no
phony rules are needed for them.  In order to work with the non-Ninja
generators, the byproducts must be known separately from the outputs.

Add a new "BYPRODUCTS" option to the add_custom_command and
add_custom_target commands to specify byproducts explicitly.  Teach the
Ninja generator to specify byproducts as outputs of the custom commands.
In the case of POST_BUILD, PRE_LINK, and PRE_BUILD events on targets
that link, the byproducts must be specified as outputs of the link rule
that runs the commands.  Activate 'restat' for such rules so that Ninja
knows it needs to check the byproducts, but not for link rules that have
no byproducts.
2014-11-14 16:16:00 -05:00
Peter Collingbourne 4d1fedf46e Give the interactive cache editor the USES_TERMINAL property 2014-11-14 11:56:33 -05:00
Brad King 810ef59a42 Merge topic 'no-cmake-self-install-when-cross-compiling'
15f55cca Do not use just-built CMake to install itself when cross-compiling (#15248)
2014-11-14 10:56:39 -05:00
Brad King cddb5002b5 Merge topic 'file-GENERATE-source'
b80557c7 file(GENERATE): Evaluate early to allow generating source files
0019d54b Genex: Fix whitespace issue.
2014-11-13 10:08:32 -05:00
Brad King 15f55cca59 Do not use just-built CMake to install itself when cross-compiling (#15248)
The special case added by commit v2.4.0~3051 (When building CMake
itself, use the new cmake to install so that the current cmake can be
overwritten, 2004-06-09) does not make sense when cross-compiling.
2014-11-13 08:58:16 -05:00
Stephen Kelly b80557c7bd file(GENERATE): Evaluate early to allow generating source files
The evaluation files must be known before cmTargetTraceDependencies
attempts to find them, but we must actually generate the files after
cmTargetTraceDependencies, as that can add to target SOURCES.  The
limitation is that the generated output name must not depend on the
SOURCES of a target if the generated file is used by that target.

Mark the output files as GENERATED so that trace dependencies does
not expect them to already exist in the filesystem.

Move the invokation of ForceLinkerLanguage in the Generate logic
to after the generated file names are known.  ForceLinkerLanguage
tries to determine the sources of a target (in order to determine
an already-known language) and otherwise fails to get information
about the generated file.

Test that the output of file(GENERATE) can be used as a target source
file and that accessing the target SOURCES in the name of the output
file is an error.  Accessing the TARGET_OBJECTS would be a similar
error if it was legal to use that generator expression in this
context.  That is not currently possible and is a different error
condition, so test the current error output as a reminder to change
the expected output if that becomes possible in the future.  Test
that generated rule files resulting from cmTargetTraceDependencies
appear in the SOURCES generated in the output file.
2014-11-12 22:36:45 +01:00
Brad King 3a6c359906 Suppress deprecation warnings for GetVersionEx
Visual Studio 12 (2013) deprecated GetVersionEx:

  warning C4996: 'GetVersionExW': was declared deprecated

in favor of either "versionhelpers.h" or VerifyVersionInfo, neither of
which exist in some of the older compilers we support.  Rather than
try to port conditionally to VerifyVersionInfo, simply suppress the
warning for now.
2014-11-11 08:55:58 -05: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
Geoff Viola bef23e8181 Fix some spelling errors in comments 2014-10-13 10:00:53 -04:00
Brad King 1b549a5c64 enable_language: Fix error messages on missing modules (#15155)
In cmGlobalGenerator::EnableLanguage, fix error messages for missing
module files to actually name the missing module instead of using the
empty string returned by GetModulesFile.
2014-09-18 09:25:26 -04:00
Brad King 09c8ad9943 enable_language: Initialize system-specific generator info only once
Call SetSystemName, SetGeneratorPlatform, and SetGeneratorToolset
exactly once after reading CMakeSystem.cmake, and not again on another
call to enable_language() or project().
2014-09-10 11:21:51 -04:00
Brad King 0f1f1271e6 CMake: Add CMAKE_GENERATOR_PLATFORM option
Reject the option by default.  It will be implemented on a per-generator
basis.  Pass the setting into try_compile project generation.  Add cache
entry CMAKE_GENERATOR_PLATFORM and associated variable documentation to
hold the value persistently.

Add a RunCMake.GeneratorPlatform test to cover basic use cases for the
option.  Verify that CMAKE_GENERATOR_PLATFORM is empty by default, and
that it is rejected when the generator does not support a user setting.
2014-09-05 14:38:05 -04:00
Brad King 03b7b6cda1 cmGlobalGenerator: Call SetGeneratorToolset even for empty toolset
Move handling of an empty toolset name into the implementation of the
method.  This simplifies the VS 10 implementation of default toolset
selection because it has one code path that is always called.
2014-09-05 13:41:54 -04:00
Brad King 5b0a46e1c9 ASM_MASM: Do not require compiler to be a full path
The compiler detection modules for this language do not yet know how
to find the full path to 'ml' or 'ml64', so do not require it.
2014-08-13 14:47:49 -04:00
Brad King 70796ef026 CMP0047: Fix CMAKE_COMPILER_IS_GNU(CC|CXX) in OLD behavior
The implementation of CMP0047 detects the QNX compiler id internally,
then changes it to GNU after the language is fully enabled.  This is too
late to correctly set the old IS_GNU variables, so set them as part of
the policy OLD behavior.

Reported-by: Mike Lattanzio <mlattanzio@blackberry.com>
2014-08-07 11:24:57 -04:00
Brad King 30983ebec1 cmGlobalGenerator: Take Build output argument by reference
No call sites pass NULL to the output argument, so take it by
reference to avoid the if(output) conditions.  Propagate the
change through the TryCompile APIs that call it.
2014-07-31 12:49:51 -04:00
Brad King 731427a646 cmGlobalGenerator: Do not re-add CMAKE_<LANG>_COMPILER
The cmGlobalGenerator::ResolveLanguageCompiler method, invoked only by
Makefile generators, contains code originally added by commit v2.4.0~796
(..., add new generators for msys and mingw, 2005-12-22) to compute the
full path to the compiler and save the result back into the cache value.
Since then the CMakeDetermine*Compiler modules have learned to resolve
the full path to the compiler and save it in CMake*Compiler.cmake files
configured in the build tree.  The value of CMAKE_<LANG>_COMPILER in the
cache is now only for reference of what the user originally specified.
The full path is now available in a normal variable of the same name,
and this is used by project code and the generators.

When the user specifies -DCMAKE_<LANG>_COMPILER=name on the command-line
of an existing build tree that uses a Makefile generator, it is first
stored in the cache with an uninitialized type.  Then later when
ResolveLanguageCompiler updates the cache entry and sets the type to
FILEPATH, cmMakefile::AddCacheDefinition does CollapseFullPath on the
"name" and ends up with something like "$PWD/name" which is unlikely to
be correct.  Furthermore, cmMakefile::AddCacheDefinition proceeds to
remove the normal variable of the same name, so the value originally
saved in CMake<LANG>Compiler.cmake is ignored and the generators use the
wrong path to the compiler.

Resolve this by dropping the code from ResolveLanguageCompiler that
touches the cache value of CMAKE_<LANG>_COMPILER.  As explained above it
is no longer needed anyway.
2014-07-24 13:31:14 -04:00
Brad King f5c0efdbe4 cmGlobalGenerator: Create a non-virtual 'DoGenerate' method
Make the virtual 'Generate' method protected.  Make 'DoGenerate'
the main entry point to generation.  This gives cmGlobalGenerator
a chance to do some early operations before the individual
generator-specific implementations take over.
2014-07-22 15:05:36 -04:00
Brad King ecb34faaab Tell generators about CMAKE_SYSTEM_NAME as soon as it is known
Add a cmGlobalGenerator::SetSystemName virtual method.  Call it from
cmGlobalGenerator::EnableLanguage as soon as CMAKE_SYSTEM_NAME is known.
This will give generators a chance to adapt themselves to the target
system.  Pass the cmMakefile instance to the method so that the
generator can update it accordingly.  Return early from EnableLanguage
if SetSystemName returns false.
2014-07-17 16:01:41 -04:00
Brad King 5fba44cf41 VS: Move VS-only API out of cmGlobalGenerator
Move the IsDependedOn method to cmGlobalVisualStudio7Generator
since that is the only caller.
2014-06-12 10:26:35 -04:00
Ben Boeckel efc205695d cmake: remove dummy backtraces for IssueMessage 2014-06-05 12:44:17 -04:00
Brad King 528e8af19f Allow a toolchain file to specify a generator toolset
Delay use of CMAKE_GENERATOR_TOOLSET until the CMakeSystem.cmake
file has been configured and loaded during the first project() or
enable_language() command.  This gives the toolchain file named by
CMAKE_TOOLCHAIN_FILE a chance to set CMAKE_GENERATOR_TOOLSET.  This
point is still early enough to set the generator toolset prior to
the initialization of any languages that might use the toolset.

The cmake::GeneratorToolset member variable remains an indication
of what was specified by the -T option or loaded from the cache.
It does not need to be updated based on the toolchain file setting.
The cmMakefile::TryCompile can still pass cmake::GeneratorToolset
into the inner instance because the try-compiled project will do
platform and language initialization using the CMakeSystem module
configured for the outer project.

Extend the RunCMake.GeneratorToolset test with cases that use a
toolchain file to set CMAKE_GENERATOR_TOOLSET.
2014-06-04 14:27:02 -04:00
Nils Gladitz 15a8af21e8 Add an "installed file" property scope
Teach set_property and get_property an "INSTALL" property type to be
associated with install-tree file paths.  Make the properties available
to CPack for use during packaging.  Add a "prop_inst" Sphinx domain
object type for documentation of such properties.
2014-05-28 12:28:18 -04:00
Brad King 45f338e3d9 Merge topic 'dev/hashmap-for-targets'
325599ca cmGlobalGenerator: Store targets in hash maps
ac4106c6 cmMakefile: Use a hashmap for imported targets
2014-05-07 15:59:46 -04:00
Ben Boeckel 325599caa2 cmGlobalGenerator: Store targets in hash maps 2014-05-07 15:48:32 -04:00
Brad King bbc358c3fc Merge branch 'master' into osx-init-early
Resolve conflict in Source/cmGlobalGenerator.cxx by integrating
changes from both sides.
2014-04-29 09:36:55 -04:00
Brad King 416761e35c Add platform-specific initialization step when enabling languages
Create a Modules/CMakeSystemSpecificInitialize.cmake module loaded after
CMakeSystem.cmake but before per-language initialization.  Use it to
load an optional Platform/<os>-Initialize.cmake module.  This will be
useful to do per-platform initialization that does not depend on the
language and use the results when enabling specific languages.
2014-04-29 09:36:14 -04:00
Brad King 5376151aa1 Merge topic 'target-transitive-sources'
9407174b target_sources: New command to add sources to target.
81ad69e0 Make the SOURCES target property writable.
6e636f2e cmTarget: Make the SOURCES origin tracable.
3676fb49 cmTarget: Allow transitive evaluation of SOURCES property.
e6971df6 cmTarget: Make the source files depend on the config.
df753df9 cmGeneratorTarget: Don't add computed sources to the target.
869328aa cmComputeTargetDepends: Use valid config to compute target depends.
2014-04-03 12:51:53 -04:00
Brad King 93054aa84f Merge topic 'target-sources-refactor'
5de63265 Genex: Only evaluate TARGET_OBJECTS to determine target sources.
aa0a3562 cmGeneratorTarget: Compute target objects on demand
042c1c83 cmTarget: Compute languages from object libraries on demand.
fdcefe3c cmGeneratorTarget: Compute consumed object libraries on demand.
c355d108 cmComputeTargetDepends: Track object library depends.
e5da9e51 cmTarget: Allow any generator expression in SOURCES property.
5702e106 cmTarget: Include TARGET_OBJECTS genex in target SOURCES property.
857d30b5 cmGlobalGenerator: Add interface to call ForceLinkerLanguages
28e1d2f8 cmStringCommand: Add GENEX_STRIP subcommand.
bf98cc25 Genex: Evaluate TARGET_OBJECTS as a normal expression.
8cd113ad cmTarget: Store strings instead of cmSourceFile* to represent SOURCES.
4959f341 cmSourceFileLocation: Collapse full path for directory comparisons.
fcc92878 cmSourceFileLocation: Remove unused Update method.
59e8740a cmTarget: Remove AddSourceFile method
26d494ba cmTarget: Use string API to add sources to cmTarget objects.
d38423ec cmTarget: Add a method to obtain list of filenames for sources.
...
2014-04-03 12:51:51 -04:00
Stephen Kelly e6971df6ab cmTarget: Make the source files depend on the config.
Disallow the use of config-specific source files with
the Visual Studio and Xcode generators. They don't have
any way to represent the condition currently.

Use the same common-config API in cmQtAutoGenerators. While
it accepts config-specific files, it doesn't have to support
multiple configurations yet.

Loop over the configs in cmTargetTraceDependencies
and cmGlobalGenerator::WriteSummary and consume all source
files.

Loop over the configs in cmComputeTargetDepends and compute the
object library dependencies for each config.
2014-04-02 23:14:02 +02:00
Stephen Kelly aa0a3562dd cmGeneratorTarget: Compute target objects on demand
Add a ComputeObjectMapping method to compute the object
names.  It takes mapping to populate as an out-parameter so
that it can be extended in the future with parameters
relevant to generator expression evaluation.

Remove the supporting cmGeneratorTarget::AddObject method. It is
no longer needed as the container member is populated directly.

The ComputeObjectMapping method is called whenever objects are
requested from the cmGeneratorTarget.  Because the Xcode generator
makes no such request, explicitly invoke the method from that
generator so that the logic of checking for bad sources in object
libraries is executed.

In a follow-up, the UseObjectLibraries usage may be replaced by a
true generator expression evaluator for TARGET_OBJECTS. That
will require generators to use cmGeneratorTarget::GetExternalObjects
which is not currently the case for Xcode and VS generators.
2014-04-02 23:12:57 +02:00
Stephen Kelly fdcefe3c42 cmGeneratorTarget: Compute consumed object libraries on demand.
Remove up-front object library computation from cmGlobalGenerator.

Adjust tests for message coming from the generator expression
evaluation.
2014-04-02 23:12:56 +02:00
Brad King 8018fcca6e Merge branch 'master' into revise-compiler-id-policies 2014-04-02 14:44:35 -04:00
Brad King a41c0a9dcb Do not warn by default when policy CMP0025 or CMP0047 is not set
These policies are triggered by the use of a particular compiler rather
than outdated CMake code in a project.  Avoid warning in every project
that enables a language by not displaying the policy warning by default.
Add variable CMAKE_POLICY_WARNING_CMP<NNNN> to control the warning
explicitly; otherwise enable the warning with --debug-output or --trace.

This breaks with strict policy convention because it does not provide
developers with any warning about the behavior change by default.
Existing projects will continue to build without a warning or change in
behavior.  When a developer changes the minimum required version of
CMake in a project to a sufficiently high value (3.0), the project will
suddenly get the new compiler id and may break, but at least the
breakage comes with a change to the project rather than the version of
CMake used to build it.

Breaking strict policy convention is worthwhile in this case because
very few projects will be affected by the behavior change but every
project would have to see the warning if it were enabled by default.
2014-04-02 14:43:54 -04:00
Stephen Kelly 857d30b52e cmGlobalGenerator: Add interface to call ForceLinkerLanguages
Avoid calling it too early when cmGeneratorTarget instances don't
yet exist.
2014-03-31 23:18:44 +02:00
Stephen Kelly beaa7e0377 cmGeneratorTarget: Compute the object directory early.
Ensure it is populated before tracing dependencies.
2014-03-31 23:18:43 +02:00
Stephen Kelly 6c9dd0ec7b cmGlobalGenerator: Make ComputeTargetObjects non-virtual
Implement it in terms of the ComputeObjectFilenames virtual method
on the local generators.

Remove the reimplementation from the global generators which are
now all functionally identical.
2014-03-15 09:30:24 +01:00
Stephen Kelly cd43433de5 cmGlobalGenerator: Extract a ComputeTargetObjectDirectory interface.
Make it public for future external calls.
2014-03-13 15:27:23 +01: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
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Ben Boeckel 6557382dcf stringapi: Use strings for program paths 2014-03-08 13:05:38 -05:00
Ben Boeckel 1a1b737c99 stringapi: Use strings for generator names 2014-03-08 13:05:38 -05:00
Ben Boeckel 24b5e93de2 stringapi: Use strings for directories 2014-03-08 13:05:38 -05:00
Ben Boeckel b3bf31a548 stringapi: Miscellaneous char* parameters 2014-03-08 13:05:37 -05:00
Ben Boeckel 5af95c396d typo: Match argument name with the header 2014-03-08 13:05:37 -05:00
Ben Boeckel 84fdc9921c stringapi: Pass configuration names as strings 2014-03-08 13:05:36 -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 8d60da0cb5 cmTarget: Remove the project argument to FindTarget
All callers passed 0 in, so just remove the branch.
2014-03-08 13:05:34 -05:00
Ben Boeckel c3833c7da4 stringapi: Use strings for VS project names 2014-03-08 13:05:33 -05:00
Ben Boeckel fabf1fbabb stringapi: Use strings in target name 2014-03-08 13:05:31 -05:00
Ben Boeckel ce5114354c stringapi: Use strings for the languages 2014-03-08 13:05:30 -05:00
Stephen Kelly 64d398416a cmGeneratorTarget: Classify sources on demand, not up front.
Implement a Visitor to hold the sequence of source file tests
for populating outputs.  Use VS 6 and 7 workaround from Brad
King for lack of partial template specialization and function
template specialization capabilities.

This will make it possible to use context dependent generator
expressions to determine the sources of a target.
2014-02-24 16:44:51 +01:00
Stephen Kelly f81eb49e8b cmTarget: Find source files on request.
In a follow-up, the list of sources will become dependent on
the config, so check for existence in cmTarget::GetSourceFiles
instead of up-front with cmGlobalGenerator::CheckTargets().
2014-02-24 16:43:23 +01:00
Brad King e7d3287590 Merge topic 'minor-cleanups'
f6cae4ea Tests: Remove some trailing black lines.
c0ea4c5c Makefile: Fix comment indentation.
5e0c73c7 cmGlobalGenerator: Remove unused variable.
907c09cd include_directory: Add missing include.
a74d125a Help: Fix typo
317d8498 Small typo fix
2014-02-19 08:34:20 -05:00
Stephen Kelly 5e0c73c78c cmGlobalGenerator: Remove unused variable. 2014-02-17 11:13:44 +01:00
Stephen Kelly 9db9c1fc8b cmTarget: Don't try to get sources of an INTERFACE_LIBRARY.
An an assert to ensure this.
2014-02-14 13:53:14 +01:00