Commit Graph

901 Commits

Author SHA1 Message Date
Stephen Kelly d92887efab Replace 'foo.size() > 0' pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Brad King 4ecc392b42 Merge topic 'delete-algorithm'
65b81da4 cmVariableWatch: Use the cmDeleteAll algorithm with for_each.
30d2de9a cmGeneratorExpressionEvaluator: Replace own algorithm with cmDeleteAll.
4a6e795b Use the cmDeleteAll algorithm instead of trivial raw loops.
abb4a678 Add a generic algorithm for deleting items in a container.
2015-01-15 09:54:04 -05:00
Brad King 6418eef222 Merge topic 'fix-COMPILE_FEATURES-genex'
45ec182d Features: Fix the COMPILE_FEATURES genex for unavailable features.
2bead0eb cmMakefile: Rename a method to what it really does.
2015-01-15 09:54:02 -05:00
Stephen Kelly 4a6e795b0c Use the cmDeleteAll algorithm instead of trivial raw loops. 2015-01-13 23:00:17 +01:00
Stephen Kelly 2bead0eb1b cmMakefile: Rename a method to what it really does.
The method does not test availability of compile features.
2015-01-12 10:30:43 -05:00
Brad King dd6c596c12 Merge topic 'join-algorithm'
55a73e6b Use the cmJoin algorithm where possible.
8dc8d756 cmStandardIncludes: Add a join algorithm for string containers.
b5813cee cmInstallCommand: Remove unused variable.
2015-01-12 09:41:02 -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
Stephen Kelly 238dd2fbab Use insert instead of a loop in some cases.
Limit this change to inserting into a vector from a vector.

A follow up change can use insert for inserting into a set.
2015-01-11 17:00:55 +01:00
Stephen Kelly 55a73e6b1f Use the cmJoin algorithm where possible. 2015-01-08 22:28:18 +01:00
Brad King c7bd275393 Merge topic 'cached-regex-clear-fixed'
ceecd790 cmMakefile: store the number of last matches in a CMake var
7878d061 test: add a test for clearing regex results
2014-12-04 10:23:26 -05:00
Ben Boeckel ceecd7902f cmMakefile: store the number of last matches in a CMake var
With PushScope and PopScope, keeping track of another bit of data for
each scope isn't easy. Instead, store it as another CMake variable so it
gets implicitly tracked along with everything else.

This works in a revert of commit
7d674b5f0b.
2014-12-03 11:06:44 -05:00
Ruslan Baratov e6db4c5a4e file: Add LOCK subcommand to do file and directory locking
Provide options to fail without blocking or to block up to a timeout.
Provide options to specify the scope containing the lock so it can be
released automatically at the end of a function, file, or process.

