Commit Graph

7271 Commits

Author SHA1 Message Date
Rolf Eike Beer
ef778d77e0 replace std::string::substr() with operations that do not allocate memory
Modify the original string instead of creating a new copy with substr() when it
is not used for anything else afterwards.
2020-03-23 22:41:44 +01:00
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
Brad King
863b0fa2ac Merge topic 'FindRuby-updates'
46064c8193 FindRuby: Add support for versions up to 2.7
675eaf3bd0 FindRuby: Update MSVC runtime library selection
b970e25d98 FindRuby: Remove extra whitespace
ecdace4d61 FindRuby: Include FPHSA closer to where it is used
f52f496138 FindRuby: Provide Ruby_LIBRARIES result variable
b00d736a0b FindRuby: Add dedicated tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4481
2020-03-18 09:09:18 -04:00
Brad King
d9ad00119d Merge topic 'FindPkgConfig-broken-pkg-config'
1c99f5df28 FindPkgConfig: Add test for specified pkg-config tool missing
b59f36aad8 FindPkgConfig: Unset results when pkg-config is broken

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4451
2020-03-18 09:08:12 -04:00
Brad King
3c7774e207 Merge topic 'FindPython-version-validation-fix'
cc7f116cb4 FindPython: fix regression on version validation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4492
2020-03-18 07:54:23 -04:00
Marc Chevrier
cc7f116cb4 FindPython: fix regression on version validation
In commit 3dab4682f6 (FindPython: reduces consumption of resources,
2020-02-10, v3.17.0-rc1~11^2) we accidentally broke the python
executable version validation when the "LOCATION" strategy is used
with the plain `FindPython` module.  Fix the logic and add test
cases covering those combinations.

Fixes: #20465
2020-03-17 10:08:34 -04:00
Brad King
bee0100396 Merge topic 'file-archive'
c7e1198a23 file: Add ARCHIVE_{CREATE|EXTRACT} subcommands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4475
2020-03-17 08:06:57 -04:00
Brad King
1c99f5df28 FindPkgConfig: Add test for specified pkg-config tool missing 2020-03-17 08:02:15 -04:00
Brad King
f52f496138 FindRuby: Provide Ruby_LIBRARIES result variable
The `cmake-developer(7)` manual documents that a plural non-cached
name should be used for results.
2020-03-16 14:05:26 -04:00
Julien Marrec
b00d736a0b FindRuby: Add dedicated tests
Issue: #20370
2020-03-16 13:33:27 -04:00
Brad King
c6def2107f Merge topic 'gtest-parallel-xml'
32bc6aa9b6 GoogleTest: Add release note for XML_OUTPUT_DIR
0001339a6f GoogleTest: Add test case for XML_OUTPUT_DIR
e9ab39eb1d GoogleTest: Add XML_OUTPUT_DIR parameter

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4433
2020-03-16 11:40:21 -04:00
Brad King
eea528fd92 Merge topic 'gnu-as'
9728839b9e ASM: Fix executable link lines with GNU 'as' tool as CMAKE_ASM_COMPILER
5932f0be4f ASM: Fix depfile flags for GNU 'as' tool
0d0aa98c84 ASM: Record vendor-specific output matched to identify assembler
ee3ec27465 CMakeDetermineCompilerId: Set locale to C for vendor output match

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4460
2020-03-16 11:31:25 -04:00
Cristian Adam
c7e1198a23 file: Add ARCHIVE_{CREATE|EXTRACT} subcommands
Fixes: #20443
2020-03-16 14:33:27 +01:00
Brad King
3766633b8a Merge topic 'FindRuby-variable-case'
e672db628b FindRuby: Rename variables to match case of module name

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Frank Dana <ferdnyc@gmail.com>
Merge-request: !4463
2020-03-13 11:01:56 -04:00
Brad King
200bc3b785 Merge topic 'swift-implicit-module-include-dir'
2026915f8f Swift: Propagate Swift_MODULE_DIRECTORY as include directory

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4320
2020-03-13 11:00:39 -04:00
Brad King
1b5554e863 Merge topic 'profiling'
9aa4640792 cmake: add command line options to output script profiling data

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Acked-by: Pavel Solodovnikov <hellyeahdominate@gmail.com>
Acked-by: Leonid Pospelov <pospelovlm@yandex.ru>
Acked-by: Cristian Adam <cristian.adam@gmail.com>
Merge-request: !2760
2020-03-13 10:59:03 -04:00
Alexander Stein
0001339a6f GoogleTest: Add test case for XML_OUTPUT_DIR 2020-03-13 10:47:33 -04:00
Brad King
c3ab1c22b0 Merge topic 'GoogleTest-gtest_discover_tests-failure'
2ba8ac07ed GoogleTest: Fix CTest not failing if gtest_discover_tests fails
2c9680eec5 GoogleTest: Add missing test case for gtest_discover_tests failure

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Steffen Seckler <steffen.seckler@tum.de>
Acked-by: Matthew Woehlke <matthew.woehlke@kitware.com>
Merge-request: !4466
2020-03-13 10:46:20 -04:00
Brad King
5932f0be4f ASM: Fix depfile flags for GNU 'as' tool
The GNU `as --help` shows `--MD <file>` as an option to generate depfiles
as needed by Ninja.  There is no `-MT <target>` flag but fortunately the
generated files automatically account for the `-o <obj>` flag.

