Commit Graph

20 Commits

Author SHA1 Message Date
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 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
Marc Chevrier 4eb77a1c1d Tests: Use C-Style comments in C sources and headers
Not all C compilers tolerate C++-style comments in C code, so do not use
them in our tests.
2015-09-25 09:34:04 -04:00
Stephen Kelly 4f6bd7022b Remove the LINK_LANGUAGE generator expression.
It accepted an optional argument to test for equality, but no way
to get the linker language of a particular target.

TARGET_PROPERTY provides this flexibility and STREQUAL provides
the necessary API for equality test.

Extend the CompileDefinitions test to cover accessing the
property of another target.
2013-07-24 10:40:00 -04:00
Brad King d3c8688ecd Merge topic 'fix-genex-HEAD-target'
5b22235 Genex: Fix the HEAD target used for evaluated expressions
2013-06-05 09:54:20 -04:00
Stephen Kelly 5b222354de Genex: Fix the HEAD target used for evaluated expressions
If the expression $<TARGET_PROPERTY:prop> appears in the content
of a target property, the target that prop is read from is
the 'head target' of the expression. In contexts such as evaluating
the content of a target property during generation, such
as INCLUDE_DIRECTORIES, the 'head target' is the one on which the
initial request was made.

If evaluating a generator expression which is not a target property
content, the target must be explicitly specified. Such contexts
include add_custom_command and file(GENERATE). The content might
then look like

 $<TARGET_PROPERTY:tgt,prop>

However, as there is no HeadTarget set, any generator expressions
evaluated as part of reading prop from tgt which do not specify
the tgt directly report an error.

Modify the logic of the TARGET_PROPERTY generator expression so
that in such contexts, the 'head target' is set to the appropriate
target which was first encountered.
2013-06-05 09:05:00 -04:00
Brad King 69cc67611a Merge topic 'test-INCLUDE_DIRECTORIES-genex-read'
07f9e15 GenexEval: Test evaluation of INCLUDE_DIRECTORIES target property.
2013-05-31 09:33:26 -04:00
Stephen Kelly 07f9e157b6 GenexEval: Test evaluation of INCLUDE_DIRECTORIES target property. 2013-05-30 16:05:17 +02:00
Stephen Kelly 32410140a7 Add $<LINK_LANGUAGE> generator expression
They can't be used when evaluating link libraries, but they can be
used for include directories and compile definitions. Later they can
be used for compile options.
2013-05-24 09:06:53 -04:00
Stephen Kelly a7ba4520c7 Add the JOIN generator expression.
This generator expression joins a list with a separator. The separator
may contain arbitrary content, such as commas, which is ordinarily a
delimiter in the generator expression syntax.
2013-05-16 19:36:31 +02:00
Stephen Kelly 5c9f5e313f Don't use LINKED where not needed. 2013-02-12 10:39:35 +01:00
Stephen Kelly e7b579bd01 Test workaround of bad interface include directories from depends. 2013-01-31 17:34:20 +01:00
Brad King db925e3532 Merge topic 'interface-includes-defines'
894f52f Handle INTERFACE properties transitively for includes and defines.
f5b1980 Populate the ExportedTargets member early in GenerateMainFile
c67b812 Make cycles in target properties ignored, not an error.
d0f950f Use mapped config properties to evaluate $<CONFIG>
26def17 Make all relevant targets available in the genex context.
0c657dc Add API to populate INTERFACE properties in exported targets.
e04f737 Add API to extract target names from a genex string.
b0c8f73 Add the TARGET_NAME generator expression.
77475fe Allow generator expressions to require literals.
b2f1700 GenEx: Add expressions to specify build- or install-only values
2013-01-07 14:20:13 -05:00
Stephen Kelly 119bf4bf7f Add test for custom command with a genex referring to a target.
This test failed before d8a59ea4 (Port cmGeneratorExpression to
cmTarget from cmGeneratorTarget, 2012-10-27), and passes after.
2013-01-07 14:03:51 -05:00
Stephen Kelly 894f52f32d Handle INTERFACE properties transitively for includes and defines.
Contextually, the behavior is as if the properties content from another
target is included in the string and then the result is evaluated.
2013-01-05 01:18:37 +01:00
Stephen Kelly e386992152 GexEx: Validate Target names and property names differently.
In the unit test, use the same IMPORTED_LOCATION trick that
the ExportImport test uses.
2012-10-22 14:05:48 -04:00
Stephen Kelly 145a4af8d3 GenEx: Test the use of generator expressions to generate lists.
We can't test this in the GeneratorExpression unit test because
the ';' chars are processed specically by the CMake function argument
parser.
2012-10-17 16:21:12 -04:00
Stephen Kelly 08cb4fa4c0 Process generator expressions in the INCLUDE_DIRECTORIES property.
This use of generator expressions, like all others to come which operate
on target properties, must initalize the dag checker.
2012-09-28 08:50:10 -04:00
Daniel R. Gomez cad69215fa Tests/IncludeDirectories: Files must end in a newline (#13314)
The HP compiler really really wants source files to end with a newline.
2012-06-18 16:16:55 -04:00
Stephen Kelly 9106b564ae Extract and use the INCLUDE_DIRECTORIES target properties.
Eliminate callers of cmMakefile::GetIncludeDirectories.

All callers of GetIncludeDirectories should go through the local generator
object.

Only the local generator calls cmTarget::GetIncludeDirectories directly.
2012-02-22 06:31:50 -05:00