Add .DELETE_ON_ERROR to the "build.make" files that contain the actual
build rules that generate files. This tells GNU make to delete the
output of a rule if the recipe modifies the output but returns failure.
This is particularly useful for custom commands that use shell
redirection to produce a file.
Do not add .DELETE_ON_ERROR for Borland or Watcom make tools because
they may not tolerate it and would not honor it anyway. Other make
tools that do not understand .DELETE_ON_ERROR will not be hurt.
Suggested-by: Andrey Vihrov <andrey.vihrov@gmail.com>
Revert commit v3.0.0-rc1~175^2~20 (add_dependencies: Disallow use with
INTERFACE_LIBRARY, 2013-12-25). Teach our dependency analysis to
transitively follow INTERFACE target utility dependencies as was done or
IMPORTED targets in commit v2.8.6~127^2~1 (Allow add_dependencies() on
imported targets, 2010-11-19). Extend the InterfaceLibrary test with a
case to cover header generation for a header-only INTERFACE library via
a custom target.
The rcc outputs are byproducts of the cmake_autogen rule, not outputs.
We still must run cmake_autogen on every run even if the rcc outputs
exist. Ninja requires explicit byproduct specification, which is now
possible in CMake since commit v3.2.0-rc1~340^2~2 (Add an option for
explicit BYPRODUCTS of custom commands, 2014-11-13). Revise the logic
introduced by commit v3.2.0-rc1~480^2 (QtAutogen: Regenerate qrc files
if their input changes, 2014-09-17) to specify byproducts explicitly.
Teach the Xcode generator that ONLY_ACTIVE_ARCH=YES means to use ARCHS,
and that the default of ONLY_ACTIVE_ARCH=NO means to use NATIVE_ARCH and
ignore ARCHS. In the latter case there is no reason to generate ARCHS.
"XML_Parser" in cmexpat is a typedef for void* while newer releases of
expat seem to use struct XML_ParserStruct *XML_Parser.
Add static_casts so that the build works with either variant.
The file lock functionality added in commit v3.2.0-rc1~297^2~1 (file:
Add LOCK subcommand to do file and directory locking, 2014-11-26) forgot
to close the lock file descriptors. Eventually it was possible to run
out of file descriptors and locks could not longer be acquired. Fix
this by closing the file descriptor or handle when we are done with it.
Also set the member back to the initial value from the constructor
to leave everything in a consistent state (useful for debugging).
Co-Author: Ruslan Baratov <ruslan_baratov@yahoo.com>
bd9c7f9b Ninja: Add policy to require explicit custom command byproducts
ed8e30b0 cmGlobalNinjaGenerator: Optimize handling of known build outputs
ad094f43 cmGlobalNinjaGenerator: Fix spelling of "unknown"
82a37d3c cmGlobalNinjaGenerator: Drop unused member
4178cd88 Help: Add notes for topic 'xcode-xctest'
87a4b858 Tests: Add XCTest example to test Frameworks and Cocoa App Bundles
ba14510b OS X: Add FindXCTest module
3714955b OS X: Add handling for XCTest bundles
54a5cdbb Tests: Compute Xcode version for any generator on OS X
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.
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.
GLOB lists directories by default and GLOB_RECURSE does not.
LIST_DIRECTORIES enables user to control the behavior explicitly for
consistently for both GLOB and GLOB_RECURSE.
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
Any environment vars that were configured for a test via the
ENVIRONMENT property will now be output when the test is run
with verbose logging enabled.
ec428faf Genex: Extend cmGeneratorExpressionContext constructor.
082b6a9d Genex: Split cmGeneratorExpressionContext into own file.
9df1f0fc Genex: Split cmGeneratorExpressionNode into own file.
80b9f0cb Genex: Extract an evaluateWithContext method.
642048ce Help: Move docs of $<0:...> and $<1:...> to output section.
8701a3f4 cmRemoveDuplicates: Partially specialize the API for pointer types.
eec7091d cmRemoveDuplicates: Type-parameterize all uniq-operations
7cbafa8c cmRemoveDuplicates: Store unique iterators instead of values.
95dd238f cmRemoveDuplicates: Fix iterator -> const_iterator.
4448f175 cmInstalledFile: Move Property implementation out of line.
7916d7ba Include cmAlgorithms where it is used.
If de-duplicating a container of pointers, there is no need to
store iterators to them, as that is just more 'pointer chasing'.
Store the pointers themselves and use API which compares the pointers
in the specialization.
There is no need to copy all of the values in the container in
order to determine uniqueness. Iterators can be stored instead
and can be used with standard algorithms with custom comparison
methods.
This also means that we use less space in case the value_type size
is greater than sizeof(iterator). That is common for std::string
which may require up to 32 bytes (libstdc++ 5.0 and MSVC at least).
With libstdc++ 4.9 and older, std::string is 8 bytes, so we likely
don't gain anything here.
Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
232a6883 Help: Add release notes for target-language-genex.
9e168941 File(GENERATE): Process genex evaluation files for each language.
b734fa44 Genex: Allow COMPILE_LANGUAGE when processing include directories.
0b945ea9 Genex: Allow COMPILE_LANGUAGE when processing compile definitions.
5c559f11 Genex: Enable use of COMPILE_LANGUAGE for compile options.
e387ce7d Genex: Add a COMPILE_LANGUAGE generator expression.
4a0128f4 VS6: Compute CMAKE_*_FLAGS and COMPILE_DEFINITIONS* only when needed
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.
Due to a difference in how AdditionalOptions are implemented in the
Fortran component of VS and the C/C++ component, flags that are not
listed in the flag table are at risk of being overwritten.
The unknown argument warning added by commit v3.2.0-rc1~452^2
(configure_file: Warn about unknown arguments, 2014-10-31) failed to
account for options handled by the NewLineStyle member instead of
directly in the main loop. Simply whitelist them for now.
In commit v3.2.0-rc1~272^2~2 (Makefile: Fix rebuild with multiple custom
command outputs, 2014-12-05) we changed the generated makefile pattern
for multiple outputs from
out1: depends...
commands...
out2: out1
to
out1 out2: depends...
commands...
This was based on the incorrect assumption that make tools would treat
this as a combined output rule and run the command(s) exactly once for
them. It turns out that instead this new pattern is equivalent to
out1: depends...
commands...
out2: depends...
commands...
so the commands may be run more than once.
Some documents suggest using a "dedicated witness" stamp file:
stamp: depends...
rm -f stamp
touch stamp.tmp
commands...
mv stamp.tmp stamp
out1 out2: stamp
However, if the commands fail the error message will refer to the stamp
instead of any of the real outputs, which may be confusing to readers.
Also, this approach seems to have the same behavior of the original
approach that motiviated the above commit: multiple invocations are
needed to bring consumers of the outputs up to date.
Instead we can return to the original approach but add an explicit
touch to each extra output rule:
out1: depends...
commands...
out2: out1
touch -c out2
This causes make tools to recognize that all outputs have changed and
therefore to execute any commands that consume them.
Preserve all but the last extension when generating .wixobj output
filenames from source files and make sure they are unique.
Output .wixobj files in cpack staging area instead
of the current working directory.
Rename the example jacoco.xml file to be jacoco.xml.in to stop CMake
from apptempting to calculate Jacoco Coverage when running over itself.
Enclose a push of -1 to the coverage vector to only happen if there is a
fin to calculate for. This prevents a crash if the target file doesn't
exist.
This should allow the consuming IDE to determine which target specific
preprocessor definitions and include directories are relevant for a
given source file.
This fixes RunCMake.(Configure|configure_file|try_compile) test
failures that failed to match empty stderr due to jom printing
its identification line.
d1082448 Tests: Extend RunCMake.CommandLine to cover 'cmake --build' for 'ninja -v'
ce935ebe cmake: Teach --build to honor CMAKE_VERBOSE_MAKEFILE for Ninja
A more-specific error message is always displayed earlier in the
output if any real error occurred. This final summary message
is distracting to readers searching through the output for the
word "error". Simply drop it.
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>
Revert commit v3.2.0-rc1~165^2 (Encoding: Write Visual Studio solution
file with BOM, 2014-12-26). The BOM breaks the VS IDE version selector
when loading the .sln from Windows Explorer.
47c2da6a cmAlgorithms: Cache the end iterators in algorithms.
a5b10ae6 cmAlgorithms: Remove needless assignment.
7fd8557f cmAlgorithms: Maintain the pivot iterator in cmRemoveIndices.
1f796791 cmAlgorithms: Relax iterator requirement for cmRemoveIndices.
ba959934 cmAlgorithms: Make cmRemoveDuplicates work with more containers.
cae45df7 cmAlgorithms: Rename template argument to RemoveN.
b917f4c0 cmAlgorithms: Relax cmRemoveN requirement to FwdIter.
bbc1a978 cmAlgorithms: Add a size() to cmRange.
47a3e22e cmAlgorithms: Rename template type in cmDeleteAll algorithm.
cb75eec0 cmAlgorithms: Add const to const objects.
Generate the OutputDirectory element value as an absolute path
to the same location as the existing relative path. Somehow
this addresses an occasional failure in a large/complex build,
and should not hurt basic use cases.
Shorten the CFBundleExecutable in the PList file of Bundles to
the file name only as it is done for Frameworks, too.
Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
6cc01c14 CPackWIX: Add release notes for the wix-shortcut-properties topic.
135febf0 CPackWIX: Enhance CMake CPack WIX generated installer.
e6731f48 CPackWIX: Add new CPACK_STARTUP_SHORTCUTS property.
279605f5 CPackWIX: Add installed file properties for the creation of shortcuts.
53d7daff CPackWIX: Refactor start menu and desktop shortcut creation.
dc0f3fb4 CPackWIX: Explicitly list CPack WIX headers for IDE convenience.
c021f59c cmMakefile: Store macro list in a vector not in a map.
2d130896 cmMakefile: Fix list of macros generation.
f1969234 cmFunctionCommand: Remove ineffectual code.
1116698a cmTarget: Don't needlessly clear vectors in the destructor.
bb9d71b4 Replace loops with algorithms.
4afe6c26 cmAlgorithms: Add cmReverseRange adaptor.
a3a0a8c2 cmAlgorithms: Add cmFindNot algorithm.
8c74a41f cmRST: Replace two erase with a rotate and larger erase.
61fe1919 cmAlgorithms: Update concept requirement to FowardIterator
09d6125b cmAlgorithms: Move cmRotate out of 'implementation detail' namespace.
8ed6ecac cmRST: Move two algorithms beside each other.
dfe49c20 cmRST: Use std::min where appropriate.
21b0654a cmGlobalGenerator: Convert set insert algorithm to vector algorithms.
416df93a Convert some raw loops to cmWrap.
37b88d34 cmAlgorithms: Add cmWrap.
a2818093 Use cmJoin where possible.
76207b08 cmCacheManager: Replace loop with algorithm.
60c3bb73 cmGlobalGenerator: Replace loop with algorithm.
05fec779 cmTarget: Port loop to algorithm.
9c225767 cmGlobalGenerator: Replace set::insert algorithm with cmRemoveDuplicates.
...
cmCTestOptionalLog takes a boolean argument that indicates
whether or not the message should be suppressed. Note that
error messages will still be printed, even if suppression is
requested. This macro will allow us to provide more
fine-grained control over what messages CTest prints to the
console.
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.
Since jsoncpp 0.7.0 (2014-11-20) the upstream may provide a CMake
package configuration file such that find_package(jsoncpp) will find a
jsoncppConfig.cmake file. In order to avoid conflicting with this
(especially on case-insensitive filesystems), and since we always prefer
projects to provide package config files (that they maintain), it is
better to not provide FindJsonCpp publicly.
Move FindJsonCpp into a private source directory that is not installed
so that we can still use it for building CMake itself.
Reported-by: Ryan Pavlik <ryan.pavlik@gmail.com>
The find_package command already knows how to compute installation
prefixes from PATH. Use the same approach to establish prefixes for
find_library, find_file, and find_path to use to look in directories
like "<prefix>/lib[/<arch>]" and "<prefix>/include" for libraries and
headers. This will reduce the amount of configuration end users need to
do to establish a work environment rooted under a specific prefix.
At the start of each configure step we already reset the generator
selection (CMAKE_GENERATOR) to match that loaded for the current
project. Add missing code to reset the generator platform and toolset
(CMAKE_GENERATOR_PLATFORM and CMAKE_GENERATOR_TOOLSET) also so that they
do not leak across projects.
6652afe6 CTest: Use clear instead of erase-all.
75661fdf cmListCommand: Move size variable out of loop.
10e53e23 cmAlgorithms: Add missing const to functors.
74906322 cmAlgorithms: Remove sort of already-sorted container.
2acd04c9 cmcmd: Remove some comment copy-pasta.
2d833232 cmCoreTryCompile: Remove variable assignment.
26602cf5 cmLocalGenerator: Move variable population inside of condition.
cfb84834 Update comment to match recent dashboard testing.
6010f936 Revert "cmGlobalGenerator: Fix value type pushed into autogens vector"
0550b9e3 Revert "Attempt to fix the compile of cmake on Sun CC."
1ee4721f Help: Fix formatting of command parameter.
62429a1e cmGlobalGenerator: Remove unneeded pointer check.
c697c1fa cmTarget: Remove template argument workaround.
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.
Pre-C++98 compilers required that the template argument be
used in the function parameters. Those compilers are no longer
supported as hosts, so drop the workaround.
Teach cmLocalVisualStudio7Generator to set 'OutputDirectory' using the
same method as is used to set the 'OutputFile' in the generated project
file. Also, OutputDirectory only needs to be set for targets that run the
linker or librarian. These two changes make the VS 7 OutputDirectory
consistent with what cmVisualStudio10TargetGenerator generates for OutDir.
Without this, since the VS Intel Fortran plugin for VS >= 10 still uses
the VS 7 .vfproj file format, when executing test VSGNUFortran using
Intel Fortran Compiler 15.xx, the following warning is issued just
before compilation:
TargetPath(...) does not match the Linker's OutputFile property value (...).
This may cause your project to build incorrectly.
To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt)
property values match the value specified in %(Link.OutputFile).
Subsequently, an error is reported during linking.
Inspired-by: Vincent Newsum <vynewsum@gmail.com>
This will allow us to use a value other than just the config name
for the project OutputDirectory setting used for $(OutDir).
Also use $(ConfigurationName) instead of $(OutDir) for the link
directory configuration suffix since that is a hard-coded instance of
a use case for CMAKE_CFG_INTDIR.
The entire vector will be destroyed at once at the end of the scope,
and the remove algorithms already give us the end of the range of
interesting values, so just use those sentinals.
Start by creating a vector to hold a unique values of the input range. We
expect that in most cases, there will be relatively few duplicates, so
reserving enough memory for a complete copy is worthwhile. Unlike a solution
involving a std::set, this algorithm allocates all the memory it needs
in one go and in one place, so it is more cache friendly.
Populate the unique copy with a lower_bound insert algorithm and record the
indices of duplicates. This is the same complexity as the std::set insert
algorithm, but without the need to allocate memory on the heap and other
disadvantages of std::set.
Remove the duplicates with the cmRemoveIndices algorithm.
Implement ContainerAlgorithms::RemoveN to remove N elements to the
end of a container by rotating. The rotate is implemented in terms
of the efficient swap algorithm, optimized even more in the standard
library implementation when the compiler supports the rvalue-references
feature to move elements. Implement cmRemoveN with a Range API
for completeness.
std::rotate in C++11 is specified to return an iterator, but
c++98 specifies it to return void. libstdc++ 5.0 will be the first
version to have the correct return type. Implement
ContainerAlgorithms::Rotate in terms of std::rotate and return the
correct iterator from it. While std::rotate requires forward iterators,
this workaround means cmRotate requires bidirectional iterators. As
most of CMake uses random access iterators anyway, this should not
be a problem.
Implement cmRemoveIndices in terms of the RemoveN algorithm, such
that each element which is not removed is rotated only once. This
can not use the cmRemoveN range-API algorithm because that would
require creating a new range, but the range must be taken by reference
and so it can't be a temporary.
These remove algorithms are not part of the STL and I couldn't find them
anywhere else either.
Use a ostringstream to account for the input being a variable of type
size_t as a result of using std::distance. There is no single
format string which portably accepts a size_t.
b5f98e50 cmMacroCommand: Manipulate target string directly.
83414d5a cmMacroCommand: Move computation of ARGV%n names out of double loop.
9a1f8f35 cmMacroCommand: Move ARGV replacement out of condition.
4aa7bd2a cmMacroCommand: Remove condition around ARGN replacement.
6774c92b cmMacroCommand: Declare tmps in the scope that it's used.
2c4a7298 cmMacroCommand: Declare arg in the scope that it is used.
a551851a cmMacroCommand: Inline variable computation.
f79c0f76 cmMacroCommand: Compute variables outside of two loops.
8e0827b6 cmMacroCommand: Remove intermediate arg variables.
f2c49f59 cmMacroCommand: Remove condition around ARGN computation.
3250a7e5 cmMacroCommand: Remove conditional append of semicolon.
081a13f7 cmMacroCommand: Declare arg variables where used and initialized.
17b5ebd3 cmMacroCommand: Join the args strings outside of the loops.
7c3f6376 Convert loop into two algorithms.
8a399c8c Convert loop to the common pattern.
abfca975 Move loop inside of condition.
0b61b86d Handle last element outside of the loop.
e21f7829 cmTarget: Use a sorted vector in place of a set.
559dc155 cmSet: Replace loop with cmJoin.
0ea71932 cmFindBase: Replace loop with cmJoin on range.
9380e85f Convert loops to cmJoin algorithm with cmRange.
bb10012f cmStringCommand: Accumulate with cmJoin and range adaptors.
0c12f1ea cmAlgorithms: Add a range adaptor and API for adjusting a range.
27c6f017 Use cmJoin to accumulate string ranges.
4e78ebbd cmAlgorithms: Add a Range container and adaptor method.
89102249 Replace common loop pattern with cmJoin
7b8725bf Convert loops populating maybe-empty content into the common pattern.
7ee56f03 Convert loops into the commonly used pattern.
0a4e5674 cmMacroCommand: Remove counting variable.
...
f30022eb install: Allow generator expressions in TARGETS DESTINATION (#14317)
7607c3d1 cmInstallGenerator: Pass destination explicitly to AddInstallRule
ebd556ca cmInstallGenerator: Fix check for absolute install destinations
290ca8e2 cmInstallGenerator: Refactor computation of absolute install dest
f99991db cmInstallGenerator: Move GetDestination to subclasses that need it
It can make sense to declare objects outside of loops if
the size required by the object can grow (eg std::string when
using getline), but that is not the case here.
Avoid using the std::accumulate algorithm which is designed for
numeric types, not complex types. It introduces unneccessary
copies.
Initialize variables where they are populated.