Commit Graph

358 Commits

Author SHA1 Message Date
Brad King c7a7c655f0 Makefile: Avoid link line object list lengths nearing system limits
Use response files for object file lists that approach the scale of the
system `ARG_MAX` limit.

Fixes #16206.
2016-07-20 15:09:42 -04:00
Brad King 34ba5c5348 Makefile: Factor out response file checks into common helper
Factor CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_{OBJECTS,LIBRARIES} lookup out
into a common helper.  Use a separate helper for each because more
specific logic may be added to each later.
2016-07-20 15:00:56 -04:00
Yury Zhuravlev 2005b96067 Makefile: Factor out WINDOWS_EXPORT_ALL_SYMBOLS helper
Factor the implementation out of cmMakefileLibraryTargetGenerator
into a helper method in cmMakefileTargetGenerator so it can be
re-used elsewhere later.
2016-07-11 09:40:42 -04:00
Brad King b5ec5b0901 Avoid using KWSys auto_ptr by adopting it ourselves
Replace use of cmsys::auto_ptr with a CM_AUTO_PTR macro that maps to
our own implementation adopted from the KWSys auto_ptr implementation.
Later we may be able to map CM_AUTO_PTR to std::auto_ptr on compilers
that do not warn about it.

Automate the client site conversions:

    git grep -l auto_ptr -- Source/ | grep -v Source/kwsys/ | xargs sed -i \
      's|cmsys::auto_ptr|CM_AUTO_PTR|;s|cmsys/auto_ptr.hxx|cm_auto_ptr.hxx|'
2016-06-29 09:47:58 -04:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Tobias Hunger 49f10f0d24 cmGeneratorTarget: Adopt Fortran module directory generation
Move code to create/get the fortran module directory from the
cmCommonTargetGenerator to cmGeneratorTarget.

Rename the ComputeFortranModuleDirectory method to
CreateFortranModuleDirectory as this method *creates* the directory if
it is missing.
2016-06-17 14:22:29 -04:00
Brad King 0392f72bef Refactor Makefile/Ninja tool working directory storage
Move cmCommonTargetGenerator::WorkingDirectory to cmLocalCommonGenerator
and add an access method.
2016-06-17 14:22:28 -04:00
Daniel Pfeifer c6220de276 Use the empty() method to check for emptyness.
Apply fix-its from clang-tidy's readability-container-size-empty
checker.
2016-06-02 21:35:50 +02:00
Brad King fb1f5d50af Merge topic 'remove-needless-copies'
27ead963 Remove unnecessary local copies.
618fb23f Pass arguments that are not modified as const&.
2016-05-27 09:08:21 -04:00
Daniel Pfeifer 1b2bb93302 Remove redundant c_str() calls.
Run clang-tidy's readability-redundant-string-cstr checker.
Ignore findings in kwsys.
2016-05-26 22:52:22 +02:00
Daniel Pfeifer 27ead96305 Remove unnecessary local copies.
Use clang-tidy's performance-unnecessary-copy-initialization checker.
After applying the fix-its (which turns the copies into const&), revise
the changes and see whether the copies can be removed entirely by using
the original instead.
2016-05-26 22:21:15 +02:00
Brad King 6052e4b3bf Merge topic 'improve-character-find-and-replace'
5784747d Improve string find: prefer character overloads.
5cec953e Use std::replace for replacing chars in strings.
2a1a2033 cmExtraEclipseCDT4Generator: use std::replace.
34bc6e1f cmCTestScriptHandler: don't call find repeatedly.
2016-05-25 09:34:29 -04:00
Daniel Pfeifer 25d1ef6424 Use enums defined in cmOutputConverter using their fully qualified name.
Mostly automated:

values=("RelativeRoot" "NONE" "FULL" "HOME" "START" "HOME_OUTPUT" "START_OUTPUT"
        "OutputFormat" "UNCHANGED" "MAKERULE" "SHELL" "WATCOMQUOTE" "RESPONSE"
        "FortranFormat" "FortranFormatNone" "FortranFormatFixed" "FortranFormatFree")
