Commit Graph

10904 Commits

Author SHA1 Message Date
FeRD (Frank Dana)
7aacae4e0e Tests: Add unit tests for property redefinition
From reading `Source/cmDefinePropertyCommand.cxx` and
`Source/cmPropertyDefinition.cxx`, attempts to use `define_property()`
to redefine an existing property will be silently ignored.
Once a property is defined, it cannot be redefined.

Add some unit tests to confirm this behavior of `define_property()`
remains as expected based on the current implementation.
2024-01-29 05:23:37 -05:00
Brad King
ac9fd4f009 Merge topic 'swift-always-restat'
1161ad76ac Swift/Ninja: Always restat swift build commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9076
2024-01-05 13:31:09 -05:00
Brad King
7058d715b4 Merge topic 'swift-compile-commands'
44f29a4291 Swift/Ninja: Fix multifile module compile commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9095
2024-01-05 13:30:15 -05:00
Brad King
02eb4c0a2a Merge topic 'test-RunCMake.ExternalProject'
3253bc306e Tests: Optionally run RunCMake.ExternalProject serially

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9129
2024-01-05 10:19:51 -05:00
Brad King
769be838cb Merge topic 'check_language_propagate_hip_platform'
ce9c6d0994 HIP: Propagate CMAKE_HIP_PLATFORM from/to the test project in check_language
9ba3fc91e5 HIP: Really forward CMAKE_HIP_HOST_COMPILER in check_language(HIP)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9121
2024-01-05 10:16:53 -05:00
Jeremy Day
1161ad76ac Swift/Ninja: Always restat swift build commands
The swift toolchain leaves output files untouched
if there are no meaningful input changes; without
restat, this causes ninja to needlessly rebuild
targets that are not actually out-of-date

Fixes: #25496
2024-01-04 13:20:05 -08:00
Brad King
3253bc306e Tests: Optionally run RunCMake.ExternalProject serially
On some machines running many tests concurrently, the `INACTIVITY_TIMEOUT`
cases do not always complete within their individual timeout.  Add an
undocumented cache entry to use on those machines to run the test serially.
2024-01-04 13:40:41 -05:00
Brad King
5a61984088 Merge topic 'compute-compiler-linker'
459d1cc095 Tests: Verify that linker tool is detected and identified where expected
6aec4739c1 LinkerId: Record detection steps to configure log
ba5f8dbba3 LinkerId: Use empty string for unknown linker id
6cbd0658c5 LinkerId: Match Apple linker on all Apple platforms
9324668517 LinkerId: Fix detection of GNU linker id without parenthesis in version output
37bc148870 LinkerId: Fix detection of linker tool without path
6e527c2d38 LinkerId: Fix detection of linker tool for Clang on OpenBSD
455aed3061 LinkerId: Fix detection of linker tool for MSVC
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9086
2024-01-04 11:53:38 -05:00
Gergely Meszaros
ce9c6d0994 HIP: Propagate CMAKE_HIP_PLATFORM from/to the test project in check_language
Fixes: #25541
2024-01-04 11:25:15 -05:00
Evan Wilde
44f29a4291 Swift/Ninja: Fix multifile module compile commands
Swift compile commands need to have all source files in the module
specified in the compile command or LSP systems will report errors on
missing types that are defined in other source files in the same module.

