Commit Graph

162 Commits

Author SHA1 Message Date
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Daniel Pfeifer 7f6b8d3399 Simplify boolean expressions
Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
2016-06-02 08:24:04 -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 9cb263d772 cmComputeLinkInformation: Do not mark interface library as a path
The empty string we add as a link item for an INTERFACE_LIBRARY target
is not a path, so do not mark it as such.  The generators currently
tolerate it either way, but only by accident.
2016-05-13 14:39:53 -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 64b5520346 Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.

Find blocks of the form

    os <<
      "...\n"
      "...\n"
      ;

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'

Find blocks of the form

    os << "...\n"
       << "...\n"
       << "...\n";

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'

Surround such blocks with the pair

    /* clang-format off */
    ...
    /* clang-format on */

in order to protect them from update by clang-format.  Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
2016-05-06 14:25:55 -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
Stephen Kelly bde277e811 cmGeneratorTarget: Add GetLinkDirectories API. 2015-10-26 22:02:13 +01:00
Stephen Kelly c099e00fc0 Access policy status from cmGeneratorTarget at generate time. 2015-10-21 00:52:23 +02:00
Stephen Kelly 215cd21a02 cmGeneratorTarget: Provide direct access to the backtrace. 2015-10-21 00:37:03 +02:00
Stephen Kelly 83703bda7d cmGeneratorTarget: Copy IsExecutableWithExports from cmTarget. 2015-10-21 00:36:09 +02:00
Stephen Kelly b5f5de70c0 cmGeneratorTarget: Copy IsFrameworkOnApple from cmTarget.
Leave the cmTarget method behind for now to implement cmInstallCommand.
2015-10-19 20:27:41 +02:00
Stephen Kelly 8e20ea6ef2 cmGeneratorTarget: Move IsLinkable from cmTarget. 2015-10-19 20:27:40 +02:00
Stephen Kelly eac15298a8 cmState: Move TargetType enum from cmTarget.
Mostly automated:

 values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType")
 for i in "${values[@]}"; do     git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
