Commit Graph

259 Commits

Author SHA1 Message Date
Brad King 473634eb1c Merge topic 'expose-cache-properties'
63c0e92c cmState: Expose list of properties of values in the cache
6eee2463 cmCacheEntry: Retrieve all properties of cache entries
120899c6 cmPropertyList: Add a way to retrieve all properties
7066218e cmake: Kill cmake::CacheManager and its getter
2016-06-13 10:03:05 -04:00
Brad King 4e66ca1952 Merge topic 'fix-cmake-ISP-violation'
23f87e81 cmake: Remove force from IssueMessage API
54c65d5f cmake: Extract DisplayMessage API.
2016-06-13 09:54:27 -04:00
Stephen Kelly 23f87e8157 cmake: Remove force from IssueMessage API
The force parameter is ugly and makes the method harder to reason about
(issues the message ... but maybe it doesn't ... but then again you can
force it).  It is a violation of

 https://en.wikipedia.org/wiki/Interface_segregation_principle

and is the kind of thing described in a recent blog here:

 http://code.joejag.com/2016/anti-if-the-missing-patterns.html

 "Any time you see this you actually have two methods bundled into one.
  That boolean represents an opportunity to name a concept in your code."
2016-06-12 22:09:27 +02:00
Stephen Kelly 54c65d5fb2 cmake: Extract DisplayMessage API. 2016-06-12 22:08:47 +02:00
Stephen Kelly 0a4af0735f cmake: Issue message independent of cmMakefile definition
The makefile is only used when called by the cmMessageCommand, so inline
the use of it there.  It otherwise creates an undesirable dependency on
cmMakefile for issuing messages in the cmake instance, a violation of
the Interface Segregation Principle.

 https://en.wikipedia.org/wiki/Interface_segregation_principle

This also makes it more explicit that the variable definitions only
affect the message() command.  If an AUTHOR_WARNING is issued for any
other reason, it is not affected.  To affect that, it is necessary to
set the cache variable instead of the regular variable.

This is an unfortunate interface quirk, but one which can't be fixed
easily now.
2016-06-12 18:38:33 +02:00
Tobias Hunger 7066218e79 cmake: Kill cmake::CacheManager and its getter
This member variable is never initialized and has apparently moved
to cmState.
2016-06-10 09:27:59 -04:00
Daniel Pfeifer f9cc43ea37 cmake: remove unnused member Verbose 2016-06-08 23:08:33 +02:00
Stephen Kelly 6e65808516 cmake: Fix constness of methods 2016-06-08 23:08:29 +02:00
Stephen Kelly 87ffd76d1a cmake: Make internal method file static 2016-06-08 23:08: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 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 0f96ef00cb Remove unused cmake::IssueMessage overload
All callers now pass a full backtrace so we do not need the alternative
that takes a cmListFileContext directly.  Drop this overload to remove
the code duplication.
2016-04-18 09:21:19 -04:00
Michael Scott 28f2d750ed Add -Werror and -Wno-error command-line options
Expand the -W set of cmake options to include support for the -Werror
and -Wno-error format, which is used to control upgrading and
downgrading warning and error messages. Implement support for these new
formats for the dev and deprecated message types.

Add tests and updated documentation for new options.
2016-01-12 14:02:51 -05:00
Michael Scott 291275347b cmake: Deduplicate warning message control code
Remove the duplicate code in cmake::Configure to set the cache variables
for the warning message suppression.  Replace it with calls to the
dedicated methods to carry this out.
2015-12-10 09:28:31 -05:00
Michael Scott 67211011d9 cmake-gui: Add options to control warning messages
Create a new dialog window for the cmake-gui that provides controls for
setting the state of suppression of developer and deprecated warning
messages.  This replaces the previous single checkbox for setting the
state of suppression of developer warnings.

Added a note for the new functionality to the release notes.
2015-12-10 09:28:31 -05:00
Michael Scott aac633d5e5 Explicitly enable deprecated warnings by default.
Explicitly enable deprecated warnings by default, via the
cmake::GetSuppressDeprecatedWarnings method, which signals
suppression is turned off unless the CMake variables are set
as required.

Add tests and update the documentation for the new
functionality.
2015-12-01 10:22:51 -05:00
Michael Scott da688bcb3b Add -W options to control deprecated warning messages.
Add 'deprecated' warning options type, to allow setting
CMAKE_WARN_DEPRECATED via the -W '-Wdeprecated' and
'-Wno-deprecated' options.

Add tests for new options and updated documentation.
2015-12-01 10:21:57 -05:00
Michael Scott 07388f83b6 Refactor the -W options parser to be generic.
Refactor the -Wdev and -Wno-dev options parser to use a generic -W
parser that follows the GCC pattern, excluding support for
-Werror=TYPE and -Wno-error=TYPE formats for now.
2015-12-01 09:40:43 -05:00
Michael Scott 246b0bfbfd Explicitly enable author (dev) warnings by default.
Explicitly enable author warnings by default, via the
cmake::GetSuppressDevWarnings method, which signals suppression
is turned off unless the CMake variables are set as required.