Issue: #25491
2024-01-03 14:57:46 -08:00
Brad King
459d1cc095 Tests: Verify that linker tool is detected and identified where expected 2024-01-03 17:07:53 -05:00
Brad King
6cbd0658c5 LinkerId: Match Apple linker on all Apple platforms
`cmake_determine_linker_id` is only used for macOS because Apple device
platforms set `_CMAKE_FEATURE_DETECTION_TARGET_TYPE` to `STATIC_LIBRARY`,
but we might as well prepare for them anyway.
2024-01-03 17:07:52 -05:00
Brad King
9324668517 LinkerId: Fix detection of GNU linker id without parenthesis in version output 2024-01-03 17:07:52 -05:00
Brad King
37bc148870 LinkerId: Fix detection of linker tool without path
Some compiler drivers invoke the linker tool as just `ld`, with no path,
expecting it to be in the `PATH`.
2024-01-03 17:07:52 -05:00
Brad King
6e527c2d38 LinkerId: Fix detection of linker tool for Clang on OpenBSD
Do not match quotes as part of the path.
2024-01-03 17:07:51 -05:00
Brad King
455aed3061 LinkerId: Fix detection of linker tool for MSVC
Previously we matched an entire build system output line and then
extracted the relevant portion in a separate brittle step.  Match
it directly.  Use the `CMAKE_LINKER` value directly if available.
2024-01-03 17:05:55 -05:00
Brad King
78b7ba6494 LinkerId: Fix detection of linker tool for GNU on SunOS sparc32
We do not use `-Wl,-v` on SunOS because not all GNU deployments use the
`collect2` helper, and those that do do not always print the underlying
`ld` command line.  Parse the `--with-ld=` option as a fallback.
2024-01-03 16:24:58 -05:00
Brad King
dd480e5be5 LinkerId: Fix detection of linker tool for XL compilers
These compilers print an explicit `export XL_LINKER=` line.
Parse it separately.
2024-01-03 16:24:58 -05:00
Brad King
262de2ad92 LinkerId: Fix detection of linker tool for XL as nvcc host compiler
When IBM XL is used as the host compiler for nvcc, it generates a
comma-separated link line.  Parse the `exec:` line syntax separately, as
was done in commit b5f20da94d (CMakeParseImplicitLinkInfo supports comma
separated link lines, 2019-08-23, v3.16.0-rc1~181^2).
2024-01-03 16:24:57 -05:00
Brad King
a192dc9fad Tests: Cover detection of linker tool for Intel on Windows 2024-01-03 16:24:57 -05:00
Brad King
03e1670166 Tests: Cover detection of linker tool for MSVC
Cover both Ninja and Visual Studio generators.
2024-01-03 16:22:50 -05:00
Brad King
0523cc501d Tests: Cover detection of linker tool while parsing implicit link info
There are a few cases where content besides the path is picked up.
Match them for now.  We will fix them in following commits.
2024-01-03 16:20:27 -05:00
Brad King
fcfe47d799 Tests: Update sample data for parsing implicit link/include information
Since commit c26c6ac488 (Link Step: compute effective linker used by the
compiler, 2023-05-27) we use `CMAKE_${lang}_VERBOSE_LINK_FLAG` when
detecting implicit link information.  Generate sample test data with it.
2024-01-03 16:20:27 -05:00
Brad King
8153485fd5 Tests: Improve isolation of cases parsing implicit link/include information 2024-01-03 16:20:27 -05:00
Brad King
bd31a35899 Tests: Add unit tests for internal cmake_determine_linker_id helper 2024-01-03 16:20:24 -05:00
Craig Scott
d0f395525f Tests: Quote possibly empty string(REPLACE) argument
The ${unity_source_line} variable should not normally be empty,
but it has been observed that it sometimes is due to other factors.
Rather than causing string(REPLACE) to fail due to the wrong
number of arguments, quote the variable so that the
UnityBuildPre2017 test case fails with a more appropriate
error in the block just after the usage fixed by this change.
2024-01-01 11:58:22 +11:00
Marc Chevrier
179c036b5d Merge topic 'Ninja-LINK_OPTIONS-with-newlines'
255c2e1430 Ninja: LINK_OPTIONS property should support newlines

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9096
2023-12-23 05:39:10 -05:00
Marc Chevrier
255c2e1430 Ninja: LINK_OPTIONS property should support newlines
Fixes: #25513
2023-12-20 17:05:09 +01:00
Brad King
e6cd118f02 Merge topic 'package-dispatch-apple'
4ac5a2f866 CMakePackageConfigHelpers: Add generate_apple_architecture_selection_file()
b9f81ee9f9 CMakePackageConfigHelpers: Remove outdated documentation summary paragraph
68a03cf3d4 generate_apple_platform_selection_file: Add INSTALL_PREFIX option
ff21f0f70f Tests: Verify generate_apple_platform_selection_file file paths

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9092
2023-12-20 09:12:49 -05:00
Brad King
a350d92c06 Merge topic 'add_test-CROSSCOMPILING_EMULATOR-exclusive'
ca5a300d7f add_test: Honor CROSSCOMPILING_EMULATOR only when cross-compiling

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8947
2023-12-20 09:09:48 -05:00
Brad King
5c1990fc51 Merge topic 'swift-CMP0157-old'
d31b48816c Swift/Ninja: Fix missing OFM in CMP0157 OLD behavior

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9089
2023-12-20 09:08:53 -05:00
Ralf Habacker
ca5a300d7f add_test: Honor CROSSCOMPILING_EMULATOR only when cross-compiling
Add policy CMP0158 to provide compatibility for existing projects.