Issue: #20426
2020-03-13 09:55:36 -04:00
Saleem Abdulrasool
2026915f8f Swift: Propagate Swift_MODULE_DIRECTORY as include directory
Teach include directory computation for Swift to implicitly propagate
the `Swift_MODULE_DIRECTORY` of all linked targets as include
directories.  This is required to ensure that the swiftmodule of a
linked target is accessible to the compiler of the current target.

Fixes: #19272
2020-03-12 11:50:43 -04:00
Craig Scott
3d388e5e98 Merge topic 'rename-macho-version-properties' into release-3.17
14732d3f30 macOS: Rename OSX_*_VERSION properties to MACHO_*_VERSION

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4452
2020-03-12 06:52:11 -04:00
Craig Scott
54863e28ce Merge topic 'rename-macho-version-properties'
14732d3f30 macOS: Rename OSX_*_VERSION properties to MACHO_*_VERSION

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4452
2020-03-12 06:52:11 -04:00
Brad King
14732d3f30 macOS: Rename OSX_*_VERSION properties to MACHO_*_VERSION
The properties added by commit 4a62e3d97c (macOS: Add
OSX_COMPATIBILITY_VERSION and OSX_CURRENT_VERSION properties,
2020-01-24, v3.17.0-rc1~80^2~1) are general-purpose for all platforms
using Mach-O formats and not just on OS X.  Rename them accordingly.
The properties are new to the CMake 3.17 release so we can rename
them without compatibility concerns.

Fixes: #20442
2020-03-12 21:15:40 +11:00
Ryan Thornton
2c9680eec5 GoogleTest: Add missing test case for gtest_discover_tests failure
Discovery timeout test needs split out into two components:
- build
- test

Building the project should result in a failure due to the timeout
when executing gtest discovery as a post build step.

Likewise, if you ran CTest after this build failure,
we should *also* detect that the discovery_timeout_test has not been built
because no discovery_timeout_test[1]_tests.cmake has been created
due to the test discovery failure (caused by the timeout).
2020-03-11 15:10:23 -05:00
Julien Marrec
e672db628b FindRuby: Rename variables to match case of module name
Use recommended case for variable names, i.e. matching name of the
module as passed to `find_package`.

For backwards compatibility, the upper case versions of both input and
output variables are used and defined when appropriate.  Skip this for
the _FOUND variable because FPHSA already does it.

This follows the approach from commit a7b09e7f43 (FindProtobuf: Rename
variables to match case of module name, 2016-03-01, v3.6.0-rc1~273^2).

Issue: #20370
2020-03-11 13:56:10 -04:00
Kyle Edwards
228232d454 Merge topic 'swift-ninja-multiconfig'
87819db28d Merge branch 'backport-swift-ninja-multiconfig' into swift-ninja-multiconfig
65b3848de0 Swift: support Ninja Multi-Config

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4440
2020-03-10 10:16:17 -04:00
Brad King
268909518f Merge topic 'file-CONFIGURE'
a6fee09484 file: Add CONFIGURE subcommand

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4436
2020-03-10 08:27:21 -04:00
Leander Beernaert
a6fee09484 file: Add CONFIGURE subcommand
Extend the `file()` command with a new `CONFIGURE` subcommand that
behaves the same as `string(CONFIGURE)` except that it writes the
resulting output immediately to a file.

Fixes: #20388
2020-03-09 11:54:02 -04:00
Kyle Edwards
87819db28d Merge branch 'backport-swift-ninja-multiconfig' into swift-ninja-multiconfig 2020-03-09 09:12:54 -04:00
Saleem Abdulrasool
65b3848de0 Swift: support Ninja Multi-Config
Enable support for multi-configuration builds using Ninja when building
Swift.
2020-03-09 09:11:22 -04:00
Wouter Klouwen
9aa4640792 cmake: add command line options to output script profiling data
For users of CMake who want to optimize their scripts if they take a
while to run, this commit adds the ability to output profiling data.

To enable this output, it adds the two command line parameters
to select the output path and format.

This commit adds the first profiling format of type ``google-trace``,
which is the output is a JSON file containing Duration events as per the
Google Trace Format specification:

