Commit Graph

706 Commits

Author SHA1 Message Date
Brad King
94139ac58e Merge topic 'export-repeat'
8affe9aa33 export: Fix use-after-free on multiple calls overwriting same FILE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4494
2020-03-20 06:17:00 -04:00
Brad King
8affe9aa33 export: Fix use-after-free on multiple calls overwriting same FILE
CMake 3.16 and below allow multiple `export()` calls with the same output
file even without using `APPEND`.  The implementation worked by accident
by leaking memory.  Refactoring in commit 5444a8095d (cmGlobalGenerator:
modernize memrory managemenbt, 2019-12-29, v3.17.0-rc1~239^2) cleaned up
that memory leak and converted it to a use-after-free instead.

The problem is caused by using the `cmGlobalGenerator::BuildExportSets`
map to own `cmExportBuildFileGenerator` instances.  It can own only
one instance per output FILE name at a time, so repeating use of the
same file now frees the old `cmExportBuildFileGenerator` instance
and leaves the pointer in the `cmMakefile::ExportBuildFileGenerators`
vector dangling.  Move ownership of the instances into `cmMakefile`'s
vector since its entries are not replaced on a repeat output FILE.

In future work we should introduce a policy to error out on this case.
For now simply fix the use-after-free to restore CMake <= 3.16 behavior.

Fixes: #20469
2020-03-19 06:41:39 -04:00
Vitaly Stakhovsky
36a5b3d1d1 cmMakefile::AddCacheDefinition: Add overload that accepts std::string value 2020-03-11 09:40:43 -04:00
Cristian Adam
598b676b5e cmake_command: Add command to EVAL a CMake script as a string 2020-03-03 08:42:13 -05:00
Vitaly Stakhovsky
bbc07e4561 Source: use std::string in place of const char* 2020-01-29 14:31:01 -05:00
Brad King
228dc92b09 Merge topic 'mf-typo'
7b6af980eb cmMakefile: Fix spelling typo in comment

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4292
2020-01-28 11:40:02 -05:00
Masashi Fujita
7b6af980eb cmMakefile: Fix spelling typo in comment 2020-01-28 10:54:15 -05:00
Vitaly Stakhovsky
1398517f31 AppendProperty: convert value param to std::string 2020-01-25 10:37:00 -05:00
Marc Chevrier
f466cea3c9 cmMakefile: modernize memory management 2020-01-14 11:03:07 +01:00
Robert Maynard
a7ea20649d find_*: Add debug logging infrastructure
Enable debug messages a new `--find-debug` command-line option or via
the `CMAKE_FIND_DEBUG_MODE` variable.

This work was started by Chris Wilson, continued by Ray Donnelly, and
then refactored by Robert Maynard to collect information into a single
message per find query.

Co-Author: Ray Donnelly <mingw.android@gmail.com>
Co-Author: Chris Wilson <chris+github@qwirx.com>
2019-12-19 08:09:49 -05:00
Robert Maynard
2467a2b318 CUDA: Add cuda meta-features (e.g. `cuda_std_11`) support 2019-12-10 17:56:48 -05:00
Daniel Eiband
777ceaea94 cmMakefile: Delay custom command creation
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
2019-11-24 20:32:43 +01:00
Daniel Eiband
3dc084ebc1 cmMakefile: Explicitly pass backtrace to GetCustomCommandTarget
Allow GetCustomCommandTarget to be called at generate time with correct
backtraces.
2019-11-24 20:13:23 +01:00
Daniel Eiband
bf76a6b801 cmMakefile: Delay CheckTargetProperties and FinalPass to generate time 2019-11-24 20:13:23 +01:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Brad King
9b03baee30 Merge topic 'objective-c-cxx'
dd0f304613 Objective C/C++: Add compiler standard detection
b515af782b Help: Add release note for Objective-C/C++ language support
9e66397c28 Languages: Add support for Objective-C++
80f120a85f Languages: Add support for Objective-C

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3811
2019-09-30 10:25:19 -04:00
Cristian Adam
dd0f304613 Objective C/C++: Add compiler standard detection 2019-09-28 15:56:53 +02:00
Daniel Eiband
5a06efda05 cmMakefile: Remove AddUtilityCommand overload without byproducts 2019-09-26 10:04:03 -04:00
Daniel Eiband
ea1bed34b2 cmMakefile: Extract utilities used for creation of custom commands
Decompose creation of custom commands further into logical steps.
2019-09-26 10:03:48 -04:00
Daniel Eiband
f151a57705 cmMakefile: Move enumerations into new header
The enumerations will also be used in cmLocalGenerator.
2019-09-26 10:02:06 -04:00
Brad King
ebb9346490 Merge topic 'cmake-system-headers'
4a08690ccf cmstd: Extend header <cm/iterator>
c688b401d3 cmstd: Modernize CMake system headers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3776
2019-09-20 10:38:43 -04:00
Brad King
541e681da2 Merge topic 'split-custom-command-creation'
0e1faa28cb cmMakefile: Separate custom command setup from actual creation
56c204e8eb cmMakefile: Refactor AddCustomCommandOldStyle to be delay friendly
3061dc6ac9 add_custom_command: Add tests for rejecting literal quotes in commands
e893ab94ba cmMakefile: Validate command line for all custom commands
f1e846fdde cmMakefile: Extract custom command validation method
4926ab2454 cmMakefile: Create all generated byproducts as known sources

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3822
2019-09-20 10:24:32 -04:00
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04:00
Daniel Eiband
0e1faa28cb cmMakefile: Separate custom command setup from actual creation
Refactor custom command manipulation functions to consist of a setup and a
commit stage.  The commit stage will be delayed to generate time.
2019-09-17 22:52:32 +02:00
Daniel Eiband
e893ab94ba cmMakefile: Validate command line for all custom commands 2019-09-17 22:50:25 +02:00
Daniel Eiband
f1e846fdde cmMakefile: Extract custom command validation method 2019-09-17 22:50:25 +02:00
Daniel Eiband
4926ab2454 cmMakefile: Create all generated byproducts as known sources 2019-09-17 22:50:25 +02:00
Daniel Eiband
9c45b95ddd cmMakefile: Remove unused AddUtilityCommand overload 2019-09-16 20:45:56 +02:00
Brad King
1ac4e0ef1b Merge topic 'tidy-deprecated-headers'
f30523d090 clang-tidy: modernize-deprecated-headers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3792
2019-09-16 10:25:53 -04:00
Brad King
7c47894b45 Merge topic 'prepare-deferred-custom-command-creation'
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
2019-09-16 10:18:51 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Daniel Eiband
5d28e361b7 add_custom_command: Move append functionality into class cmMakefile 2019-09-13 11:00:21 -04:00
Daniel Eiband
4fb29850ad add_custom_command: Refactor setting implicit depends
Implicit dependencies are now passed as argument to AddCustomCommandToOutput.
This is necessary to be able to delay custom command creation.
2019-09-12 23:00:36 +02:00
Daniel Eiband
2edb0b71ed cmMakefile: Add lookup from source name to targets via byproducts
Given an output source name it is now possible to query which target has a
byproduct of this name or has a PRE_BUILD, PRE_LINK, or POST_BUILD build event
with a byproduct of this name.