Fixes: #23672
2023-12-19 10:00:55 -05:00
Brad King
4ac5a2f866 CMakePackageConfigHelpers: Add generate_apple_architecture_selection_file()
Add a helper to select architecture-specific implementations of a
package on an Apple-specific platform.

Fixes: #25516
2023-12-19 08:56:30 -05:00
Brad King
68a03cf3d4 generate_apple_platform_selection_file: Add INSTALL_PREFIX option
This is necessary to forward to `configure_package_config_file`.
2023-12-19 08:51:16 -05:00
Brad King
ff21f0f70f Tests: Verify generate_apple_platform_selection_file file paths 2023-12-19 08:27:44 -05:00
Brad King
c3b4453b13 Merge topic 'gtest_discover_tests_error_message'
2ea216a6bb GoogleTest: Add working directory to gtest_discover_tests error message

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9083
2023-12-19 08:10:55 -05:00
Brad King
d2cbadf3b4 Merge topic 'package-dispatch-apple'
dc5098429b CMakePackageConfigHelpers: Clarify Apple platform selection usage error
3b9586671c CMakePackageConfigHelpers: Clarify Apple platform selection template name

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9087
2023-12-19 08:10:15 -05:00
Brad King
49dc6a44e0 Merge topic 'Xcode-Check-Imported-Framework'
defbfd6f55 Xcode: Restore support for standalone IMPORTED_LOCATION_<CONFIG>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9082
2023-12-19 08:04:01 -05:00
Evan Wilde
d31b48816c Swift/Ninja: Fix missing OFM in CMP0157 OLD behavior
The CMP0157 old behavior omitted the output-file-map after the Swift
build split because we stopped calling `EmitSwiftDependencyInfo` when we
could not split the build because we didn't call
`WriteObjectBuildStatement`. If we can't split the build, then we still
need to include the OFM information to not break incremental builds.
2023-12-18 19:42:53 -08:00
Brad King
dc5098429b CMakePackageConfigHelpers: Clarify Apple platform selection usage error
`generate_apple_platform_selection_file` requires `INSTALL_DESTINATION`.
2023-12-18 14:57:27 -05:00
Brad King
edb10c5325 Merge topic 'package-dispatch-apple'
1dd4a9baff Tests: Cover generate_apple_platform_selection_file on all platforms
3148db4533 CMakePackageConfigHelpers: Fix Apple platform selection for tvOS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9077
2023-12-18 10:56:43 -05:00
Marc Chevrier
defbfd6f55 Xcode: Restore support for standalone IMPORTED_LOCATION_<CONFIG>
In commit 878ae03832 (macOS: IMPORTED framework: Honor SYSTEM target
property in all cases, 2023-08-27, v3.28.0-rc1~162^2) we broke support
for `IMPORTED_LOCATION_<CONFIG>` without `IMPORTED_CONFIGURATIONS`.
Previously it worked if the importing project's configurations match the
set of `IMPORTED_LOCATION_<CONFIG>` properties set.  Fix that case.