Add test cases for author and deprecated messages displayed by
default.
2015-12-01 09:35:53 -05:00
Michael Scott deec3a3f06 Make message suppression more consistent.
Make the message suppression more consistent, by adding a check
for the message related CMake variables in cmake::IssueMessage,
which allows callers of IssueMessage other than the message
command to behave as expected. Also added a check for
CMAKE_SUPPRESS_DEVELOPER_WARNINGS in the message command to
mirror the deprecated message type behaviour.

Added a 'force' flag to the cmake::IssueMessage method, to
make the message suppression consistent, when setting the
message related CMake variables directly in a CMake file.

Expand message command tests to cover the AUTHOR_WARNING message
type as well.
2015-11-30 15:00:08 -05:00
Robert Dailey 2b958a2027 cmake-gui: Add option to specify generator toolset
The -T parameter to CMake may now be specified through cmake-gui via a
new text field in the first-time configure wizard (below the generator
chooser).

The generator factories specify whether or not they support toolsets.
This information is propagated to the Qt code and used to determine if
the selected generator should also display the optional Toolset widgets.
2015-11-17 10:03:10 -05:00
Stephen Kelly 780bff5279 cmake: Store hardcoded lists of sources and headers
Don't duplicate this in each cmMakefile.
2015-10-27 07:44:22 +01:00
Brad King 414cc18a9a Merge topic 'revert-cmake-W-options'
2e606306 Merge branch 'improve-variable-help-formatting' into revert-cmake-W-options
81739e92 Revert topic 'cmake-W-options' (#15747)
2015-09-25 16:16:17 -04:00
Brad King 81739e9215 Revert topic 'cmake-W-options' (#15747)
The changes in commit c96fe0b4 (cmake: Add -W options to control
deprecation warnings and errors, 2015-07-28) fail to account for
-Wdev warnings produced by places in CMake other than message().
This causes a regression in which -Wno-dev fails to suppress such
warnings.  Revert the feature until it can be revised accordingly.
2015-09-22 13:53:09 -04:00
Stephen Kelly d8a5714839 cmake: Remove unused cmPolicies member.
heaptrack showed a 1 byte allocation with the backtrace pointing
here, as is the case since commit v3.3.0-rc1~112^2~5 (cmPolicies:
Remove unused cmPolicy class., 2015-05-03)
2015-08-23 18:28:01 +02:00
Michael Scott c96fe0b40d cmake: Add -W options to control deprecation warnings and errors
Refactor the -Wdev and -Wno-dev to use a generic -W parser that follows
the GCC pattern.  Include support for setting CMAKE_ERROR_DEPRECATED and
CMAKE_WARN_DEPRECATED via the deprecated warning.  Add -Werror=dev and
-Wno-error=dev options so that dev warning options are in line with
deprecated warning options.  Use a new CMAKE_SUPPRESS_DEVELOPER_ERRORS
internal cache entry to store the above new dev options persistently.
Add tests for new options and updated cmake documentation and release
notes to list new options.
2015-07-29 09:20:10 -04:00
Ben Boeckel 594bafe527 cmake: add --trace-expand option
The --trace option is helpful, but sometimes, what you're looking for is
deep under many layers of function calls and figuring out what instance
of the function call you're looking at is tedious to determine (usually
involving patching and message()). Instead, add a --trace-expand option
to trace while expanding commands into what CMake actually sees.
2015-07-23 15:33:10 -04:00
Stephen Kelly 353e422b2a cmMakefile: Remove unused GetPolicies method. 2015-06-06 09:35:55 +02:00
Stephen Kelly 52919ac8ac cmMakefile: Make cmListFileBacktrace default constructible. 2015-06-03 01:03:59 +02:00
Stephen Kelly 01e1cd5c1f cmState: Move snapshot creation to the cmake instance.
Don't create a snapshot in Initialize(), but leave the creation
responsibility to the cmake instance instead.  Previously, the
cmState would Initialize() in its constructor, and the cmake instance
would re-Initialize() during Configure().  The end result was the
same and there would be one snapshot present.  However, cmLocalGenerator
also created a snapshot on construction, and that one was used, leaving
the first snapshot unused, and potential for off-by-one errors.

Fix that by making the cmLocalGenerator use the existing snapshot
if it is top-level.  Add a CurrentSnapshot to the cmake instance and
populated it while configuring a directory.  This will eventually
replace the 'current local generator' concept.  Fix the GetParent
implementation to be able to return the first snapshot.
2015-05-24 13:30:24 +02:00
Stephen Kelly 4fdad392b6 cmake: Remove redundant forward declaration.
The appropriate include is already here.
2015-05-24 12:56:09 +02:00
Stephen Kelly 8b4b9631f5 cmake: Add IssueMessage overload taking a single cmListFileContext.
Port appropriate clients to use it.
2015-05-22 01:21:35 +02:00
Stephen Kelly ca7cc2ebd0 cmake: Extract PrintMessagePreamble method. 2015-05-22 00:54:26 +02:00
Brad King b0ea367308 Help: Spell '-D' option consistently across documentation (#15575)
Always show the option with its argument separate in summary text.
State in the main documentation that the option and its argument can be
given together too.
2015-05-20 08:30:36 -04:00
Stephen Kelly ae6c8a9d68 cmState: Store the Source and Binary directories. 2015-04-28 07:50:57 +02:00
Stephen Kelly b23cf06f86 cmake: Remove redundant start directories.
They are maintained as containing the same content as the 'home'
directories, but they are never read from.

Fix some comments and help strings which confused the two by
name. They actually mean what is called CMAKE_SOURCE_DIR in
cmake code.
2015-04-21 00:12:51 +02:00
Stephen Kelly 9b5f80a83c Move global properties to cmState. 2015-04-15 11:43:50 -04:00
Stephen Kelly 0076b5d834 cmake: Remove the happy global property scope pattern.
Global properties are already global in scope, so remove the
overload for specifying it and port users of the API.

The call from cmMakefile::GetProperty can be simplified because
the scope is only used during chaining, and there is no further
chaining after processing global properties.
2015-04-15 11:43:50 -04:00
Stephen Kelly 24b7f31d3a cmake: Remove unused cmCommand methods. 2015-04-15 11:43:50 -04:00
Stephen Kelly 96f8c5f9a3 cmState: Move cmCommand-related methods from cmake class. 2015-04-13 21:12:14 +02:00
Stephen Kelly 1e738bcf9c cmake: Simplify RemoveUnscriptableCommands algorithm.
Remove obsolete RemoveCommand method.
2015-04-13 21:10:19 +02:00
Stephen Kelly b159bff732 Move property definition to cmState. 2015-04-13 20:13:13 +02:00
Brad King 62c5e6f1a1 Merge topic 'introduce-cmState'
f081c5bd cmState: Move CacheEntryType enum from cmCacheManager.
f71fdf0e cmMakefile: Remove unused CacheManager accessor.
ff7169a0 Port to cmState.
a6b1ad13 Introduce cmState class.
2015-04-13 11:45:02 -04:00
Stephen Kelly f081c5bddd cmState: Move CacheEntryType enum from cmCacheManager. 2015-04-13 11:44:16 -04:00
Stephen Kelly a6b1ad1309 Introduce cmState class.
At this point, it is an interface to the cache.  It will be extended
to be a universal interface for access to and manipulation of
configuration-time data (defintions, properties on targets,
directories, source files etc).

This will allow porting all command implementations away
from the cmMakefile and cmTarget classes, and result in something
more-purely related to configuration-time processing of cmake
commands.  That should serve at least the following goals:

 * Split the CMake implementation more definitively into three
   stages: Configuration, computation and generation, and be able to
   implement each optimally for memory access patterns etc.
 * Make better IDE integration possible by making more configuration
   data available.
 * Make it possiblte to use a smaller library than CMakeLib.a in
   cpack and ctest, resulting in smaller executables.
 * Make it possible to run the configure step multiple times in
   the same CMake run (#14539).

Manage its lifetime in the cmake class, and add a convenience accessor
to cmMakefile.
2015-04-13 11:44:14 -04:00
Brad King 92d6179893 Merge topic 'cmake-cleanups'
07d44d63 cmake: Remove confusing duplication.
ea819b29 cmMakefile: Remove unused method.
6ad86c7f cmMakefile: Remove bad comment.
fca2b542 cmMakefile: Internalize setting of CMakeInstance on Properties.
7bb4e3db cmMakefile: Out-of-line Home directory accessors.
6241253a cmake: Out-of-line Home and Start directory methods.
0ee3ccb3 cmake: Fix variable name bugs.
57dd094e Use vector, not list for cmCommand storage.
6deb43e6 Remove some files which do not need to be in BootstrapCommands.
ecdb1b3b Add some missing includes.
04b307b9 cmake: Simplify CommandExists method.
0f1f324b cmake: Rename oddly named variables.
275185ac cmake: Constify GetCommand method.
c57f086a cmake: Don't lower-case a string needlessly.
23368c9b cmake: Use make_pair instead of Foo::value_type.
14c70b8c cmake: out-of-line try compile state methods.
...
2015-04-13 11:38:20 -04:00
Stephen Kelly 6241253a4b cmake: Out-of-line Home and Start directory methods. 2015-04-12 23:10:44 +02:00
Stephen Kelly 0ee3ccb3b0 cmake: Fix variable name bugs. 2015-04-12 23:10:44 +02:00
Stephen Kelly 275185ac2b cmake: Constify GetCommand method. 2015-04-12 20:08:49 +02:00