https://docs.google.com/document/d/1CvAClvFfyA5R-
PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#
2020-03-07 13:36:27 +00:00
Sylvain Joubert
dc00809596 find_*: Add support for REQUIRED keyword
In the same spirit as the REQUIRED keyword on find_package, this will
stop cmake execution with an error on a failed find_program, find_file,
find_path or find_library.
2020-03-06 16:40:26 +01:00
Brad King
995b122471 Merge topic 'FindPython-artifacts-scope'
e5b4c74238 FindPython: Add possibility to control scope of artifacts.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4426
2020-03-06 09:18:24 -05:00
Kyle Edwards
e484b4289d Merge topic 'macos_framework_postfix'
ad3f69c86e Add support for FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4289
2020-03-05 10:50:15 -05:00
Marc Chevrier
e5b4c74238 FindPython: Add possibility to control scope of artifacts.
Fixes: #20362
2020-03-05 16:44:48 +01:00
Brad King
fee2b209b8 Merge topic 'objlib-transitive-deps'
a833aa1167 Fix dependencies on targets linked through object libraries
3b3de0fd17 Tests: Extend ObjectLibrary test with case for object lib dependencies

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4427
2020-03-05 07:26:18 -05:00
Brad King
9871190dd7 Merge topic 'ninja-multi-custom-command-deps'
081c4679f7 Ninja Multi-Config: Don't build target dependencies for custom commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4423
2020-03-05 07:24:49 -05:00
Brad King
cf0dc5efbf Merge topic 'ninja-multi-custom-command-deps' into release-3.17
081c4679f7 Ninja Multi-Config: Don't build target dependencies for custom commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4423
2020-03-05 07:24:48 -05:00
Brad King
fbe5caee8f Merge topic 'findx11-improvement'
77802aab97 FindX11: Find additional libraries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !4101
2020-03-05 07:22:39 -05:00
Brad King
a833aa1167 Fix dependencies on targets linked through object libraries
When an object library is used via `target_link_libraries`, any targets
listed in the object library's `INTERFACE_LINK_LIBRARIES` closure should
become direct dependencies of the consuming target.  However, these were
accidentally left out by `cmComputeTargetDepends::CollectTargetDepends`
because object libraries are encountered through external object sources
first and then added to the `emitted` set which blocks them from being
processed as link dependencies.

This was not noticed by the test case in commit bab24e782c
(target_link_libraries: Propagate dependencies of object libraries,
2018-12-10, v3.14.0-rc1~260^2) because the relevant dependency appears
transitively through the object library target itself.

Re-order the logic to process link dependencies first, and then external
object sources.  That way object libraries used via
`target_link_libraries` will be treated as such by dependency analysis.

This also adds missing backtrace information for object libraries used
via `target_link_libraries`.  The missing information was mentioned in a
FIXME comment in the RunCMake.FileAPI test added by commit ea0a060168
(fileapi: Add test for codemodel v2, 2018-11-09, v3.14.0-rc1~257^2~7).
That comment itself was dropped by commit a0de350e2f (FileAPI test:
Break gen_check_targets() into JSON files, 2020-02-07), but we can now
update the corresponding location in the `.json` files to have the
now-expected backtrace information.

Fixes: #20421
2020-03-04 13:07:41 -05:00
Brad King
3b3de0fd17 Tests: Extend ObjectLibrary test with case for object lib dependencies
Add the test case from commit bab24e782c (target_link_libraries:
Propagate dependencies of object libraries, 2018-12-10,
v3.14.0-rc1~260^2) to the main ObjectLibrary test.
2020-03-04 13:04:00 -05:00
Zsolt Parragi
77802aab97 FindX11: Find additional libraries
With this change, FindLibrary(X11) learns about the following libraries:

 * xcb
 * X11-xcb
 * xcb-icccm
 * xcb-xkb
 * xkbcommon
 * xkbcommon-X11
2020-03-04 16:55:32 +01:00
Alexandru Croitor
ad3f69c86e Add support for FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG> 2020-03-04 14:30:54 +01:00
Brad King
95b151af90 Merge topic 'FindPython-manage-SOABI-suffix'
0c97b73bc0 FindPython: python_add_library can now manage SOABI suffix.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4420
2020-03-04 08:20:18 -05:00
Brad King
ab00435e79 Merge topic 'FindPython-manage-SOABI-suffix' into release-3.17
0c97b73bc0 FindPython: python_add_library can now manage SOABI suffix.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4420
2020-03-04 08:20:17 -05:00
Brad King
26f728ca78 Merge topic 'ninja-multi-spurious-unused-variables'
8b799f80e3 Ninja Multi-Config: Fix spurious unused variable warning

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4421
2020-03-04 08:18:03 -05:00
Kyle Edwards
8b799f80e3 Ninja Multi-Config: Fix spurious unused variable warning
Fixes: #20381
2020-03-03 15:52:36 -05:00
Kyle Edwards
081c4679f7 Ninja Multi-Config: Don't build target dependencies for custom commands
If cross-config mode is used, and a target depends on another target
as well as a custom command, we don't want the custom command to also
depend on the depended target, as that would build targets unnecessarily.
Fix this behavior.
2020-03-03 15:15:13 -05:00
Brad King
38ac070ead Merge topic 'cmake_command-eval'
598b676b5e cmake_command: Add command to EVAL a CMake script as a string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4408
2020-03-03 09:19:39 -05:00