Fixes: #25506
Issue: #25515
2023-12-18 10:18:25 -05:00
Alexander Krabler
2ea216a6bb GoogleTest: Add working directory to gtest_discover_tests error message
If the working directory didn't exist, the old message just says:

    Error running test executable.

        Path: '<Path to test executable>'
        Result: No such file or directory
        Output:

This leads the user to the conclusion that the test executable doesn't
exist, which isn't true.  Make the true cause visible by reporting the
working directory in the error message.
2023-12-18 09:03:51 -05:00
Craig Scott
50e8791f92 Merge topic 'fc-provider-find-package-args'
0415304970 FetchContent: Fix FIND_PACKAGE_ARGS not being passed to dep providers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9080
2023-12-17 15:43:00 -05:00
Brad King
ba41ca758a Merge topic 'swift-split-compilation-model'
9bed4f4d81 Swift/Ninja: Split compilation model
64b3367845 cmGlobalGenerator: Allow passing language to GetLangaugeOutputExtension

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8907
2023-12-16 07:15:41 -05:00
Brad King
1dd4a9baff Tests: Cover generate_apple_platform_selection_file on all platforms
The test added by commit 37bc3400cd (CMakePackageConfigHelpers: Add
generate_apple_platform_selection_file(), 2023-11-03) covers importing
only on macOS, and is specific to the xcframework test case.  Add a
dedicated test for `generate_apple_platform_selection_file` that covers
export and import on all platforms.
2023-12-16 06:54:46 -05:00
Craig Scott
0415304970 FetchContent: Fix FIND_PACKAGE_ARGS not being passed to dep providers
Fixes: #25504
2023-12-16 16:42:00 +11:00
Brad King
6ba3bb0563 Merge topic 'cmake-test-launcher'
88863d83d6 fileapi: Add test launcher to codemodel-v2
1ec0372ed4 add_test: Optionally use a launcher for tests running in-project targets
478a5f4e04 fileapi: Make launcher attribute 'arguments' optional
b44e38a397 cmFileAPICodemodel: Add missing std::move()

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8963
2023-12-15 09:34:20 -05:00
Brad King
d901c4aa95 Merge topic 'FindCUDAToolkit-cupti'
04959e0285 Tests: Verify CUDA::cupti existence on a subset of machines
09a3c8b46b CUDAToolkit: Correctly search all include paths from compiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9072
2023-12-15 09:32:00 -05:00
Evan Wilde
9bed4f4d81 Swift/Ninja: Split compilation model
Splitting the Swift build into an object build and a separate link step,
instead of building and linking in one step. The immediate benefit is
LSP support because we are able to emit compile-commands for Swift files
now. Additionally, it is possible to specify flags to the compile step,
enabling folks to emit C and C++ headers from their Swift builds for
C/C++ interop, without needing custom commands. Eventually, this gives
us a path toward working object libraries.

Object Libraries:
 - Object libraries don't work today because CMake doesn't emit targets
   for object libraries into the Ninja build file.
 - tl;dr: Object libraries work if they aren't WMO. Still need work to
   make WMO'd object libraries work.

   Object libraries still don't completely work with this patch because,
   while we emit the targets, the `TARGET_OBJECTS` generator expression
   expansion has a separate mechanism for determining what the names of
   the objects are based on the input source files, so targets that
   depend on an object library built with a whole-module optimization
   will depend on objects based on the name of the source file instead
   of the actual emitted object file.

These features require being able to accurately model wholemodule builds
though, because we actually need to track object files and WMO affects
what objects are emitted. For that, we require CMP0157 use the NEW
policy. When it's OLD, we have to fall back on the old behavior and
cannot provide object libraries or the compile-commands for LSP.

Issue: #25308
2023-12-15 05:51:13 -08:00