Commit Graph

112 Commits

Author SHA1 Message Date
Brad King bd9c7f9b2c Ninja: Add policy to require explicit custom command byproducts
Add policy CMP0058 to avoid generating 'phony' ninja rules for unknown
custom command dependencies.  This requires projects to specify their
custom command byproducts explicitly.  With this requirement we no
longer have to assume that unknown custom command dependencies are
generated and can instead simply assume they are source files expected
to exist when the build starts.  This is particularly important in
in-source builds.  It is also helpful for out-of-source builds to allow
Ninja to diagnose missing files before running custom command rules that
depend on them.
2015-03-20 17:40:12 -04:00
Brad King ed8e30b00d cmGlobalNinjaGenerator: Optimize handling of known build outputs
Teach WriteUnknownExplicitDependencies to take ownership of the set of
WriteBuild outputs immediately since no other methods need the data.
This avoids re-inserting the whole set into another already populated
set.
2015-03-20 13:33:13 -04:00
Brad King ad094f435e cmGlobalNinjaGenerator: Fix spelling of "unknown" 2015-03-20 13:32:55 -04:00
Brad King 80afe28a10 Ninja: Do not generate circular phony rules (#15454)
The phony rules added by commit v2.8.12~248^2 (Ninja: Custom Command
file depends don't need to exist before building, 2013-06-07) are
circular, e.g.

  build side-effect: phony side-effect

This is not diagnosed by Ninja as of version 1.5, but the dependency
does not make sense.  Simply drop it and use phony rules of the form

  build side-effect: phony

instead.

Reported-by: Daniel Dunbar
2015-03-18 12:55:27 -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
Brad King b5a467262b Merge topic 'drop-ancient-workarounds'
0f7bdd61 Remove VS 6 special case.
5e92c826 Remove some obsolete stuff.
15e42bb2 cmStandardIncludes: Remove obsolete cmOStringStream.
931e055d Port all cmOStringStream to std::ostringstream.
f194a009 Remove unused cmIStringStream class.
3ec1bb15 cmStandardIncludes: Remove std namespace hack.
bb3bce70 cmStandardIncludes: Remove ANSI_FOR_SCOPE hack.
28fa4923 cmStandardIncludes: Remove iostreams workaround for obsolete Compaq compiler.
837a8a63 cmStandardIncludes: Drop Comeau-related workaround.
4030ddfd Remove Borland-related undef.
17d6a6fd cmStandardIncludes: Remove comment about Borland.
26fb5011 Drop SGI as a CMake host compiler.
2015-01-12 08:57:39 -05: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
Stephen Kelly 6162c9194b Use two-iterator std::set::insert where appropriate. 2015-01-11 17:00:55 +01:00
Brad King 67bd514adc Ninja: Refactor restat to be a string internally
This will allow values other than "" and "1" to be generated in
the rules.ninja file.
2014-11-14 16:16:00 -05:00
Peter Collingbourne f42d86f0b8 Ninja: Implement USES_TERMINAL using the console pool if available 2014-11-14 11:56:33 -05:00
Peter Collingbourne d5eae5563f Ninja: factor out the test for console pool support 2014-11-14 11:56:33 -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
Brad King de8e534b41 Ninja: Limit custom command side-effects to build folder
Revert commit 7243c951 (Ninja: Don't limit custom cmd side-effects to
build folder, 2014-06-27) because it causes every custom command
dependency in the source tree to get a phony rule.  For large projects
these rules get too big for Ninja to handle efficiently.  While the
original change addressed a valid concern, it did not seem to occur
regularly in practice because well-behaved projects generate their
side-effects only in the build tree.  Until we support explicit
specification of side-effects (CMake issue #14963), we will have to use
this as a middle-ground.
2014-10-08 08:50:15 -04:00
Nils Gladitz 71da30cae0 Ninja: Fix variable duplication in RSP rules
Stream clear() resets stream state but does not actually clear its content.
2014-10-06 22:29:09 +02:00
Sylvain Joubert 9f32a2411b Ninja: Use 'console' pool for CMake re-run if possible (#14915)
The pre-defined 'console' pool is a non-buffered pool that runs with a
depth of 1.  CMake re-run cannot be run concurrently and it will
eventually output something.  A non-buffered pool allows to get it as
soon as possible

Also, generate the minimal required version of Ninja in the build file.
2014-10-03 08:48:47 -04:00
Sylvain Joubert 6120fca8e2 Ninja: Prevent compilers to be silently modified
Unlike with Unix Makefiles generator modifying compiler paths was not
protected with Ninja generator.  It was possible to modify them in the
cache without the expected effect on the generated solution.  Also
activate corresponding tests with Ninja.
2014-09-22 08:44:39 -04:00
Adam Strzelecki 7243c95129 Ninja: Don't limit custom cmd side-effects to build folder (#14972)
Actually custom command can write wherever it wants to, such as temporary
folder or source folder, possibly violating rules that only build folder should
be affected. Therefore we should consider custom command dependency at any path
as possible side effect adding phony rule.

We avoid adding phony rules for regular source files (since the paraent
commit) so we no longer need the in-build-tree test to avoid them.
2014-06-30 09:33:37 -04:00
Adam Strzelecki a33cf6d088 Ninja: Consider only custom commands deps as side-effects (#14972)
Since commit v2.8.12~248^2 (Ninja: Custom Command file depends don't
need to exist before building, 2013-06-07) all explicit dependencies
inside build folder were considered as possible build command
side-effects and phony rules were produced for them in case they don't
exist when starting to build. This is unnecessary since regular compile
inputs need to exist or cmake will fail.  Moreover the exception for
sources having GENERATED property that can be missing is already handled
by WriteAssumedSourceDependencies.

This fixes unwanted phony rules for all regular source files when doing
in-source build, causing Ninja not complain when such files gets missing,
i.e. during development. Also this reduces number of rules in ninja.build.

Now only custom command dependencies are considered as possible side-effects.
2014-06-30 09:33:37 -04:00
Brad King 0b028c6f0a Merge topic 'ninja-avoid-double-phony'
04377f1b Ninja: Remove CMake includes from explicit depends (#14972)
2014-06-16 08:54:46 -04:00
Adam Strzelecki 04377f1b31 Ninja: Remove CMake includes from explicit depends (#14972)
It may happen that CMake include is an explicit dependency for some command,
while all CMake includes are set phony in WriteTargetRebuildManifest, this may
lead to duplicate phony generate rules which causes ninja warnings.

We need to remove implicit CMake includes in WriteUnknownExplicitDependencies.

This fixes FindCUDA ninja warnings.
2014-06-16 08:51:38 -04:00
Ben Boeckel 01b79c6385 ninja: Don't use a stringstream to build an argument list
Streams are expensive to construct (looks like some locale-related
stuff), so use strings instead.
2014-05-02 13:22:19 -04:00
Stephen Kelly d83ef53a12 Rename local 'dir_max' variables to 'dir'
The code is not computing the maximum length directory, as is the
case in cmLocalVisualStudioGenerator::ComputeLongestObjectDirectory.
2014-03-17 15:27:01 +01: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 f6da044080 cmLocalGenerator: Add ComputeObjectFilenames interface.
Implement it in the local generators and use it in the global
generators.
2014-03-13 15:28:02 +01:00
Stephen Kelly 9ad804ac7b cmGeneratorTarget: Constify cmSourceFile* in containers.
Some of them will be used with other APIs which require value_type
to be cmSourceFile const*.
2014-03-13 15:27:23 +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 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 24b5e93de2 stringapi: Use strings for directories 2014-03-08 13:05:38 -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 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
Brad King 2c426bfb2d Ninja: Normalize paths of CMake re-run rule dependencies
Send all implicit dependencies through ConvertToNinjaPath.
Add CMakeCache.txt before uniquifying the list.
2014-01-21 14:29:55 -05:00
Brad King 9465242d01 Merge topic 'ninja_fix_rerun'
20e595ab Revert "Ninja: Track configured files so we can regenerate them."
2014-01-16 09:24:15 -05:00
Brad King ce362f27d6 Merge topic 'revert-ninja_fix_rerun'
79859689 Revert "Ninja: Avoid re-running CMake on next build after regeneration"
2014-01-16 09:24:13 -05:00
Brad King 20e595aba8 Revert "Ninja: Track configured files so we can regenerate them."
Revert commit 4a6397a7 (Ninja: Track configured files so we can
regenerate them, 2013-06-17).  The files reported by the method
cmMakefile::GetOutputFiles() must cause CMake to re-run only if they are
missing and without considering a timestamp.  This is not the meaning of
the implicit dependencies field so Ninja re-runs CMake too often.

Another solution will have to be found to the original problem.
2014-01-15 16:37:25 -05:00
Brad King 7985968900 Revert "Ninja: Avoid re-running CMake on next build after regeneration"
Revert commit 6fac24d7 (Ninja: Avoid re-running CMake on next build
after regeneration, 2014-01-09).  The files reported by the method
cmMakefile::GetOutputFiles() must cause CMake to re-run only if they are
missing and without considering a timestamp.  Therefore they cannot be
listed as outputs of the re-run rule or Ninja will re-run CMake every
time because the timestamp of configure_file outputs does not change.

Another solution will have to be found to the original problem.
2014-01-15 16:33:22 -05:00
Brad King 020006f936 Merge topic 'ninja_fix_rerun'
6fac24d7 Ninja: Avoid re-running CMake on next build after regeneration
2014-01-13 10:23:23 -05:00
Robert Maynard 6fac24d750 Ninja: Avoid re-running CMake on next build after regeneration
In commit 4a6397a7 (Ninja: Track configured files so we can regenerate
them, 2013-06-17) we accidentally started listing files generated by
CMake as inputs to the configuration process instead of outputs from it.
Move the list of files generated by CMake to the regeneration rule
outputs section and tell Ninja to restat after running it.
2014-01-13 10:09:48 -05:00
Stephen Kelly 38de54cf6f cmGeneratorTarget: Add methods to access source file groups.
These methods and others will be able to get a config parameter
later to implement the INTERFACE_SOURCES feature.
2014-01-09 19:38:07 +01:00
Stephen Kelly ef25ba8d06 Constify handling of target dependencies. 2013-12-11 15:30:11 +01:00
Brad King 123a0608df Teach GenerateBuildCommand to find its own make program
Add a cmGlobalGenerator::SelectMakeProgram method to select a
caller-provided make program, the CMAKE_MAKE_PROGRAM cache entry, or a
generator-provided default.  Call it from all implementations of the
GenerateBuildCommand method with the corresponding generator's default,
if any.
2013-11-18 11:30:48 -05:00
Brad King 8904d1410b cmGlobalGenerator: Cleanup GenerateBuildCommand API
All cmGlobalGenerator::GenerateBuildCommand call sites that need to
produce a string now generate "cmake --build" commands.  The remaining
call sites immediately pass the result to cmSystemTools::RunSingleCommand.
Avoid the intermediate string and argument parsing by directly producing a
vector of strings.  Also drop the ignoreErrors argument because no call
sites remain that use it.
2013-11-18 08:26:21 -05:00
Brad King 684063c036 Refactor tool selection for edit_cache (#14544)
Refactor edit_cache tool selection to ask each global generator for its
preference.  Teach the Ninja generator to always use cmake-gui because
Ninja by design cannot run interactive terminal dialogs like ccmake.
Teach the Makefile generator to use cmake-gui when also using an "extra"
generator whose IDE has no terminal to run ccmake, and otherwise fall
back to CMAKE_EDIT_COMMAND selection for normal Makefile build systems.
2013-11-12 08:47:19 -05:00
Brad King e378bc6441 Merge topic 'ninja-use-deps'
eeb4aec Ninja: use deps = gcc/msvc feature
2013-10-28 08:38:40 -04:00
Peter Kümmel eeb4aece1c Ninja: use deps = gcc/msvc feature
cmcldeps is now only used for .rc file processing
2013-10-24 19:48:18 +02:00
Brad King 0c39a757da Drop the 'Full' field from cmDocumentationEntry
We need only 'Brief' for usage documentation.  We no longer have builtin
'Full' documentation, which is now in Help/*/*.rst files.
2013-10-16 09:22:37 -04:00
Stephen Kelly fe732264e9 Add the INTERFACE_LIBRARY target type.
This target type only contains INTERFACE_* properties, so it can be
used as a structural node. The target-specific commands enforce
that they may only be used with the INTERFACE keyword when used
with INTERFACE_LIBRARY targets. The old-style target properties
matching LINK_INTERFACE_LIBRARIES_<CONFIG> are always ignored for
this target type.

The name of the INTERFACE_LIBRARY must match a validity generator
expression. The validity is similar to that of an ALIAS target,
but with the additional restriction that it may not contain
double colons. Double colons will carry the meaning of IMPORTED
or ALIAS targets in CMake 2.8.13.

An ALIAS target may be created for an INTERFACE library.

At this point it can not be exported and does not appear in the
buildsystem and project files are not created for them. That may
be added as a feature in a later commit.

The generators need some changes to handle the INTERFACE_LIBRARY
targets returned by cmComputeLinkInterface::GetItems. The Ninja
generator does not use that API, so it doesn't require changes
related to that.
2013-10-07 19:56:31 -04:00
Brad King e6f93dc560 Merge topic 'windows_ninja_duplicate_paths'
a11da72 Ninja: Properly convert all paths to unix style before we do set intersection.
2013-07-24 11:02:33 -04:00