Commit Graph

47 Commits

Author SHA1 Message Date
Daniel Pfeifer efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -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
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
Daniel Pfeifer 7f6b8d3399 Simplify boolean expressions
Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
2016-06-02 08:24:04 -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 8174e5cd94 cmCustomCommand: Remove special member functions.
The compiler generated ones are fine.  The existing implementations
here are incorrect as they omit some members.
2015-06-07 11:09:32 +02:00
Stephen Kelly 34e1d6db72 cmCustomCommand: Re-arrange data layout.
Size goes from 240 to 224 bytes.
2015-06-07 10:48:15 +02:00
Stephen Kelly 52919ac8ac cmMakefile: Make cmListFileBacktrace default constructible. 2015-06-03 01:03:59 +02:00
Stephen Kelly 238dd2fbab Use insert instead of a loop in some cases.
Limit this change to inserting into a vector from a vector.

A follow up change can use insert for inserting into a set.
2015-01-11 17:00:55 +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
Ben Boeckel 2a1b2d8486 backtrace: Convert to local paths in IssueMessage
This is the only place we care show the FilePath to the user, so defer
the expensive relative path calculation until here.
2014-06-05 12:44:19 -04:00
Ben Boeckel a08292059e genex: remove the need for backtraces
Rather than making dummy backtraces and passing them around, just make
backtraces optional.
2014-06-05 12:44:18 -04:00
Ben Boeckel d46c650d67 cmMakefile: return a backtrace
This allows backtraces to be fully controlled by the makefile rather
than externally (and makes changing how they are manipulated easier).
2014-06-05 12:44:04 -04:00
Brad King d45e7f3461 cmCustomCommand: Return std::string from GetWorkingDirectory 2014-03-12 10:44:00 -04:00
Stephen Kelly c6c0bd9d2f cmMakefile: Consify custom command API. 2014-01-22 15:16:40 +01:00
Brad King 17c841c42d add_custom_command: Manage backtrace memory correctly (#14299)
Add an assignment operator to cmCustomCommand to copy the Backtrace
member pointee and avoid multiple-free on destruction.

Reported-by: Vitezslav Cizek <vcizek@suse.cz>
2013-07-17 11:18:06 -04:00
Brad King bfb7288f81 Record backtrace in cmCustomCommand
This will be used to report custom command errors to the user with a
backtrace pointing at the add_custom_command or add_custom_target call.
2010-12-15 14:53:24 -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 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 09289aadb6 ENH: Removed "Used" mark from custom commands. It is no longer needed or checked by any generators. 2007-05-28 11:18:15 -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 16cafd5cdf COMP: Fix init order. 2006-09-27 16:20:47 -04:00
Brad King 4babd52d8d BUG: The copy constructor should copy the escape settings. 2006-09-27 15:26:03 -04:00
Brad King dd332a00cc ENH: Re-implemented command line argument shell quoting to support several platforms with one code base. 2006-09-27 13:43:46 -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
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 347c5f4b46 ENH: add working directory support 2006-02-08 10:58:36 -05:00
Bill Hoffman a91947039a ENH: for all custom commands that can not be given to a target, add them to all targets in the current makefile 2006-01-09 14:40:31 -05:00
Ken Martin 825a762a30 ENH: always write out all custom commands 2005-07-28 09:14:42 -04:00
Ken Martin b25dea9f11 ENH: add test to make sure custom commands are used 2005-06-21 09:34:47 -04: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
Bill Hoffman fc0a916eee ENH: allow duplicate commands with the same output to be reduced automatically to one command 2003-06-04 13:42:42 -04:00
Ken Martin 0b3b21fa63 warning fixes 2003-06-03 14:55:20 -04:00
Ken Martin ba68f771b3 yikes added new custom command support 2003-06-03 10:30:23 -04: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
Will Schroeder a6a43d5320 ENH:Updated copyright 2002-01-21 15:30:43 -05:00
Bill Hoffman cc5c1fa6f7 ENH: separate command from its arguments in the custom command. This allows the generator on windows to change the slashes for just the command 2001-09-04 16:07:54 -04:00
Will Schroeder 54cfe84f3f ENH:New copyright 2001-04-27 08:01:17 -04:00
Ken Martin 865ec96644 major changes to support multiple libraries and source lists 2001-04-11 14:59:02 -04:00