Extend the RunCMake.file test with cases covering the file(LOCK) command
usage and error cases.
2014-12-03 09:47:44 -05:00
Brad King 808c77e231 Merge branch 'revert-cached-regex-clear' into revert-cached-regex-clear-for-master
Resolve conflict in Source/cmMakefile.h by integrating both changes.
2014-11-26 13:53:06 -05:00
Ben Boeckel 7d674b5f0b Revert "ClearMatches: Only clear matches which were actually set" (#15261)
This reverts commit v3.1.0-rc1~557^2~2 (ClearMatches: Only clear matches
which were actually set, 2014-03-12).  The optimization did not track
the match count in the same scope as the variables, allowing possible
inconsistency.

Resolve conflicts in Source/cmIfCommand.cxx, Source/cmMakefile.cxx,
and Source/cmMakefile.h by moving the changes to the new location
of the code involved.
2014-11-26 13:45:06 -05:00
Gregor Jasny bae604d9a8 Track nested loop levels in CMake language with a stack of counters
It gets incremented while entering a loop block (e.g. foreach or while)
and gets decremented when leaving the block. Because scope borders for
example at function borders must be taken into account the counter is
put into a stack. With every new scope an empty counter is pushed on the
stack, when leaving the scope the original value is restored.

This will allow easy querying if the break command is properly nested
within a loop scope.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
2014-11-25 14:14:15 -05: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 fe5d6e8c0f Add USES_TERMINAL option for custom commands
Teach the add_custom_command and add_custom_target commands a new
USES_TERMINAL option.  Use it to tell the generator to give the command
direct access to the terminal if possible.
2014-11-14 11:55:09 -05:00
Brad King 8eb64831be Merge topic 'revert-definition-map-lookup'
d1b62185 Merge branch 'parent-scope-tests' into variable-pull-failure
5f414cef Revert "cmDefinitions: Don't store parent lookups"
e0c0b1ac test: add a test for PARENT_SCOPE with multiple scopes
064c415d test: add test for PARENT_SCOPE behavior
2014-10-27 08:32:26 -04:00
Brad King 0c3ddf8b65 Merge branch 'revert-definition-map-lookup' into release 2014-10-24 13:38:32 -04:00
Ben Boeckel 5f414cefb6 Revert "cmDefinitions: Don't store parent lookups"
This reverts commit 5abfde6cb8.

The behaviors associated with implicit pulldown on variable lookup
seriously conflict with the optimizations made in these commits.
Basically, since values were copied upon variable lookup, not just on
PARENT_SCOPE, coupled with PARENT_SCOPE's behavior based on whether the
variable is in the current scope or not causes serious problems with not
storing a value for every variable at every scope.

The commit changed behavior of the following example, among other cases:

  function(test_set)
    set(blah "value2")
    message("before PARENT_SCOPE blah=${blah}")
    set(blah ${blah} PARENT_SCOPE)
    message("after PARENT_SCOPE blah=${blah}")
  endfunction()
  set(blah value1)
  test_set()
  message("in parent scope, blah=${blah}")

Reported-by: Alex Merry <alex.merry@kde.org>
Reported-by: Ben Cooksley <bcooksley@kde.org>
2014-10-24 13:31:21 -04: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 9edf6903e6 Merge topic 'if-sanity'
858d5a0b Fix if() checks of CMAKE_SYSTEM_NAME on Cygwin
e177e7af FPHSA: Avoid if() dereferencing of quoted variable
425acc52 cmcurl: Use if(DEFINED) to simplify conditions
cede5cbd libarchive: Avoid depending on if() to dereference a quoted variable
2d97178b FindGTK2: Avoid depending on if() to dereference a quoted variable
0b12815d Modules/Test*.cmake: Use if(DEFINED) to simplify conditions
188a1f23 If: Introduce policy CMP0054 - don't dereference quoted variables in if()
b900c1cc If: Extract cmConditionEvaluator from if() implementation
2014-09-15 10:27:36 -04:00
Nils Gladitz 188a1f236e If: Introduce policy CMP0054 - don't dereference quoted variables in if() 2014-09-11 21:23:17 +02: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 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
Ben Boeckel 4b13916970 cmMakefile: fix __CMAKE_RULE property setting
It got put into the condition by mistake.
2014-07-14 12:55:04 -04:00
Ben Boeckel 6208c285c8 cmMakefile: Defer dependency calculations 2014-07-08 10:13:51 -04:00
Ben Boeckel dc2e26df01 cmMakefile: Avoid excess source files
When there are no commands, a main_dependency is not required and when
there are also no dependencies, nothing is required.
2014-07-08 10:13:51 -04:00
Ben Boeckel d2803fbac6 cmMakefile: Add a CreateSource method
The GetOrCreateSource searches the source file listing again, but some
callers know that it already didn't exist.
2014-07-08 10:13:50 -04:00
Ben Boeckel 5abfde6cb8 cmDefinitions: Don't store parent lookups
When looking up scopes, it is faster to not store the lookup locally to
keep the maps smaller and avoid extra allocations and rebalancing.
2014-06-09 14:46:45 -04:00
Ben Boeckel 2a1b2d8486 backtrace: Convert to local paths in IssueMessage
This is the only place we care show the FilePath to the user, so defer
the expensive relative path calculation until here.
2014-06-05 12:44:19 -04:00
Ben Boeckel d46c650d67 cmMakefile: return a backtrace
This allows backtraces to be fully controlled by the makefile rather
than externally (and makes changing how they are manipulated easier).
2014-06-05 12:44:04 -04:00
Brad King 1468e986e1 Merge topic 'cxx14-features'
dd043c3f Features: Add support for C++14 features.
2014-05-29 09:58:37 -04:00
Brad King 4a67e9cd41 Merge topic 'dev/CMP0053-variable_watch'
9ba91463 tests: test CMP0053 in WARN mode when watching variables
2014-05-27 09:46:33 -04:00
Brad King 03a3ee222b Merge topic 'variable_watch-no-allowed-access'
d8498003 variable_watch: Remove undocumented and redundant access type
2014-05-27 09:46:32 -04:00
Stephen Kelly dd043c3f21 Features: Add support for C++14 features.
Record the features implemented by GNU 4.9 and Clang 3.4.
2014-05-22 18:01:23 +02:00
Ben Boeckel 9ba91463e6 tests: test CMP0053 in WARN mode when watching variables
When CMP0053 is in WARN mode, variables get expanded twice, leaking the
fact that the string was expanded twice and changing behavior. Instead,
suppress variable watches when running the expansion to trigger the
CMP0053 warning.
2014-05-22 11:13:29 -04:00
Ben Boeckel d849800351 variable_watch: Remove undocumented and redundant access type
The ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS access type was switched on an
undocumented variable and its lookup caused an unnecessary performance
impact.  Remove it.
2014-05-22 10:36:49 -04:00
Stephen Kelly 0dfe395e3c Features: Add COMPILE_FEATURES generator expression.
Allow setting build properties based on the features available
for a target.  The availability of features is determined at
generate-time by evaluating the link implementation.

Ensure that the <LANG>_STANDARD determined while evaluating
COMPILE_FEATURES in the link implementation is not lower than that
provided by the INTERFACE of the link implementation.  This is
similar to handling of transitive properties such as
POSITION_INDEPENDENT_CODE.
2014-05-21 17:22:32 +02:00
Stephen Kelly aa8a6fcee8 cmMakefile: Add methods for checking availability of a feature. 2014-05-20 19:01:27 +02:00
Stephen Kelly b6dedf034e cmMakefile: Extract CheckNeeded{C,Cxx}Language methods. 2014-05-20 16:11:35 +02:00
Stephen Kelly 8dd129dfbb cmMakefile: Extract CompileFeaturesAvailable method. 2014-05-20 16:11:34 +02:00
Stephen Kelly 6b9b2fff61 cmMakefile: Extract CompileFeatureKnown method. 2014-05-20 16:11:34 +02:00
Stephen Kelly e0890d03a4 Features: Extend concept to C language.
Add properties and variables corresponding to CXX equivalents.

Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.

Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
2014-05-15 00:15:18 +02:00
Stephen Kelly bc9a8bba46 Makefile: Undef FEATURE_STRING iteration define after use. 2014-05-10 13:12:14 +02:00
Ben Boeckel bc38565863 EVIS: Reimplement using custom parsing code
Introduce a new implementation of ExpandVariablesInString and select
between the old and new implementations based on policy CMP0053.
Instead of cmCommandArgumentParserHelper, use a custom parser with our
own stack.  This is much faster and works well for our simple grammar.

The new behavior of CMP0053 should expand @VAR@ syntax only in certain
contexts.  All existing EVIS callers use "replaceAt == true" so
hard-code our call to the old implementation.  Update the signature to
default to "replaceAt == false" and pass "replaceAt == true" explicitly
in the call sites for configure_file and string(CONFIGURE).

Testing the configure (no generate) step with ParaView shows ~20%
performance improvement.

In terms of complete configure/generate steps, further testing with
ParaView shows a 20% performance improvement over 2.8.12.2 with Unix
Makefiles and minimal with Ninja. Ninja is less because it generate step
is the expensive part (future work will address this) by a long shot and
these changes help the configure step for the most part.
2014-05-08 13:24:49 -04:00
Brad King 3e206022ab Merge topic 'minor-cleanups'
47795421 Fix whitespace in docs.
aa283b6b Features: Fix test for GNU 4.8.1.
bbfd4cd4 Features: Include the language of the compiler in error messages.
2014-05-08 11:27:57 -04:00
Brad King 1cc1efc063 Merge topic 'dev/regex-variables'
3f517522 StoreMatches: Minor cleanups
ef62fbad ClearMatches: Store match variable names statically
f718b30a ClearMatches: Only clear matches which were actually set
2014-05-07 15:59:47 -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 ac4106c69a cmMakefile: Use a hashmap for imported targets 2014-05-07 15:48:32 -04:00
Stephen Kelly bbfd4cd48f Features: Include the language of the compiler in error messages. 2014-05-07 12:36:22 +02:00
Stephen Kelly 3fdfa5d3fc Features: Make CMAKE_CXX_KNOWN_FEATURES a property.
As a 'built-in' variable it imposes a cost on all variable lookups
and it is expected to be rarely used.
2014-05-02 10:18:16 +02:00
Brad King 8535d4cf5d Merge topic 'cxx98-features'
a36b957f Features: Add cxx_template_template_parameters.
2014-04-30 09:42:00 -04:00
Ben Boeckel 3f51752264 StoreMatches: Minor cleanups 2014-04-29 16:00:06 -04:00
Ben Boeckel ef62fbad55 ClearMatches: Store match variable names statically
Constructing the names and then turning them into a std::string is
non-negligible in performance testing.
2014-04-29 16:00:05 -04:00
Ben Boeckel f718b30a95 ClearMatches: Only clear matches which were actually set
ClearMatches was clearing many variables which were never set in the
first place. Instead, store how many matches were made last time and
only clear those. It is moved to the cmMakefile class since it is a
common utility used by multiple commands.
2014-04-29 16:00:05 -04:00
Stephen Kelly 8d0b1ccac1 Features: FATAL_ERROR on compilers with no recorded features.
Users of the new target_compile_features command are expected to
check the existence of the CMAKE_CXX_COMPILE_FEATURES variable before
attempting to use it to require features.
2014-04-17 16:20:50 +02:00
Stephen Kelly a36b957fc4 Features: Add cxx_template_template_parameters.
Extend the existing feature infrastructure as needed to support
both C++11 and C++98 features.
2014-04-16 15:16:23 +02:00
Stephen Kelly 60c0d2dd81 Features: Add cxx_defaulted_move_initializers. 2014-04-08 11:05:58 +02:00
Stephen Kelly c4e672358c Features: Add cxx_long_long_type. 2014-04-08 11:05:58 +02:00
Stephen Kelly dcaafada0e Features: Add cxx_func_identifier. 2014-04-08 11:05:57 +02:00
Stephen Kelly 251a1f02a0 Features: Add cxx_local_type_template_args. 2014-04-08 11:05:57 +02:00
Stephen Kelly 53fe7773e6 Features: Add cxx_extended_friend_declarations. 2014-04-08 11:05:57 +02:00
Stephen Kelly 16603f7cdb Features: Add cxx_enum_forward_declarations. 2014-04-08 11:05:57 +02:00
Stephen Kelly adf22f611e Features: Add cxx_default_function_template_args. 2014-04-08 11:05:57 +02:00
Stephen Kelly 7b3e8a0534 Features: Add cxx_right_angle_brackets. 2014-04-08 11:05:57 +02:00
Stephen Kelly 9a49fd21be Features: Add cxx_decltype_incomplete_return_types. 2014-04-08 11:05:57 +02:00
Stephen Kelly 1889045ca6 Features: Add cxx_sizeof_member. 2014-04-08 11:05:57 +02:00
Stephen Kelly ab455ebafd Features: Add cxx_thread_local. 2014-04-08 11:05:57 +02:00
Stephen Kelly 300ce2481e Features: Add cxx_inline_namespaces. 2014-04-08 11:05:57 +02:00
Stephen Kelly f9d04a96b5 Features: Add cxx_variadic_macros. 2014-04-08 11:05:57 +02:00
Stephen Kelly 3d76656fb3 Features: Add cxx_uniform_initialization. 2014-04-08 11:05:56 +02:00
Stephen Kelly e74b216c90 Features: Add cxx_generalized_initializers. 2014-04-08 11:05:56 +02:00
Stephen Kelly ff80c3b420 Features: Add cxx_attributes. 2014-04-08 11:05:56 +02:00
Stephen Kelly 7605fee593 Features: Add cxx_alignof. 2014-04-08 11:05:56 +02:00
Stephen Kelly e7d6e1f44f Features: Add cxx_alignas.
cxx_alignof will be a separate feature known to CMake, because
both can be implemented with separate backward compatibility
versions.
2014-04-08 11:05:56 +02:00
Stephen Kelly 32c2acd65c Features: Add cxx_extern_templates. 2014-04-08 11:05:56 +02:00
Stephen Kelly 9064f78b0c Features: Add cxx_unrestricted_unions. 2014-04-08 11:05:56 +02:00
Stephen Kelly 3322b393a2 Features: Add cxx_unicode_literals. 2014-04-08 11:05:56 +02:00
Stephen Kelly 04c5b99f38 Features: Add cxx_user_literals. 2014-04-08 11:05:56 +02:00
Stephen Kelly e1e292cd06 Features: Add cxx_alias_templates. 2014-04-08 11:05:56 +02:00
Stephen Kelly 3300f78310 Features: Add cxx_rvalue_references. 2014-04-08 11:05:55 +02:00
Stephen Kelly b1c5bd5314 Features: Add cxx_reference_qualified_functions. 2014-04-08 11:05:55 +02:00
Stephen Kelly ea9c445f06 Features: Add cxx_raw_string_literals. 2014-04-08 11:05:55 +02:00
Stephen Kelly 735adf2c94 Features: Add cxx_range_for. 2014-04-08 11:05:55 +02:00
Stephen Kelly 0fa9bbf1fa Features: Add cxx_nullptr. 2014-04-08 11:05:55 +02:00
Stephen Kelly 8149fc909f Features: Add cxx_noexcept. 2014-04-08 11:05:55 +02:00
Stephen Kelly bd2a025eb0 Features: Add cxx_nonstatic_member_init. 2014-04-08 11:05:55 +02:00
Stephen Kelly 15cdf6f51d Features: Add cxx_lambdas. 2014-04-08 11:05:55 +02:00
Stephen Kelly a579a0aab4 Features: Add cxx_inheriting_constructors. 2014-04-08 11:05:55 +02:00
Stephen Kelly ebab2015f9 Features: Add cxx_explicit_conversions. 2014-04-08 11:05:55 +02:00
Stephen Kelly ac3a1b14c0 Features: Add cxx_deleted_functions. 2014-04-08 11:05:55 +02:00
Stephen Kelly 91f3699000 Features: Add cxx_defaulted_functions. 2014-04-08 11:05:54 +02:00
Stephen Kelly 7e748417bc Features: Add cxx_decltype. 2014-04-08 11:05:54 +02:00
Stephen Kelly 8d3467636c Features: Add cxx_strong_enums. 2014-04-08 11:05:54 +02:00
Stephen Kelly 0caf08e43e Features: Add cxx_auto_function. 2014-04-08 11:05:54 +02:00
Stephen Kelly 0685ac6edc Features: Add cxx_override. 2014-04-08 11:05:54 +02:00
Stephen Kelly 57ac6a905c Features: Add cxx_final. 2014-04-08 11:05:54 +02:00