Commit Graph

699 Commits

Author SHA1 Message Date
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Daniel Pfeifer 191fc3a0f3 cmOutputConverter: remove unused 'local' argument 2016-06-20 23:03:28 +02:00
Tobias Hunger 3c488ce899 cmLocalGenerator: Adopt target compile flag generation
Factor the flag generation out of cmCommonTargetGenerator::GetFlags
into a new cmLocalGenerator::GetTargetCompileFlags method.
This will allow it to be used without a target generator available.
2016-06-17 14:49:38 -04:00
Brad King 5467e7945d cmLocalGenerator: Add method to get Fortran-specific compiler flags
Add a cmLocalGenerator::GetTargetFortranFlags virtual method to get
generator-specific generation of Fortran-specific flags.  Implement it
in cmLocalCommonGenerator by moving the implementation from
cmCommonTargetGenerator::AddFortranFlags.  This will allow it to be used
without having a target generator available.

Inspired-by: Tobias Hunger <tobias.hunger@qt.io>
2016-06-17 14:49:29 -04:00
Brad King 18e00ac7b9 Merge topic 'avoid-cmMakefile-IssueMessage-after-configure'
ea5324cd cmMakefile: Port messages for compile features to cmake
df8c3130 cmGlobalGenerator: Don't use cmMakefile::IssueMessage after configure
946d1e50 cmMakefile: Avoid IssueMessage after configure is finished
096c7754 cmLocalGenerator: Store Backtrace for the directory
2016-06-13 09:54:24 -04:00
Stephen Kelly 096c7754b3 cmLocalGenerator: Store Backtrace for the directory
Don't rely on cmMakefile to provide that.  Use it to issue messages.
2016-06-12 19:01:45 +02:00
Tobias Hunger f62ed322dc cmLocalGenerator: Add GetTargetDefines to get all defines for a target 2016-06-10 09:24:49 -04:00
Brad King 853b1bb4ba cmLocalGenerator: Constify AppendDefines and AddCompileDefinitions 2016-06-10 09:24:11 -04:00
Tobias Hunger d9613b962e cmLocalGenerator: Move GetFrameworkFlags implementation to private helper 2016-06-09 10:41:42 -04:00
Tobias Hunger 70d3bf8580 cmLocalGenerator: Adopt GetFrameworkFlags method
Move it from cmCommonTargetGenerator.
2016-06-09 10:39:57 -04:00
Tobias Hunger b0d3e693f1 cmLocalGenerator: Pass configuration to GetTargetFlags
Move the configuration lookup to call sites.  This will allow
multi-configuration callers to use the method.
2016-06-08 16:18:31 -04:00
Brad King 0c7951a939 cmLocalGenerator: Consolidate conditions in AddArchitectureFlags
Make room for possible future non-Apple architecture flags.
2016-06-02 09:47:32 -04: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
Daniel Pfeifer 5cec953e6a Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and
`with` are string literals with a size of one.

Automate with:

git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
2016-05-24 23:22:20 +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
Geoff Viola 5e4287131b GHS: Shorten long object paths with duplicate source names
Detect when the resulting object path is too long and compute an
alternative name using a hash.
2016-05-06 08:21:05 -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 da07c506b9 cmLocalGenerator: Simplify IssueMessage implementation
This method was added by commit v3.4.0-rc1~424^2~6 (cmLocalGenerator:
Add IssueMessage method, 2015-06-13) in order to reduce callers'
dependency on cmMakefile.  Currently the implementation of
cmLocalGenerator::IssueMessage is just a copy of the post-configure code
path in cmMakefile::IssueMessage.  De-duplicate the implementation by
simply calling the cmMakefile copy for now.  This will simplify upcoming
refactoring of backtraces.  The dependency on cmMakefile can be removed
by future work once that is done.
2016-04-15 10:13:08 -04:00
Brad King cc7aed77a8 cmLocalGenerator: Use own IssueMessage method 2016-04-15 08:34:05 -04:00
Brad King adea45e15a Merge topic 'fix-target-alias-in-subdir'
0e44f489 Rename local target lookup methods to clarify purpose
bc30f8b5 Fix lookup of an ALIAS target outside aliased target's directory (#16044)
2016-04-05 09:37:59 -04:00
Brad King 0e44f4894f Rename local target lookup methods to clarify purpose
Rename methods:

* `cmMakefile::Find{ => LocalNonAlias}Target`
* `cmLocalGenerator::Find{ => LocalNonAlias}GeneratorTarget`

These names clarify that they are for directory-local target names
and do not consider alias targets.
2016-04-01 15:44:16 -04:00
Brad King bc30f8b5e6 Fix lookup of an ALIAS target outside aliased target's directory (#16044)
Refactoring in commit v3.5.0-rc1~272^2~11 (cmTarget: Implement ALIAS in
terms of name mapping, 2015-10-25) accidentally introduced logic that
assumes ALIAS targets always reference targets in their own directory.
Fix this and add a test case.

The configure-step fix is that `cmMakefile::FindTarget` should not consider
aliases.  The purpose of this method is just to look up targets local to
a directory.  Since ALIAS and normal targets share a namespace we know a
locally defined target will never collide with an ALIAS target anyway.
The method has 3 call sites, and this change is safe for all of them:

* `cmInstallCommand::HandleTargetsMode`: Rejects aliases before the call.
* `cmFLTKWrapUICommand::FinalPass`: Should never have considered aliases.
* `cmMakefile::FindTargetToUse`: Falls back to a global lookup anyway.

