Commit Graph

50 Commits

Author SHA1 Message Date
Tobias Hunger 1d601c6cb9 server-mode: Introduce cmServerConnection
Use it to split pipe and stdin/out handling out of cmServer itself.

The server will shut down when it looses its connection to the client.
This has the nice property that a crashing client will cause the server
to terminate as the OS will close the connection on behave of the client.
2016-09-22 08:06:38 -04:00
Tobias Hunger 7df8a8f276 server-mode: Add --experimental flag
Allow for experimental cmProtocolVersions, which will only ever get
listed if the server was started with the (undocumented)
"--experimental" flag.

Mark current protocol version 1.0 as experimental.
2016-09-20 08:32:26 -04:00
Tobias Hunger b13d3e0d0b cmake-server: Bare-bones server implementation
Adds a bare-bones cmake-server implementation and makes it possible
to start that with "cmake -E server".

Communication happens via stdin/stdout for now.

Protocol is based on Json objects surrounded by magic strings
("[== CMake Server ==[" and "]== CMake Server ==]"), which simplifies
Json parsing significantly.

This patch also defines an interface used to implement different
versions of the protocol spoken by the server, but does not include
any protocol implementaiton.
2016-09-19 08:57:57 -04:00
Tobias Hunger 49ad7f9af8 cmake: Add `cmake -E capabilities` mode
Add `cmake -E capabilities` to report on generators, cmake version and
possibly other static capabilities of cmake.

Closes: #15462
2016-08-16 13:45:05 -04:00
Alex Turbov e63151ff54 cmake: Add an option to control what files needs to be traced
Even in relatively small projects using `--trace` (and `--trace-expand`)
may produce a lot of output.  When developing a custom module usually
one is interested in output of only a few particular modules.

Add a `--trace-source=<file>` option to enable tracing only a subset of
source files.  The final output would be only from requested modules,
ignoring anything else not matched to given filename(s).
2016-06-17 11:46:23 -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 ce82e0a53f Deprecate Visual Studio 7 .NET 2003 generator
Update documentation to mark the generator deprecated.  Add a warning at
the end of generation plus an option to turn off the warning.
2016-04-28 10:09:20 -04:00
Brad King 6a501b6519 Tests: Drop test for VS 7.0 generator deprecation warnings
We removed this generator but forgot to remove this now-unused test
case.
2016-04-28 10:04:09 -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
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
Sebastian Schuberth 497cad7c88 cmake: Teach --build to reject multiple --target options
Previously we did not clearly document that `--target` is only supported
to be specified once.  Even worse, specifying it multiple times would
silently ignore any previously specified targets and only build the last
target.

Update the documentation to specify this.  Update the implementation to
reject multiple `--target` options to prevent user errors.
2016-02-05 11:48:16 -05:00
Brad King 1787269ef3 cmake: Fix `-E time` argument passing to child
Since this command was introduced in 2002 it has incorrectly constructed
the child process command line by concatenating arguments separated by
spaces with no quoting.  Fix this by passing the command argument vector
directly to RunSingleCommand without an intermediate quoting and
re-parsing step.