In a call to GetSourceFileWithOutput a matching byproduct can now optionally be
returned as fallback if there is no matching output of a custom command.

Default behavior is not changed by this commit.
2019-09-12 16:01:45 +02:00
Daniel Eiband
7569239362 cmMakefile: set GENERATED property of outputs upfront
Setting the GENERATED property of outputs upfront is a precondition for delayed
custom command creation (generator expressions in outputs).

Issue: 12877
2019-09-06 22:22:22 +02:00
Regina Pfeifer
62e5f72289 clang-tidy: Replace typedef with using 2019-09-03 13:21:26 -04:00
Daniel Eiband
10507c6dc0 cmMakefile: Add configurations getter with empty configuration default 2019-08-30 13:52:13 +02:00
Gabor Bencze
9413952c42 cmCommand refactor: cmCMakePolicyCommand 2019-08-20 14:42:20 -04:00
Kitware Robot
54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP 2019-08-09 10:41:44 -04:00
Regina Pfeifer
6491270e0d cmFunctionBlocker: Move check for matching args 2019-07-31 00:03:17 +02:00
Regina Pfeifer
b51fba6298 cmMakefile: Add OnExecuteCommand callback
In cmCTestScriptHandler, port away from cmFunctionBlocker
and update the elapsed time with the new callback instead.
2019-07-31 00:03:17 +02:00
Kyle Edwards
89dc04af1d Merge topic 'cmStringAlgorithms'
f71f7ce3f0 cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3618
2019-07-30 10:04:40 -04:00
Sebastian Holtermann
f71f7ce3f0 cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h
This adds the `cmStringAlgorithms.h` header and moves all string functions
from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
2019-07-29 21:13:56 +02:00
Regina Pfeifer
020478dbea cmMakefile: Keep function blockers in a stack
Highlight the fact that we only ever operate on the top element.
2019-07-27 00:22:15 +02:00
Sebastian Holtermann
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value
argument instead of a `const char *`.

Benefits are:
- `std::string` can be passed to `cmMakefile::AddDefinition` directly without
  the `c_str()` plus string length recomputation fallback.
- Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at
  compile time.

In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid
`std::string::c_str` calls and the `std::string` is passed directly.
Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might
be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
2019-07-24 11:11:25 +02:00
Sebastian Holtermann
f2ba968ef2 cmMakefile: Simplify and rename AddDefinitionBool
This simplifies the `cmMakefile::AddDefinition` method with bool value
overload to call the string based `cmMakefile::AddDefinition` method
with either an "ON" or "OFF" string.
Also the method is renamed to `cmMakefile::AddDefinitionBool`
2019-07-24 11:11:25 +02:00
Brad King
573f1fc19b Merge topic 'command-final-action'
732dd344b9 cmCommand: remove FinalPass from interface
fbee46e262 cmVariableWatchCommand: Port away from FinalPass
360d415592 cmLoadCommandCommand: Port away from FinalPass
316e40baec cmInstallProgramsCommand: Port away from FinalPass
7bc88b9165 cmInstallFilesCommand: Port away from FinalPass
6a1a3763ee cmFLTKWrapUICommand: Port away from FinalPass
20169f0b8d cmExportLibraryDependenciesCommand: Port away from FinalPass
a74dad3bd3 cmMakefile: decouple FinalAction from cmCommand
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3562
2019-07-19 12:09:03 -04:00
Daniel Pfeifer
a74dad3bd3 cmMakefile: decouple FinalAction from cmCommand 2019-07-18 11:53:46 +02:00
Sebastian Holtermann
3bed969dac cmMakefile: Modernize AddFunctionBlocker method to accept a std::unique_ptr 2019-07-17 14:58:27 +02:00
Marc Chevrier
1591f138f1 modernize: manage cmCommand instances using unique_ptr. 2019-07-14 15:37:30 +02:00