The generate-step fix is that `cmLocalGenerator::FindGeneratorTarget`
should not consider aliases.  This method is the generate-step
equivalent to the above.  The method has 2 call sites, and this change
is safe for both of them:

* `cmInstallTargetGenerator::Compute`: Never uses an alias target name.
* `cmLocalGenerator::FindGeneratorTargetToUse`: Falls back to global lookup.

Reported-by: Matteo Settenvini <matteo@member.fsf.org>
2016-04-01 15:44:16 -04:00
Brad King b42866a34a Drop Visual Studio 6 generator
This generator has been deprecated since CMake 3.3.  Remove it.
Update documentation, modules, and tests to drop content specific
to this generator.
2016-03-09 09:42:18 -05:00
Brad King a887c7f1fd Merge topic 'fix-target-lookup-performance-regression'
9b7d5871 Improve internal generator target structure lookup
6cbf6a51 Fix internal target lookup performance regression
2016-02-09 10:10:23 -05:00
Brad King 9b7d5871b8 Improve internal generator target structure lookup
In commit v3.5.0-rc1~272^2~6 (cmGlobalGenerator: Add FindGeneratorTarget
API, 2015-10-25) a lookup was implemented via linear search.  Replace it
with an efficient data structure.

Suggested-by: Stephen Kelly <steveire@gmail.com>
2016-02-08 13:08:11 -05:00
Nick Lewis 18ce97c4a2 install: Add EXCLUDE_FROM_ALL option (#14921)
Let us take an example of a project that has some tests in a component
that need to be installed into a dedicated test package.  The user
expectation is that the result could be achieved by typing the
following:

    make
    make tests
    make install
    DESTDIR=/testpkgs make install-tests

However this results in test components in the default installation as
well as the testpkg.

Add an EXCLUDE_FROM_ALL option to the install() command to tell it that
the installation rule should not be included unless its component is
explicitly specified for installation.
2016-02-04 09:16:56 -05:00
Brad King 036b6ef7c4 Port CMake from cmIML to KWIML
KWIML no longer uses a configured prefix.
2015-12-18 10:02:07 -05:00
Brad King 9342a4c203 Merge branch 'reduce-cmState-accumulation' into reduce-cmState-accumulation-for-master 2015-11-25 12:33:06 -05:00
Brad King 0fa7f143a0 cmLocalGenerator: Use ScopePushPop RAII class to manage local variable scopes 2015-11-24 19:38:34 -05:00
Stephen Kelly 79c3a2a8f7 cmGlobalGenerator: Remove map from cmTarget to cmGeneratorTarget
The configure-time and generate-time types should be completely
independent.

Add ownership of cmGeneratorTarget instances to the cmLocalGenerator.
2015-10-27 07:44:26 +01:00
Stephen Kelly c389f8bb07 cmLocalGenerator: Port Find method away from GetGeneratorTarget
Mirror the cmMakefile::FindTarget method.
2015-10-27 07:44:26 +01:00
Stephen Kelly 9b244cc0ec cmLocalGenerator: Store imported targets in a separate container. 2015-10-27 07:44:24 +01:00
Stephen Kelly def6da616b cmLocalGenerator: Port FindGeneratorTarget away from GetGeneratorTarget 2015-10-27 07:44:24 +01:00
Stephen Kelly 3e3c754b8c cmLocalGenerator: Port internals to cmGeneratorTarget 2015-10-27 07:44:22 +01:00
Stephen Kelly 00b8c0a8d4 cmLocalGenerator: Add IsRootMakefile API 2015-10-27 07:44:21 +01:00
Stephen Kelly 7d409f500e cmLocalGenerator: Add GetPolicyStatus API 2015-10-27 07:44:21 +01:00
Stephen Kelly 4c41e74da5 Use cmLocalGenerator at generate-time. 2015-10-24 09:19:53 +02:00
Stephen Kelly 67b2f4312c Port to GetGeneratorTargets. 2015-10-24 09:19:53 +02:00
Stephen Kelly a6b7eb5bc8 cmInstallTargetGenerator: Get a cmGeneratorTarget directly.
Extend the cmGeneratorTarget API to make this possible.
2015-10-24 09:19:52 +02:00
Stephen Kelly a8c0fbcc19 cmLocalGenerator: Store a vector of generator targets.
Not a map from cmTarget to cmGeneratorTarget.
2015-10-21 23:21:01 +02:00
Brad King 9206120e30 Merge topic 'use-generator-target'
c099e00f Access policy status from cmGeneratorTarget at generate time.
d74bca5a cmGeneratorTarget: Copy the policy map from the cmTarget.
c6e86955 cmTarget: Remove unused NameResolvesToFramework.
18046bd5 cmCommonTargetGenerator: Use NameResolvesToFramework without cmTarget.
91411641 Move ComputeLinkType out of cmTarget.
6d94078e cmGeneratorTarget: Move IsDLLPlatform from cmTarget.
3ebc6285 cmGeneratorTarget: Move HaveWellDefinedOutputFiles from cmTarget.
311018e5 cmGeneratorTarget: Move GetExportMacro from cmTarget.
215cd21a cmGeneratorTarget: Provide direct access to the backtrace.
1df8bd3a cmGlobalGenerator: Port IsRootOnlyTarget to cmGeneratorTarget.
83703bda cmGeneratorTarget: Copy IsExecutableWithExports from cmTarget.
2015-10-21 09:17:01 -04: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 04b6bb1676 cmLocalGenerator: Simplify semantic of adding generator targets.
Don't store on the global generator as a side effect.  Update clients to adapt.
2015-10-20 23:58:49 +02:00