Commit Graph

168 Commits

Author SHA1 Message Date
Pavel Solodovnikov
37d9387be3 Replace empty-string comparisons with checking against empty(). 2017-09-21 11:23:19 +03:00
Pavel Solodovnikov
7d5095796a Meta: modernize old-fashioned loops to range-based for.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-12 16:22:47 +03:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Brad King
4f5bbbeab9 Add deprecation warnings for policies CMP0036 and below
The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for some policies
to encourage projects to port away from setting policies to OLD.
2017-04-21 15:04:33 -04:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
Automate with:

git grep -l '#include <cm_' -- Source \
  | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g'

git grep -l '#include <cmsys/' -- Source \
  | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g'

git grep -l '#include <cm[A-Z]' -- Source \
  | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
2017-04-11 22:35:21 +02:00
Stephen Kelly
e6eecec761 cmListFileCache: Remove cmState header include
Include it in dependents which have previously relied on it
transitively.
2016-10-19 15:41:00 +02:00
Stephen Kelly
a91eaf3872 cmState: Port dependents to new cmStateTypes header 2016-10-19 15:40:59 +02:00
Stephen Kelly
2fe3e55d53 cmState: Move CacheEntryType enum to separate namespace
Port dependent code to the change.
2016-10-19 15:40:58 +02:00
Daniel Pfeifer
1a9de8035c surround macro arguments with parentheses 2016-09-05 22:09:49 +02:00
Daniel Pfeifer
5cbb548807 fix a batch of include-what-you-use violations 2016-08-24 00:29:15 +02:00
Daniel Pfeifer
e7b842e189 Make sure unnused parameters are /*named*/ 2016-08-17 01:49:57 +02:00
Daniel Pfeifer
1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King
0ac18d40c8 Remove //------... horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King
e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King
180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Brad King
cc684857c2 cmPolicies.cxx: Add missing include <ctype.h> for isdigit (#16066) 2016-04-15 13:46:15 -04:00
Stephen Kelly
5447ca1a94 cmMakefile: Remove CMP0001 handling to callers. 2015-07-25 14:48:37 +02:00
Stephen Kelly
71e69fc93b cmPolicies: Store only state that users can set.
cmPolicies::PolicyMap does not need to store the REQUIRED_ALWAYS or
REQUIRED_IF_USED states as they are statically determined.
2015-07-25 14:48:36 +02:00
Stephen Kelly
93cc2eef38 cmPolicies: Store all statuses in a single bitset.
Currently there are an optimal number of policies (64) such that
there are no wasted bits.  When another policy is added, the
cmPolicyMap will grow from 40 bytes to 80, and occupy 45.  By storing
all in a single bitset, we stay under the cache line size of 64 bytes
until there are 512 policies in a range.
2015-06-07 09:29:29 +02:00
Stephen Kelly
44a8115797 cmPolicies: Replace UNDEFINED bitset with WARN bitset.
Might as well use the existing concept.
2015-06-06 10:09:45 +02:00
Stephen Kelly
013ada80ea cmPolicies: Implement PolicyMap in terms of bitset. 2015-05-04 22:32:21 +02:00
Stephen Kelly
be6664c208 cmPolicies: Implement abstraction for PolicyMap.
Hide the detail that it is a std::map.
2015-05-04 22:32:21 +02:00
Stephen Kelly
13981f2068 cmPolicies: Make all API static. 2015-05-04 22:32:20 +02:00
Stephen Kelly
23e2bcc8db cmPolicies: Remove unused DefinePolicy method.
Policies are no longer defined at runtime.
2015-05-04 22:32:20 +02:00
Stephen Kelly
5641ba4fca cmPolicies: Remove unused cmPolicy class. 2015-05-04 22:32:20 +02:00
Stephen Kelly
3de5449703 cmPolicies: Loop over all policies using enum constants. 2015-05-04 22:32:19 +02:00
Stephen Kelly
387aff200c cmPolicies: Trivialize GetPolicyStatus method.
It would be possible to implement this with an XMacro and switch
statement, but every codepath currently would still return WARN.
2015-05-04 22:32:19 +02:00
Stephen Kelly
dbf680d670 cmPolicies: Use more-direct ID access. 2015-05-04 22:32:19 +02:00
Stephen Kelly
8c204133e5 cmPolicies: Implement in terms of public API. 2015-05-04 22:32:19 +02:00
Stephen Kelly
e3a8c0291e cmPolicies: Make private method file-static. 2015-05-04 22:32:19 +02:00
Stephen Kelly
cb765af049 cmPolicies: Implement short description access with XMacros. 2015-05-04 22:32:18 +02:00
Stephen Kelly
5df267fa1d cmPolicies: Implement version check with XMacro. 2015-05-04 22:32:18 +02:00
Stephen Kelly
2235cfebee cmPolicies: Implement id to version with XMacro. 2015-05-04 22:32:18 +02:00
Stephen Kelly
05d8438860 cmPolicies: Implement id to string conversion with XMacro. 2015-05-04 22:32:18 +02:00
Stephen Kelly
fdca04db68 cmPolicies: Implement more-compact IsPolicyNewerThan. 2015-05-04 22:32:17 +02:00
Stephen Kelly
a7ff972751 cmPolicies: Parse string for id conversion.
Remove now-unused PolicyStringMap.
2015-05-04 22:32:17 +02:00
Stephen Kelly
953d1b00af cmPolicies: Make private method file-static. 2015-05-03 10:09:10 +02:00
Stephen Kelly
2c10494ab3 cmPolicies: Remove runtime check for programming errors. 2015-05-03 10:08:50 +02:00
Stephen Kelly
fd0aa7434b cmPolicies: Remove unused static data. 2015-05-03 10:08:04 +02:00
Stephen Kelly
a3291fe8ec cmPolicies: Remove unused header. 2015-05-03 10:07:58 +02:00
Nils Gladitz
aed6239e40 if: Implement new IN_LIST operator 2015-04-30 10:21:19 -04:00
Nils Gladitz
32a2f41402 Revert "add_custom_command: Diagnose MAIN_DEPENDENCY limitation."
This reverts commit 242c3966 (add_custom_command: Diagnose
MAIN_DEPENDENCY limitation, 2015-03-09) and the follow up commit
b372a99a (UseSWIG: Do not use MAIN_DEPENDENCY on custom commands,
2015-03-26).

I misdiagnosed the underlying issue that prompted creation of policy CMP0057.
The actual issue surfaces when a single custom command's MAIN_DEPENDENCY
is listed in more than one target; this issue will have to be addressed
independently.
2015-04-30 10:20:20 -04:00
Brad King
882f48e5ba Link libraries by full path even in implicit directories
When CMP0003 was first introduced we wanted to link all libraries by
full path.  However, some projects had problems on platforms where
find_library would find /usr/lib/libfoo.so when the project really
wanted to link to /usr/lib/<arch>/libfoo.so and had been working by
accident because pre-CMP0003 behavior used -lfoo to link.

We first tried to address that in commit v2.6.0~440 (Teach find_library
to avoid returning library paths in system directories, 2008-01-23) by
returning just "foo" for libraries in implicit link directories.  This
caused problems for projects expecting find_library to always return a
full path.  We ended up using the solution in commit v2.6.0~366 (...
switch library paths found in implicit link directories to use -l,
2008-01-31).  However, the special case for libraries in implicit link
directories has also proven problematic and confusing.

Introduce policy CMP0060 to switch to linking all libraries by full path
even if they are in implicit link directories.  Explain in the policy
documentation the factors that led to the original approach and now to
this approach.
2015-04-09 11:29:18 -04:00
Stephen Kelly
06f61c26cf Do not treat DEFINITIONS as a built-in directory property
Add policy CMP0059 to cover this change.  The property has been
deprecated since CMake 2.4 anyway.

This will help clean up cmMakefile -- the DefineFlagsOrig member should
not need to exist.
2015-04-02 13:00:48 -04:00
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
15b06bc012 Merge topic 'cmAlgorithms-cleanup'
95dd238f cmRemoveDuplicates: Fix iterator -> const_iterator.
4448f175 cmInstalledFile: Move Property implementation out of line.
7916d7ba Include cmAlgorithms where it is used.
2015-03-12 15:26:35 -04:00
Stephen Kelly
7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Nils Gladitz
242c396656 add_custom_command: Diagnose MAIN_DEPENDENCY limitation.
The new policy CMP0057 diagnoses reuse of the same MAIN_DEPENDENCY across
multiple custom commands.
2015-03-09 12:45:38 +01:00