summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomCommandCommand.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Ninja Multi-Config: Add support for DEPFILE option in add_custom_command()Kyle Edwards2020-02-071-1/+1
| | | | And give other generators a path forward to add support in the future.
* cmake: avoid getcwd in `CollapseFullPath`Tim Blechmann2020-01-141-1/+2
| | | | | | `CollapseFullPath` calls getcwd, which is a rather expensive system call. we can replace it with `GetHomeOutputDirectory()` to save us from the calling overhead
* cmAddCustomCommandCommand: remove unnecessary bracesBen Boeckel2019-12-181-2/+2
|
* cmMakefile: Delay custom command creationDaniel Eiband2019-11-241-1/+1
| | | | | | | | Move custom command creation to cmLocalGenerator and dispatch custom commands in cmMakefile to generate time. Generators add custom commands using the new methods provided by cmLocalGenerator. Issue: #12877
* cmMakefile: Move enumerations into new headerDaniel Eiband2019-09-261-5/+5
| | | | The enumerations will also be used in cmLocalGenerator.
* add_custom_command: Format files in error message in a single lineDaniel Eiband2019-09-231-2/+2
|
* add_custom_target: Add output checks for custom target byproductsDaniel Eiband2019-09-231-32/+4
| | | | | Use the output checks for byproducts of add_custom_command also for byproducts of add_custom_target.
* add_custom_command: Add tests for custom command output checksDaniel Eiband2019-09-231-2/+2
|
* Refactor: Use cmStrCat to construct error stringsAsit Dhal2019-09-181-8/+5
| | | | | Replace string construction using std::stringstream with cmStrCat and cmWrap.
* Merge topic 'prepare-deferred-custom-command-creation'Brad King2019-09-161-32/+8
|\ | | | | | | | | | | | | | | 5d28e361b7 add_custom_command: Move append functionality into class cmMakefile 4fb29850ad add_custom_command: Refactor setting implicit depends Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3810
| * add_custom_command: Move append functionality into class cmMakefileDaniel Eiband2019-09-131-9/+3
| |
| * add_custom_command: Refactor setting implicit dependsDaniel Eiband2019-09-121-23/+5
| | | | | | | | | | Implicit dependencies are now passed as argument to AddCustomCommandToOutput. This is necessary to be able to delay custom command creation.
* | add_custom_command: Delay slash conversion until after genex evaluationSebastian Lipponer2019-09-131-4/+3
|/ | | | | | Generator expressions may contain or produce backslashes. Fixes: #19553
* Source sweep: Use cmStrCat for string concatenationSebastian Holtermann2019-08-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is generated by a python script that uses regular expressions to search for string concatenation patterns of the kind ``` std::string str = <ARG0>; str += <ARG1>; str += <ARG2>; ... ``` and replaces them with a single `cmStrCat` call ``` std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...); ``` If any `<ARGX>` is itself a concatenated string of the kind ``` a + b + c + ...; ``` then `<ARGX>` is split into multiple arguments for the `cmStrCat` call. If there's a sequence of literals in the `<ARGX>`, then all literals in the sequence are concatenated and merged into a single literal argument for the `cmStrCat` call. Single character strings are converted to single char arguments for the `cmStrCat` call. `std::to_string(...)` wrappings are removed from `cmStrCat` arguments, because it supports numeric types as well as string types. `arg.substr(x)` arguments to `cmStrCat` are replaced with `cm::string_view(arg).substr(x)`
* clang-tidy: isolate declarations for readabilityRegina Pfeifer2019-08-201-2/+10
|
* cmA*Command: Turn into free functionsRegina Pfeifer2019-08-071-41/+43
| | | | Ref: #19499
* cmAddCustomCommand: Initialize static std::unordered_set on constructionSebastian Holtermann2019-06-041-24/+23
|
* Support job pools in custom commands and targetsRosen Matev2019-05-141-3/+16
| | | | | | | | | | Provide a way for custom commands and targets to set the pool variable of the ninja build statement. Setting `JOB_POOL` is not compatible with `USES_TERMINAL`, which implies the `console` pool. The option is silently ignored with other generators. Closes: #18483
* Factor out enum MessageType into dedicated headerBruno Manganelli2019-01-161-4/+4
| | | | Reduce the number of files relying on `cmake.h`.
* add_custom_{command,target}: Fix WORKING_DIRECTORY leading genexBrad King2018-11-031-6/+0
| | | | | | | | | | | Since commit v3.13.0-rc1~39^2 (add_custom_{command,target}: WORKING_DIRECTORY generator expressions, 2018-09-22) the `WORKING_DIRECTORY` option accepts generator expressions. Fix support for the case of a leading generator expression by deferring conversion to an absolute path until after evaluation of the generator expression. Fixes: #18543
* cmMakefile: return directories as const std::string&Vitaly Stakhovsky2018-08-271-1/+1
|
* Merge topic 'std-string-apis'Brad King2018-02-011-2/+2
|\ | | | | | | | | | | | | 653b8946 Reduce raw string pointers usage. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1729
| * Reduce raw string pointers usage.Pavel Solodovnikov2018-01-311-3/+3
| | | | | | | | | | | | | | | | | | | | * Change some functions to take `std::string` instead of `const char*` in the following classes: `cmMakeFile`, `cmake`, `cmCoreTryCompile`, `cmSystemTools`, `cmState`, `cmLocalGenerator` and a few others. * Greatly reduce using of `const char*` overloads for `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`. * Remove many redundant `c_str()` conversions throughout the code.
* | cmAddCustomCommandCommand: use std::string const& for FileIsFullPathBen Boeckel2018-01-311-1/+1
| |
* | cmAddCustomCommandCommand: store keywords in stringsBen Boeckel2018-01-311-49/+99
|/ | | | | | | Callgrind indicated that `strlen` was being called a lot of times here due to the string comparisons. Since keywords are "sparse" in `add_custom_command`, use a hash comparison to handle keywords and then use strings for comparison since they have a built-in length parameter.
* Reduce allocation of temporary values on heap.Pavel Solodovnikov2018-01-261-4/+3
| | | | | - Use `std::move` while inserting temporary results into vectors. - Change `push_back` to `emplace_back` where appropriate.
* Meta: modernize old-fashioned loops to range-based `for`.Pavel Solodovnikov2017-09-121-9/+6
| | | | | | Changes done via `clang-tidy` with some manual fine-tuning for the variable naming and `auto` type deduction where appropriate.
* Use C++11 nullptrDaniel Pfeifer2017-08-241-1/+1
|
* Access string npos without instancePavel Solodovnikov2017-06-011-1/+1
|
* add_custom_{command,target}: Add COMMAND_EXPAND_LISTS optionEd Branch2017-01-141-2/+7
| | | | | | This option allows lists generated by generator expressions to be expanded. Closes: #15935
* Include necessary headers in commandsDaniel Pfeifer2016-10-261-2/+10
|
* Simplify CMake per-source license noticesBrad King2016-09-271-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Make the add_custom_command output more predictableStephen Kelly2016-09-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* add_custom_command: Add DEPFILE option for NinjaKulla Christoph2016-08-301-3/+16
| | | | | | | | 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
* use CM_NULLPTRDaniel Pfeifer2016-06-281-1/+1
|
* Revise C++ coding style using clang-formatKitware Robot2016-05-161-238/+157
| | | | | | | | | | | | | 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.
* Remove `//------...` horizontal separator commentsBrad King2016-05-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Port to static cmPolicies API.Stephen Kelly2015-05-041-2/+1
|
* cmMakefile: Rename GetCurrent{Output,Binary}Directory.Stephen Kelly2015-04-201-2/+2
| | | | Match names used in CMake code.
* Port all cmOStringStream to std::ostringstream.Stephen Kelly2015-01-111-4/+4
| | | | All compilers hosting CMake support the std class.
* Add an option for explicit BYPRODUCTS of custom commands (#14963)Brad King2014-11-141-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add USES_TERMINAL option for custom commandsPeter Collingbourne2014-11-141-2/+12
| | | | | | 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.
* strings: Remove redundant calls to std::string::c_str()Nils Gladitz2014-10-151-1/+1
| | | | | Replacements were detected and performed by the clang tool remove-cstr-calls on a linux build.
* add_custom_command: Normalize OUTPUT and DEPENDS paths.Stephen Kelly2014-05-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove c_str calls when using stream APIs.Stephen Kelly2014-03-111-1/+1
| | | | | Use an ad-hoc clang tool for matching the calls which should be ported.
* Remove some c_str() calls.Stephen Kelly2014-03-111-11/+11
| | | | | | 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.
* add_custom_command: Disallow use of SOURCE signatures.Stephen Kelly2014-02-121-0/+30
| | | | Add CMP0050 to control this behavior.
* Normalize slashes of add_custom_(command|target) DEPENDS (#11973)Brad King2011-03-301-3/+9
| | | | | | | | | | | | | | | | 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.
* Handle relative WORKING_DIRECTORY in add_custom_(command|target)Brad King2011-01-261-0/+7
| | | | This also fixes handling of trailing slashes in the directory name.
* Normalize add_custom_command OUTPUT names (#10485)Brad King2010-12-151-0/+1
| | | | | | | | | | | | 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.