Reported-by: Andrey Pokrovskiy <wonder.mice@gmail.com>
2016-01-20 08:55:23 -05:00
Ashley Whetter 77cd74a3ea Print line number of cache parse errors (#11109)
Track the line number while parsing `CMakeCache.txt` files and include
it in a parse failure error message.
2016-01-19 10:19:42 -05: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
Bartosz Kosiorek 7984ac5e58 cmake: Teach -E make_directory to support multiple input directories 2015-12-10 09:07:38 -05:00
Bartosz Kosiorek bc35087da3 cmake: Teach -E copy_directory to support multiple input directories 2015-12-07 10:51:27 -05:00
Bartosz Kosiorek 384ae5514e cmake: Teach -E copy[_if_different] to support multiple files (#15703)
If multiple input files are provided then the destination must be a
directory.  If only one input file is provided then destination may be
either a file or directory.
2015-12-04 10:26:34 -05:00
Bartosz Kosiorek 0be5020bf8 cmake: Improve '-E' help message formatting 2015-12-04 10:12:02 -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 e8974b62d7 Modify dev warning options to affect deprecated warnings.
Change the '-Wdev' and '-Wno-dev' options to also enable and
suppress the deprecated warnings output, via the
'CMAKE_WARN_DEPRECATED' CMake variable, by default. This
action does not happen if the user specifies a deprecated
warning message option.

Add tests and update the documentation for the new
functionality.
2015-12-01 10:22:45 -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 aa427a4239 Tests: Revise message in RunCMake.CommandLine -Wdev case
Use more prose-like capitalization.
2015-11-30 15:00:08 -05:00
Tamas Kenez 8bb908b108 Document and test CMAKE_[CURRENT_](BINARY|SOURCE)_DIR in script mode 2015-10-06 09:34:28 -04:00
Michael Scott bc3e1e4b55 Tests: Add case for -Wdev and -Wno-dev with non-message() warnings (#15747) 2015-09-25 16:21: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
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
Brad King 90ad087ab9 cmake: Fix --build <relative-dir> for VS generators (#15609)
The VS >= 10 generators need to parse the .sln file from the build
directory to locate targets in subdirectories.  This occurs after we
change the working directory to the build tree.  If a relative directory
other than "." was given then we would change to it and also refer to
the .sln file location with it.  Fix this by converting the build tree
to a full path always.  This will also give a more informative error
message when the directory does not exist.
2015-06-11 16:04:21 -04:00
Brad King 7195ec92b2 Tests: Extend RunCMake.CommandLine to cover --build with no arg 2015-06-11 15:58:52 -04:00
Bill Hoffman 67fa3da9e8 cmake: Add internal -E mode to run include-what-you-use with the compiler
Add an internal "cmake -E __run_iwyu" mode to wrap the compiler call.
Run a given include-what-you-use command line with the compiler options
and report a warning if it finds anything.  Then run the real compiler.

Co-Author: Brad King <brad.king@kitware.com>
2015-05-19 13:16:29 -04:00
Brad King 7b8e7c4ac3 Deprecate Visual Studio 7 generator (.NET 2002)
Update documentation to mark the generator deprecated.  Add a warning at
the end of generation plus an option to turn off the warning.
2015-04-15 09:21:24 -04:00
Brad King 85c2626bab Deprecate Visual Studio 6 generator
Update documentation to mark the generator deprecated.  Add a warning at
the end of generation plus an option to turn off the warning.
2015-04-15 09:08:57 -04:00
Gerald Combs 588dcb33b7 cmake: Provide guidance when an invalid -G option is given
Print a list of generators if no generator or an invalid one is
supplied.

Signed-off-by: Gerald Combs <gerald@wireshark.org>
2015-04-10 15:14:34 -04:00
Brad King 4e039a9a98 Tests: Move more command line tests into RunCMake.CommandLine
Port most CMakeTestBadCommandLines test cases to RunCMake.CommandLine
and drop the former test.  Add validation of expected results, which was
not done by the old test.
2015-04-10 14:56:41 -04:00
Nils Gladitz 6c4781baa9 Tests: Consolidate, refactor and extend -E tar tests 2015-04-10 08:32:32 -04:00
Nils Gladitz d2cc580704 cmake: Teach "-E tar" command a "--format=" option
Allows specifying a libarchive defined archive format currently restricted to
7zip, gnutar, pax, paxr and zip.

The default is "paxr" (pax restricted).
2015-04-10 08:32:31 -04:00
Brad King af92482712 Makefile: Tolerate a BOM while scanning source dependencies (#15493)
Otherwise an #include directive on the first line of a source file is
ignored if the file contains a Byte-Order-Mark.

Suggested-by: Aleksey Konovalov <konovalov.aleks@gmail.com>
2015-04-03 13:04:57 -04:00
Brad King d1082448a8 Tests: Extend RunCMake.CommandLine to cover 'cmake --build' for 'ninja -v' 2015-02-26 10:21:09 -05:00
Brad King 44fd71decb cmake: Teach "-E tar" command a "--files-from=" option
Read file names from the lines of a specified file.  Reject input lines
starting in '-' to leave room for option parsing to be added later.  Add
just '--add-file=' now to allow files starting in '-' to be specified.
2015-01-26 13:28:31 -05:00
Brad King 3a60c899fc cmake: Teach "-E tar" command a "--mtime=" option
Add an option to set the mtime of entries in a tarball so that one can
create a tarball with a consistent content hash (e.g. MD5) for a given
set of files regardless of their current timestamps on disk.  This will
be useful for submission of tarballs to CDash, which tracks content
hashes to avoid duplication.

Inspired-by: Bill Hoffman <bill.hoffman@kitware.com>
2015-01-19 14:16:19 -05:00
Stephen Kelly 73ae888506 RunCMake: Expect empty output by default.
Expect tests to specify stderr content if it is present.

Fix the CMP0019 test, which has only been testing the WARN status
until now.  Specify in the CommandLine and FPHSA tests that content
is at least one character.

Set policies in the Language and CheckModules tests, which have empty
test output, modulo unrelated policies on some platforms.
2014-12-31 16:34:34 +01:00
Ben Boeckel aee7e4a03b cmCacheManager: parse -D flags more strictly
In the case of:

    -DCACHE_VARS=-DEXTERNAL_PROJECT_CMAKE_ARG:BOOL=TRUE

the variable is parsed out as:

    CACHE_VARS=-DEXTERNAL_PROJECT_CMAKE_ARG

because the parser allows '=' in the variable name. Disallow such a name
on the command line.
2014-10-20 12:17:19 -04:00
Ben Boeckel 368e8de4cd Tests: test -D parsing on the command line 2014-10-20 12:17:03 -04:00
Brad King 7abd574798 cmake: Add '-E env' command-line tool
Extend the cmake command-line interface to support

 cmake -E env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...

This will be useful to run processes with modified environments
without using a shell or a full "cmake -P" script to wrap it.

Extend the RunCMake.CommandLine test to cover success and failure cases.

Inspired-by: Jonathan Bohren <jbo@jhu.edu>
2014-06-23 16:47:49 -04:00
Brad King b1c113d9a7 cmake: Do not open directories as scripts (#14966)
Check if a file path is a directory before opening it.  Extend the
RunCMake.CommandLine test with a case running "cmake -P" on a directory.
2014-06-09 16:21:11 -04:00
Brad King 44e2923f33 cmake: Fix --build crash on bad CMAKE_GENERATOR in cache
If we fail to create the generator named by CMAKE_GENERATOR, exit
with an error message instead of crashing.  While at it, fix the
wording of the error message when CMAKE_GENERATOR is not set.

Extend the RunCMake.CommandLine test with cases covering the
"cmake --build" option when the named directory does not provide
a CMakeCache.txt with a valid CMAKE_GENERATOR.
2014-06-03 11:52:19 -04:00
Brad King 94389f6388 cmake: Add '-E sleep' command
Add a cmake command-line interface to provide a cross-platform 'sleep'.
2014-01-21 13:50:49 -05:00
Brad King e0228e2b04 cmake: Improve '-E create_symlink' edge case handling (#14713)
The logic added by commit ffc0b5e4 (Overwrite the symlink if it already
exists, 2007-02-15) does not recognize and remove existing broken links
before replacing them.  Improve the logic to remove any existing
destination file or link (but not directory).  On failure, report an
error message explaining why the existing path could not be removed or
the new one could not be created.

Add a RunCMake.CommandLine test to cover 'cmake -E' cases.  Start with
test cases covering 'cmake -E create_symlink' behavior on UNIX platforms.
2014-01-20 14:02:21 -05:00