2015-10-15 00:41:39 +02:00
Stephen Kelly 983c00f8f9 Generators: Use GetType from the cmGeneratorTarget. 2015-10-15 00:41:19 +02:00
Stephen Kelly d6b394edcb cmComputeLinkDepends: Port result API to cmGeneratorTarget. 2015-10-12 18:39:58 +02:00
Stephen Kelly 7c8236efa7 cmComputeLinkInformation: Port result API to cmGeneratorTarget. 2015-10-12 18:39:58 +02:00
Stephen Kelly c7645fca12 cmComputeLinkInformation: Port data interface to cmGeneratorTarget. 2015-10-12 18:39:58 +02:00
Stephen Kelly ce8894aaf0 cmComputeLinkInformation: Port some implementation to cmGeneratorTarget. 2015-10-12 18:39:58 +02:00
Brad King aad0e62060 Merge topic 'use-generator-target'
1c1c2a12 cmGeneratorTarget: Port ExpandLinkItems away from cmTarget.
c66084f5 cmGeneratorTarget: Port GetImportLinkInterface away from cmTarget.
83c29e39 cmGeneratorTarget: Port ComputeLinkImplementationLibraries away from cmTarget.
19882554 cmGeneratorTarget: Port handleSystemIncludesDep away from cmTarget.
c1f687b1 cmGeneratorTarget: Port GetLinkImplementationLibrariesInternal.
a6e1f05c cmGeneratorTarget: Port ComputeLinkInterface away from cmTarget.
654002fe cmGeneratorTarget: Port ComputeLinkInterfaceLibraries away from cmTarget.
922c8901 cmGeneratorTarget: Port GetLinkInterface away from cmTarget.
eaa5b9cb cmGeneratorTarget: Port cmTargetCollectLinkLanguages away from cmTarget.
f539da12 cmGeneratorTarget: Port GetLinkInterfaceLibraries away from cmTarget.
1c5d70f9 cmGeneratorTarget: Port processILibs away from cmTarget.
064c2488 cmComputeLinkDepends: Port some API to cmGeneratorTarget.
3e428fdc cmGeneratorTarget: Move IsImportedSharedLibWithoutSOName from cmTarget.
110fd2fb cmGeneratorTarget: Move GetOutputTargetType from cmTarget.
e7391699 cmGeneratorTarget: Move HasMacOSXRpathInstallNameDir from cmTarget.
c5718217 cmGeneratorTarget: Move HaveInstallTreeRPATH from cmTarget.
...
2015-10-12 10:26:20 -04:00
Brad King 762108f3ec Merge topic 'add-cmLocalGenerator-API'
223d0efe Remove some needless GetMakefile() calls.
a367416c cmLocalGenerator: Add current source directory accessor.
bbef3c2d cmLocalGenerator: Add current binary directory accessor.
12cb3bdc cmLocalGenerator: Add Home directory accessors.
72efa15d Eclipse: Port API to cmLocalGenerator.
f2a641d6 Kate: Remove unused variables.
10cf42f5 Kate: Port API to cmLocalGenerator.
e46ef270 export: Port internal method to cmGeneratorTarget.
53d3a1c9 cmMakefile: Remove unused GetProjectName calls.
4ab2750c cmLocalGenerator: Add GetProjectName method.
c8187f41 cmCPluginAPI: Inline code to get project name.
8c6e6dd3 cmMakefile: Inline initialization of project name.
27916f2c cmLocalGenerator: Add cmake instance accessor.
2015-10-12 10:26:15 -04:00
Stephen Kelly 064c248811 cmComputeLinkDepends: Port some API to cmGeneratorTarget. 2015-10-10 11:14:31 +02:00
Stephen Kelly 3e428fdcb4 cmGeneratorTarget: Move IsImportedSharedLibWithoutSOName from cmTarget. 2015-10-10 11:03:48 +02:00
Stephen Kelly e73916992c cmGeneratorTarget: Move HasMacOSXRpathInstallNameDir from cmTarget. 2015-10-10 11:03:48 +02:00
Stephen Kelly c5718217ad cmGeneratorTarget: Move HaveInstallTreeRPATH from cmTarget. 2015-10-09 01:04:38 +02:00
Stephen Kelly ee44be22cb cmGeneratorTarget: Use local GetProperty method. 2015-10-09 00:07:55 +02:00
Stephen Kelly 12cb3bdce4 cmLocalGenerator: Add Home directory accessors.
Reduce reasons for cmLocalGenerator to have a cmMakefile.
2015-10-09 00:00:19 +02:00
Brad King d833df1228 Merge topic 'add-link-search-static-properties-defaults'
9e21b01a Revert LINK_SEARCH_{START,END}_STATIC behavior change
2015-09-01 09:53:21 -04:00
Brad King 9e21b01a4d Revert LINK_SEARCH_{START,END}_STATIC behavior change
The changes to cmComputeLinkInformation.cxx in commit 675ef165 (Allow
LINK_SEARCH_{START,END}_STATIC props to have default values, 2015-08-07)
are unrelated to the feature added by that change and are incorrect.
They lead to cases of extra -Bdynamic flags.  Revert them.
2015-08-31 13:08:53 -04:00
Brad King 27e4b21dfa Merge topic 'use-generator-target'
c2b7336f cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget.
69329fff cmGeneratorTarget: Move GetLanguages from cmTarget.
0431f2c4 cmGeneratorTarget: Move ComputeLinkImplementationLanguages from cmTarget.
abe9505d cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget.
d4a24c0e cmGeneratorTarget: Move GetLinkImplementation from cmTarget.
83981cf5 cmTarget: Add GetLinkImplMap method.
771e79a2 cmLinkItem: Add cmOptionalLinkImplementation type.
3846ebcf cmLinkItem: Add cmLinkImplementation type.
a7f5d70d cmGeneratorTarget: Move compile defintions processing from cmTarget.
d051086c cmGeneratorTarget: Move compile features processing from cmTarget.
db4cb92b cmGeneratorTarget: Move compile options processing from cmTarget.
e6ccbf6f cmGeneratorTarget: Move include directory processing from cmTarget.
8bfb0c53 cmGeneratorTarget: Move link iface helpers from cmTarget.
2cb3e574 cmGeneratorTarget: Move GetImportLinkInterface from cmTarget.
6d3d099b cmGeneratorTarget: Move ComputeLinkInterfaceLibraries from cmTarget.
0db9d927 cmGeneratorTarget: Move GetLinkInterfaceLibraries from cmTarget.
...
2015-08-27 10:07:32 -04:00
Stephen Kelly abe9505df9 cmGeneratorTarget: Move HaveBuildTreeRPath from cmTarget. 2015-08-26 19:46:32 +02:00
Stephen Kelly 00f2298f07 Reduce uses of cmMakefile::GetGlobalGenerator.
Don't assume the cmMakefile has a global generator.
2015-08-25 23:06:33 +02:00
Brad King cb99eff642 Merge topic 'use-generator-target'
9b449e9c cmComputeLinkInformation: Lookup a target only if we have one
2015-08-17 10:24:42 -04:00
Chuck Atkins 675ef165f2 Allow LINK_SEARCH_{START,END}_STATIC props to have default values.
Use the CMAKE_LINK_SEARCH_START_STATIC and CMAKE_LINK_SEARCH_END_STATIC
variables to initialize the LINK_SEARCH_START_STATIC and
LINK_SEARCH_END_STATIC target properties respectively.
2015-08-13 10:34:44 -04:00
Brad King 9b449e9c5d cmComputeLinkInformation: Lookup a target only if we have one
The change in commit 27252b24 (cmComputeLinkInformation: Simplify
generator object access, 2015-08-02) broke the conditional use of a
target introduced in commit 41abdc17 (cmGeneratorTarget: Move GetSOName
from cmTarget, 2015-08-04).  Restore the conditional lookup.  Add a test
case that hacks platform information variables to trigger this code
everywhere.
2015-08-13 10:24:10 -04:00
Stephen Kelly 27252b2414 cmComputeLinkInformation: Simplify generator object access. 2015-08-07 00:51:40 +02:00
Stephen Kelly a309409ead cmOrderDirectories: Port to cmGeneratorTarget. 2015-08-05 18:20:50 +02:00
Stephen Kelly 4329a71c12 cmComputeLinkDepends: Port to cmGeneratorTarget. 2015-08-05 18:20:49 +02:00
Stephen Kelly c93230ac38 cmComputeLinkInformation: Port to cmGeneratorTarget. 2015-08-05 18:20:49 +02:00
Stephen Kelly f8076644ce cmGeneratorTarget: Move GetLinkClosure from cmTarget. 2015-08-05 18:20:49 +02:00
Stephen Kelly 7c809fa2a6 cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. 2015-08-05 18:20:48 +02:00
Stephen Kelly e27d737e27 cmGeneratorTarget: Move IsChrPathUsed from cmTarget. 2015-08-05 18:20:47 +02:00
Stephen Kelly 41abdc17df cmGeneratorTarget: Move GetSOName from cmTarget.. 2015-08-05 18:20:43 +02:00
Stephen Kelly ec38e4c84f Move GetFullPath to cmGeneratorTarget 2015-07-27 21:59:02 +02:00
Stephen Kelly 4d8b79ad7e cmComputeLinkInformation: Port to cmOutputConverter. 2015-06-06 09:15:56 +02:00
Brad King 2c5a1bff23 Merge topic 'refactor-cmPolicies'
013ada80 cmPolicies: Implement PolicyMap in terms of bitset.
be6664c2 cmPolicies: Implement abstraction for PolicyMap.
de211686 Port to static cmPolicies API.
13981f20 cmPolicies: Make all API static.
23e2bcc8 cmPolicies: Remove unused DefinePolicy method.
5641ba4f cmPolicies: Remove unused cmPolicy class.
3de54497 cmPolicies: Loop over all policies using enum constants.
387aff20 cmPolicies: Trivialize GetPolicyStatus method.
dbf680d6 cmPolicies: Use more-direct ID access.
8c204133 cmPolicies: Implement in terms of public API.
e3a8c029 cmPolicies: Make private method file-static.
cb765af0 cmPolicies: Implement short description access with XMacros.
5df267fa cmPolicies: Implement version check with XMacro.
2235cfeb cmPolicies: Implement id to version with XMacro.
05d84388 cmPolicies: Implement id to string conversion with XMacro.
6eaade8a cmPolicies: Introduce XMacro table for policy data.
...
2015-05-05 09:35:30 -04:00
Stephen Kelly de21168612 Port to static cmPolicies API. 2015-05-04 22:32:20 +02:00
Stephen Kelly a0836ed978 Port to cmMakefile::GetGlobalGenerator. 2015-05-03 11:42:00 +02:00
Brad King faede40b46 cmComputeLinkInformation: Reduce 'if' nesting in AddItem
Also add a comment explaining why interface libraries still get a link
item.
2015-04-21 14:03:02 -04:00
Stephen Kelly 5d056c0dd8 Port Global property interaction to cmState. 2015-04-15 11:43:50 -04:00