for i in "${values[@]}"; do git grep -l cmLocalGenerator::$i | xargs sed -i "s|cmLocalGenerator::$i|cmOutputConverter::$i|g"; done
2016-05-25 09:20:09 -04:00
Daniel Pfeifer 5784747d1b Improve string find: prefer character overloads.
Apply fix-its from clang-tidy's performance-faster-string-find checker.
Ignore findings in kwsys.
2016-05-24 23:22:24 +02: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 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
Daniel Pfeifer 5e62444cff Add options to run clang-tidy with the compiler
Create a <LANG>_CLANG_TIDY target property (initialized by a
CMAKE_<LANG>_CLANG_TIDY variable) to specify a clang-tidy command line
to be run along with the compiler.
2016-04-13 09:56:10 -04:00
Tim Grothe 247c168b98 Refactor `.def` file lookup
Return a `cmSourceFile const*` from GetModuleDefinitionFile so that
callers can get more information than just the path to the file.
2015-11-04 09:15:14 -05:00
Stephen Kelly 4bc65d76f1 Makefiles: Port to cmGeneratorTarget. 2015-10-24 09:19:53 +02:00
Stephen Kelly 3e8ef64273 cmLocalGenerator: Port some API to cmGeneratorTarget. 2015-10-17 17:30:38 +02:00
Stephen Kelly cfb2f7508a Use cmGeneratorTarget for property access. 2015-10-17 17:30:38 +02:00
Stephen Kelly b857f0d84b Use GetName from cmGeneratorTarget. 2015-10-17 17:30:37 +02:00
Brad King f13521317a Merge topic 'clean-up-cmTarget'
55474e61 cmState: Move GetTargetTypeName from cmTarget.
38df5c36 Remove now-obsolete casts.
4ee2b267 cmGeneratorTarget: Use enum for GetType.
eac15298 cmState: Move TargetType enum from cmTarget.
482b3811 cmTarget: Move link type enum out.
2ee1cb85 cmTarget: Move ImportInfoMap out of internal class.
a48bcabd cmTarget: Move backtrace member out of internal class.
6694d993 cmTarget: Remove unneeded constructors.
983c00f8 Generators: Use GetType from the cmGeneratorTarget.
2015-10-16 09:35:34 -04: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 7f5ec9f109 cmLocalGenerator: Port GetTargetDirectory to cmGeneratorTarget. 2015-10-15 00:33:12 +02:00
Stephen Kelly 06f56d3bf5 cmLocalUnixMakefileGenerator3: Port AppendCleanCommand to cmGeneratorTarget. 2015-10-15 00:23:53 +02:00
Stephen Kelly c8f8f16541 cmLocalUnixMakefileGenerator3: Port another API to cmGeneratorTarget. 2015-10-15 00:20:16 +02:00
Stephen Kelly 1583440509 cmGeneratorExpression: Port interface to cmGeneratorTarget. 2015-10-12 23:07:46 +02:00
Stephen Kelly 11165525ba cmGeneratorExpression: Port to cmLocalGenerator. 2015-10-12 23:07:46 +02:00
Stephen Kelly ce75c86ec3 cmGeneratorTarget: Move GetSupportDirectory from cmTarget. 2015-10-12 18:39:59 +02:00
Stephen Kelly 8d2e3e53b9 cmGeneratorTarget: Move HasImplibGNUtoMS from cmTarget. 2015-10-12 18:39:59 +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
Stephen Kelly a367416cec cmLocalGenerator: Add current source directory accessor. 2015-10-10 11:04:39 +02:00
Stephen Kelly bbef3c2da8 cmLocalGenerator: Add current binary directory accessor. 2015-10-10 11:04:39 +02:00
Stephen Kelly 50dc9b4440 cmGeneratorTarget: Move GetPDBDirectory from cmTarget. 2015-10-09 01:04:37 +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
Stephen Kelly 5d3776a7eb Access sources through cmGeneratorTarget. 2015-10-07 08:37:56 +02:00
Brad King e134e53b47 Add support for *.manifest source files with MSVC tools
Classify .manifest sources separately, add dependencies on them, and
pass them to the MS manifest tool to merge with linker-generated
manifest files.

Inspired-by: Gilles Khouzam <gillesk@microsoft.com>
2015-09-17 10:21:32 -04:00
Stephen Kelly 69329fff70 cmGeneratorTarget: Move GetLanguages from cmTarget. 2015-08-26 19:46:32 +02:00
Stephen Kelly ee26add4f4 cmGeneratorTarget: Move IsBundleOnApple 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 3df705681b cmGeneratorTarget: Move GetPDBName from cmTarget. 2015-08-05 18:20:46 +02:00
Stephen Kelly a45fed81e5 cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. 2015-08-05 18:20:46 +02:00
Stephen Kelly 803a7982b4 cmGeneratorTarget: Move GetLinkInformation from cmTarget 2015-08-05 18:20:44 +02:00
Brad King a8c3698526 Merge topic 'refactor-fortran-module-directory'
e90372a0 cmCommonTargetGenerator: Factor out Fortran module directory computation
70c21301 cmCommonTargetGenerator: Store working directory for relative paths
7371d8f3 cmCommonTargetGenerator: Return string from GetFortranModuleDirectory
613bc08a cmDependsFortran: Use string to store module directory
2015-07-30 09:56:16 -04:00
Brad King 7e27a42ebd Merge topic 'cmCommonTargetGenerator-GetLinkedTargetDirectories'
6d79eda7 cmCommonTargetGenerator: Adopt linked target directory computation
2015-07-30 09:56:14 -04:00
Brad King 70c21301b2 cmCommonTargetGenerator: Store working directory for relative paths
The Makefile generators run tools with the current working directory set
to the subdirectory of the build tree for the each target.  The Ninja
generator runs tools with the current working directory set to the top
of the build tree.  Tell cmCommonTargetGenerator where the working
directory will be so it can compute proper relative paths.
2015-07-29 13:20:03 -04:00