Commit Graph

59 Commits

Author SHA1 Message Date
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Stephen Kelly 92d76b50aa Make the add_custom_command output more predictable
I otherwise get:

   Expected stderr to match:

    expect-err> CMake Error at AppendNotOutput.cmake:1 \(add_custom_command\):
    expect-err>   add_custom_command given APPEND option with output.*
    expect-err>   which is not already a custom command output.
    expect-err> Call Stack \(most recent call first\):
    expect-err>   CMakeLists.txt:3 \(include\)

   Actual stderr:

    actual-err> CMake Error at AppendNotOutput.cmake:1 (add_custom_command):
    actual-err>   add_custom_command given APPEND option with output
    actual-err>   "/home/stephen/dev/src/cmake/with
    actual-err> space/Tests/RunCMake/add_custom_command/AppendNotOutput-build/out" which is
    actual-err>   not already a custom command output.
    actual-err> Call Stack (most recent call first):
    actual-err>   CMakeLists.txt:3 (include)

Using a specific line for paths is a style already used elsewhere for
the same reason, such as CMP0041 output.
2016-09-19 08:49:46 -04:00
Kulla Christoph 048d1adb4e add_custom_command: Add DEPFILE option for Ninja
Provide a way for custom commands to inform the ninja build tool about
their implicit dependencies.  For now simply make use of the option an
error on other generators.

Closes: #15479
2016-08-30 09:05:18 -04:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -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 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
Stephen Kelly de21168612 Port to static cmPolicies API. 2015-05-04 22:32:20 +02:00
Stephen Kelly 54d6a9187f cmMakefile: Rename GetCurrent{Output,Binary}Directory.
Match names used in CMake code.
2015-04-21 00:12:52 +02:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Brad King e15a7075b5 Add an option for explicit BYPRODUCTS of custom commands (#14963)
A common idiom in CMake-based build systems is to have custom commands
that generate files not listed explicitly as outputs so that these
files do not have to be newer than the inputs.  The file modification
times of such "byproducts" are updated only when their content changes.
Then other build rules can depend on the byproducts explicitly so that
their dependents rebuild when the content of the original byproducts
really does change.

This "undeclared byproduct" approach is necessary for Makefile, VS, and
Xcode build tools because if a byproduct were listed as an output of a
rule then the rule would always rerun when the input is newer than the
byproduct but the byproduct may never be updated.

Ninja solves this problem by offering a 'restat' feature to check
whether an output was really modified after running a rule and tracking
the fact that it is up to date separately from its timestamp.  However,
Ninja also stats all dependencies up front and will only restat files
that are listed as outputs of rules with the 'restat' option enabled.
Therefore an undeclared byproduct that does not exist at the start of
the build will be considered missing and the build will fail even if
other dependencies would cause the byproduct to be available before its
dependents build.

CMake works around this limitation by adding 'phony' build rules for
custom command dependencies in the build tree that do not have any
explicit specification of what produces them.  This is not optimal
because it prevents Ninja from reporting an error when an input to a
rule really is missing.  A better approach is to allow projects to
explicitly specify the byproducts of their custom commands so that no
phony rules are needed for them.  In order to work with the non-Ninja
generators, the byproducts must be known separately from the outputs.

Add a new "BYPRODUCTS" option to the add_custom_command and
add_custom_target commands to specify byproducts explicitly.  Teach the
Ninja generator to specify byproducts as outputs of the custom commands.
In the case of POST_BUILD, PRE_LINK, and PRE_BUILD events on targets
that link, the byproducts must be specified as outputs of the link rule
that runs the commands.  Activate 'restat' for such rules so that Ninja
knows it needs to check the byproducts, but not for link rules that have
no byproducts.
2014-11-14 16:16:00 -05:00
Peter Collingbourne fe5d6e8c0f Add USES_TERMINAL option for custom commands
Teach the add_custom_command and add_custom_target commands a new
USES_TERMINAL option.  Use it to tell the generator to give the command
direct access to the terminal if possible.
2014-11-14 11:55:09 -05:00
Nils Gladitz cc1139cc30 strings: Remove redundant calls to std::string::c_str()
Replacements were detected and performed by the clang tool
remove-cstr-calls on a linux build.
2014-10-15 14:54:05 +02:00
Stephen Kelly c4af46b444 add_custom_command: Normalize OUTPUT and DEPENDS paths.
While tracing dependencies of a target, cmTargetTraceDependencies
follows sources by full path to determine if the source is to be
produced by a custom command.  Commit 4959f341 (cmSourceFileLocation:
Collapse full path for directory comparisons., 2014-03-27) changed
the storage of target sources to be in the form of a normalized
path instead of an unnormalized path.

The path is followed by looking it up in a mapping via
cmMakefile::GetSourceFileWithOutput to acquire an appropriate
cmSourceFile.  The mapping is populated with the OUTPUT components
of add_custom_command invocations, however it is populated with
unnormalized paths.  This means that the tracing logic does not
find appropriate cmSourceFiles, and does not generate appropriate
build rules for the generated sources.

Normalize the paths in the OUTPUT components of add_custom_command
to resolve this.

The paths in the DEPENDS component of add_custom_command are also
not normalized, leading to the same problem again.  Normalize the
depends paths after generator evaluation and expansion.
2014-05-28 21:05:41 +02:00
Stephen Kelly af8a1643c1 Remove c_str calls when using stream APIs.
Use an ad-hoc clang tool for matching the calls which should be
ported.
2014-03-11 15:03:50 +01:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Stephen Kelly f2eee72fac add_custom_command: Disallow use of SOURCE signatures.
Add CMP0050 to control this behavior.
2014-02-12 11:19:27 -05:00
Brad King 128605054a Normalize slashes of add_custom_(command|target) DEPENDS (#11973)
All commands accepting file paths should normalize the slashes so that
the string-represented names can be compared reliably.  The commands
add_library and add_executable have done this for years.  We taught
add_custom_command to normalize its OUTPUT names in commit a75a0a14
(Normalize add_custom_command OUTPUT names, 2010-12-15).  We handled a
special case of the DEPENDS option in commit 7befc007 (Handle trailing
slashes on add_custom_command DEPENDS, 2011-01-26).

Teach both add_custom_command and add_custom_target to normalize slashes
of DEPENDS files up front.  This approach subsumes the above-mentioned
special case so remove the one line added for it but keep its test.
Extend the CustomCommand test to check that slash count mismatches
between custom command OUTPUT and DEPENDS can still be linked correctly.
2011-03-30 09:52:07 -04:00
Brad King 88548a45fb Handle relative WORKING_DIRECTORY in add_custom_(command|target)
This also fixes handling of trailing slashes in the directory name.
2011-01-26 18:02:02 -05:00
Brad King a75a0a1448 Normalize add_custom_command OUTPUT names (#10485)
Previously the OUTPUT arguments of add_custom_command were not
slash-normalized but those of add_library and add_executable were.
This caused the example

  add_custom_command(OUTPUT a//b.c ...)
  add_library(... a//b.c ...)

to fail at build time with "no rule to make a/b.c".  Fix this and modify
the CustomCommand test to try it.
2010-12-15 08:44:57 -05:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King bed3ac8741 ENH: Remove SKIP_RULE_DEPENDS option from add_custom_command()
- Option was recently added but never released.
  - Custom commands no longer depend on build.make so we do
    not need the option.
  - Rule hashes now take care of rebuilding when rules change
    so the dependency is not needed.
2008-06-02 16:45:07 -04:00
Brad King 600e5e274e ENH: Add SKIP_RULE_DEPENDS option for add_custom_command()
- Allows make rules to be created with no dependencies.
  - Such rules will not re-run even if the commands themselves change.
  - Useful to create rules that run only if the output is missing.
2008-05-14 11:38:47 -04:00
Brad King e9503a174e ENH: Make add_custom_command interpret relative OUTPUT locations with respect to the build tre instead of the source tree. This can greatly simplify user code since generating a file will not need to reference CMAKE_CURRENT_BINARY_DIR. The new behavior is what users expect 99% of the time. 2008-01-30 11:22:10 -05:00
Ken Martin 0e69d38004 ENH: add return and break support to cmake, also change basic command invocation signature to be able to return extra informaiton via the cmExecutionStatus class 2008-01-23 10:28:26 -05:00
Brad King d7a5d4c191 ENH: Added IMPLICIT_DEPENDS option to ADD_CUSTOM_COMMAND. It currently works only for Makefile generators. It allows a custom command to have implicit dependencies in the form of C or CXX sources. 2007-09-17 10:50:46 -04:00
Brad King 2dfa2ba888 ENH: Added APPEND option to ADD_CUSTOM_COMMAND to allow extra dependencies to be connected later. This is useful to create one rule and then have a macro add things to it later. This addresses bug#2151. 2006-10-04 15:24:26 -04:00
Brad King 9a1d4e92eb BUG: Fix/cleanup custom commands and custom targets. Make empty comment strings work. Fix ZERO_CHECK target always out of date for debugging. Fix Makefile driving of custom commands in a custom target. Fix dependencies on custom targets not in ALL in VS generators. 2006-09-28 16:40:35 -04:00
Brad King d01b6f1281 ENH: Added VERBATIM option to ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET commands. This option enables full escaping of custom command arguments on all platforms. See bug#3786. 2006-09-28 11:30:49 -04:00
Brad King d5719f22c1 ENH: Added support for multiple outputs generated by a single custom command. For Visual Studio generators the native tool provides support. For Xcode and Makefile generators a simple trick is used. The first output is considered primary and has the build rule attached. Other outputs simply depend on the first output with no build rule. During cmake_check_build_system CMake detects when a secondary output is missing and removes the primary output to make sure all outputs are regenerated. This approach always builds the custom command at the right time and only once even during parallel builds. 2006-04-11 11:06:19 -04:00
Andy Cedilnik ee1975570e ENH: Allow blocking of writing into the source tree 2006-03-22 14:40:36 -05:00
Ken Martin 3d96e52261 STYLE: some m_ to this-> cleanup 2006-03-15 11:02:08 -05:00
Andy Cedilnik 634343c3e8 STYLE: Fix some style issues 2006-03-10 13:06:26 -05:00
Bill Hoffman ccdca71332 ENH: fix broken tests 2006-02-08 15:37:54 -05:00
Bill Hoffman 347c5f4b46 ENH: add working directory support 2006-02-08 10:58:36 -05:00
Ken Martin fd05925bda ENH: fix for earlier fix on source with relative path 2005-08-08 13:28:12 -04:00
Brad King bb043289d0 BUG: Do not convert SOURCE argument from relative to full path. It breaks the old-style SOURCE==TARGET trick and the SOURCE argument is only present for old-style commands anyway. This addresses bug#2120. 2005-08-08 12:00:42 -04:00
Ken Martin 91730c6005 ENH: slightly modified version of Alex's relative path arguments for custom commands 2005-07-08 11:51:21 -04:00
Brad King 289429cd00 ENH: Added check for invalid characters in output name. 2005-03-22 08:36:40 -05:00
Brad King 39af9ee1e4 ENH: Updated implementation of custom commands. Multiple command lines are now supported effectively allowing entire scripts to be written. Also removed extra variable expansions and cleaned up passing of commands through to the generators. The command and individual arguments are now kept separate all the way until the generator writes them out. This cleans up alot of escaping issues. 2005-02-22 10:32:44 -05:00
Andy Cedilnik 4ef0f1414c ENH: Fix typo: Bug #100 - Spelling correction to an error message 2003-07-29 07:01:56 -04:00
Bill Hoffman aeab59d9e7 ENH: better error checking 2003-07-15 12:52:16 -04:00
Ken Martin ba68f771b3 yikes added new custom command support 2003-06-03 10:30:23 -04:00
Brad King 4888c088ae ENH: Moved ExpandListVariables out of individual commands. Argument evaluation rules are now very consistent. Double quotes can always be used to create exactly one argument, regardless of contents inside. 2002-12-11 18:13:33 -05:00
Andy Cedilnik 3893ee72d2 Add comment support, so that you can see in build process what the custom command does 2002-12-10 16:47:37 -05:00
Brad King 1f6a3c67b1 ENH: Added reference to Copyright.txt. Removed old reference to ITK copyright. Changed program name to CMake instead of Insight in source file header. Also removed tabs. 2002-10-23 18:03:27 -04:00
Ken Martin 4dec2a174a remove unused variables 2002-09-15 09:54:08 -04:00
Bill Hoffman 0a3d0d24fd ENH: add list expansion back 2002-05-22 13:20:54 -04:00
Bill Hoffman 0415b58573 ENH: backwards compatible for VTK 4.0, add cmake version requires 2002-04-17 16:16:06 -04:00
Sebastien Barre 9b8926925b ENH: use target as source if source is empty 2002-04-11 10:05:47 -04:00
Bill Hoffman 7d76de4403 make sure ; expansion is done in all commands 2002-03-29 14:20:32 -05:00