37094 Commits

Author SHA1 Message Date
Brad King
a12ed97b5c CMake 4.0.2 2025-05-05 10:23:02 -04:00
Craig Scott
149ee3b4bc Xcode: Use DEBUGGER_WORKING_DIRECTORY as a fallback for scheme work dir
This also means when XCODE_SCHEME_WORKING_DIRECTORY is
set and a Xcode generator is used, that property will be used when
writing the debugger field in the file API replies.

Fixes: #26909
2025-05-03 10:16:15 -04:00
Brad King
e49dc061c2 Merge topic 'clang-macos-sdk' into release-4.0
bf1bb62e74 macOS: Restore support for LLVM/Clang without explicit CMAKE_OSX_SYSROOT

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10734
2025-05-03 10:02:16 -04:00
Brad King
bf1bb62e74 macOS: Restore support for LLVM/Clang without explicit CMAKE_OSX_SYSROOT
In commit 7b19531291 (macOS: Do not pass any SDK/-isysroot to compilers
by default, 2024-11-06, v4.0.0-rc1~511^2) we broke support for using
upstream LLVM/Clang to build for macOS because the compiler has no
default sysroot.  Handle empty `CMAKE_OSX_SYSROOT` with LLVM/Clang by
falling back to the macOS SDK reported by `xcrun --show-sdk-path` .

Fixes: #26863
2025-05-02 13:49:40 -04:00
Brad King
edec9fbf57 Merge topic 'fix-find-performane-regression' into release-4.0
bb3a348def find_package: Fix performance regression in 4.0.0 release

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10731
2025-05-01 15:50:24 -04:00
Matthew Woehlke
bb3a348def find_package: Fix performance regression in 4.0.0 release
In commit e90f60f864 (find_package: Don't glob certain macOS paths,
2024-10-23, v4.0.0-rc1~579^2~1) we changed the name matching logic of
`find_package` to check if a possible match is a directory before
checking whether the name is a match.  In some situations, this results
in unnecessarily calling `stat` for a very large number of files, which
can be extremely slow on some systems (especially Windows).  Fix this by
making the check the last thing we do before accepting a possible match.

Fixes: #26817
2025-05-01 14:48:33 -04:00
Matthew Woehlke
9081e73104 CPS: Fix mangling of relative requirement names
CPS names look like `[package]:component`, which needs to get mangled
into `package::component` to match CMake's convention. This was
implemented correctly for fully qualified component requirements, but
relative names were not being properly mangled. Adjust handling of
relative names to correctly translate from CPS to CMake convention.
2025-04-30 11:56:09 -04:00
Brad King
f70aed86f1 Merge topic 'macos-curl-backend' into release-4.0
1e1129c6fe macOS: Reliably apply workaround for system curl 8.{3,4,5} LibreSSL backend

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10724
2025-04-30 09:39:48 -04:00
Gregor Jasny
1e1129c6fe macOS: Reliably apply workaround for system curl 8.{3,4,5} LibreSSL backend
In commit f2596dfa0e (macOS: Work around bug in system curl 8.{3,4,5}
LibreSSL backend, 2024-07-16, v3.30.1~2^2) we tried to prefer
`secure-transport` on problematic versions of curl.  However, the
`curl_global_sslset` setting must be applied before every
`curl_global_init` call, not just the first one.  Otherwise a
second (or subsequent) download won't apply the work-around.
2025-04-29 11:49:49 -04:00
Brad King
cd4e72ca08 Normalize PWD environment variable before using it
In commit 5aed3ee49d (cmSystemTools: Add GetLogicalWorkingDirectory,
2024-10-28, v4.0.0-rc1~528^2~6) we incorrectly trusted `PWD` to be a
normalized path so long as its realpath matches the current working
directory.

Fixes: #26870
2025-04-15 09:37:08 -04:00
Marc Chevrier
2e9648e0de Ninja generator: restore correct encoding for policy CMP0181=OLD
Fixes: #26857
2025-04-12 16:37:57 +02:00
Brad King
ee515b2aa8 CMake 4.0.1 2025-04-10 10:58:22 -04:00
Brad King
d736dafa22 Merge branch 'backport-3.31-apple-CoreFoundation-headers' 2025-04-08 11:39:10 -04:00
Sergey Fedorov
42390e7aa2 Source: Include specific CoreFoundation headers instead of umbrella header
Some CoreFoundation headers included by the umbrella header, which we do
not need, use syntax that GCC does not support.  Avoid including them.

GCC-Issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115880
2025-04-08 11:38:24 -04:00
Brad King
14ffd1cc4e cmXCodeObject: Drop unused CoreFoundation header
It has not been needed since commit d250b67722 (cmGlobalXCodeGenerator:
Adopt pbxproj object id generation, 2021-01-06, v3.19.3~4^2~2).
2025-04-08 11:38:23 -04:00
Brad King
f21682cf1a Merge topic 'normalize-input-paths' into release-4.0
5805461074 cmSystemTools: Simplify call to FindProgram for our own executable
db0e2574cb cmSystemTools: Restore FindProgram look-up of on-disk case on Windows
5d700abda4 Source: Simplify FindProgram calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10620
2025-04-08 10:45:45 -04:00
Brad King
5805461074 cmSystemTools: Simplify call to FindProgram for our own executable
Remove the unnecessary `FindProgramPath` wrapper.  Call the KWSys
`FindProgram` directly, without our CMake-specific wrapper, since
we follow-up with a `ToNormalizedPathOnDisk` anyway.
2025-04-07 19:57:07 -04:00
Brad King
db0e2574cb cmSystemTools: Restore FindProgram look-up of on-disk case on Windows
KWSys's `FindProgram` no longer looks up the actual case on disk.  This
behavior change was inherited from the change to `CollapseFullPath`.
Extend commit 773b75e4ed (cmake: Explicitly look up on-disk case of
input paths on Windows, 2024-10-23, v4.0.0-rc1~589^2) to cover this by
wrapping `FindProgram` in a CMake-specific layer.

Issue: #20214
2025-04-07 19:57:07 -04:00
Brad King
5d700abda4 Source: Simplify FindProgram calls
Remove defaulted arguments.  Remove unnecessary `.c_str()`.
2025-04-07 19:55:30 -04:00
Brad King
f183631ae3 Merge branch 'backport-3.31-apple-posix' into apple-posix 2025-04-07 15:57:25 -04:00
Sergey Fedorov
aa64d4482f macOS: Define _DARWIN_C_SOURCE in more sources
Restore Darwin APIs removed by `_POSIX_C_SOURCE`.
2025-04-07 15:56:36 -04:00
Brad King
3e4519a4e3 Merge topic 'find_package-cps-multiple-inclusion' into release-4.0
b498611902 find_package: Add minimal support for CPS multiple inclusion

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10581
2025-04-03 14:06:51 -04:00
Brad King
01f92efeb0 Restore expansion of leading '~' as home directory in input paths
This was accidentally dropped by commit 622596c6b2 (cmSystemTools:
Re-implement ToNormalizedPathOnDisk without translation map, 2024-10-30,
v4.0.0-rc1~528^2~5).  Previously it was done by `CollapseFullPath`.
`cm::PathResolver` intentionally does not expand `~` because it makes
sense only for transforming input paths.  Teach `ToNormalizedPathOnDisk`
to handle it directly.

Fixes: #26827
2025-04-02 14:41:48 -04:00
Matthew Woehlke
b498611902 find_package: Add minimal support for CPS multiple inclusion
Do not try to load a CPS file if we've already loaded the same file.
This only works if the current `find_package` call selects the same file
as the previous most recent call, and if the user has not meddled with
the `<name>_CONFIG` variable.

Issue: #26731
2025-04-02 13:45:36 -04:00
Brad King
7167236ba3 Merge topic 'find_package-fix-nested-calls' into release-4.0
37823b366f find_package: Restore component requirements in nested calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10576
2025-04-02 10:23:27 -04:00
Matthew Woehlke
37823b366f find_package: Restore component requirements in nested calls
Fix logic to populate required and optional components from CMake
variables when `find_package` is called in a nested context.

This was broken in commit e2a6416622 (find_package: Refactor in support
of recursion, 2024-11-29, v4.0.0-rc1~356^2), which promoted the
component sets from locals (in cmFindPackageCommand::InitialPass) to
member variables. Previously, in a nested context, these sets were
simply not filled, and we relied on the variables indicating component
requirement to already be set. When logic was added to properly fill the
sets (which is needed for CPS), it blindly dumped all components into
the required set, without actually checking whether the context had
marked the components as required or optional.

Fixes: #26824
2025-04-02 10:16:40 -04:00
Brad King
94d65a9535 get_filename_component: Restore lexical preprocessing of REALPATH for compat
Revert commit c554437733 (get_filename_component: Fix REALPATH for ..
after symlink, 2024-11-21, v4.0.0-rc1~411^2) because it changed existing
behavior without a policy.  Also add a test case for the old behavior.

Note that we have policy `CMP0152` to fix this for `file(REAL_PATH)`,
but it does not affect `get_filename_component(... REALPATH)`.  A new
policy would be needed for the latter.

Fixes: #26815
Issue: #26472
2025-04-01 09:45:03 -04:00
Brad King
f76a123f98 CMake 4.0.0 2025-03-27 10:29:51 -04:00
Brad King
0cd7adb881 CMake 4.0.0-rc5 2025-03-21 09:34:42 -04:00
Brad King
8214004200 Merge topic 'GNU-linker-pushpop_state-detection' into release-4.0
d5be7c7f31 Linker: Detect GNU push-state/pop-state flags more robustly
7b552b9a64 Linker: Save GNU push-/pop-state detection with compiler inspection results
a9b126b0da Linker: Save linker inspection results with compiler inspection results
3f5f2b2d49 Linker: Honor CMAKE_<LANG>_LINK_LIBRARY_USING_FEATURE_SUPPORTED when FALSE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10468
2025-03-21 08:07:13 -04:00
Marc Chevrier
a9b126b0da Linker: Save linker inspection results with compiler inspection results
Reconfigure `CMake<LANG>Compiler.cmake` again after linker information
is detected.
2025-03-20 11:00:02 -04:00
Marc Chevrier
3f5f2b2d49 Linker: Honor CMAKE_<LANG>_LINK_LIBRARY_USING_FEATURE_SUPPORTED when FALSE
It is documented to override `CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED`.
2025-03-20 10:59:01 -04:00
Martin Duffy
39f365ec3c instrumentation: Unique snippet file names
Updates the hash in snippet file naming to take the ProcessId into account
so that snippets with identical commands don't risk a collision in filename.

Additionally, this adds a `workingDir` to snippet files so that snippets with
identical commands can be more easily differentiated, such as with install
snippets.
2025-03-18 13:23:02 -04:00
Martin Duffy
d723409e8e export: Allow multiple exports when only one export is installed
Since commit c8997fc046 (export: Allow depending on targets exported
multiple times, 2024-12-26, v4.0.0-rc1~241^2), it is possible to depend
on a target exported multiple times so long as the target is exported in
only one set and with a consistent namespace.  However, as a
side-effect, a target could not be in multiple export sets even if only
one of those sets was installed.

Update the check so that uninstalled export sets do not count towards a
target being exported multiple times.
2025-03-17 18:01:30 -04:00
Brad King
df2ec408c9 Merge topic 'cps-fix-default-configs' into release-4.0
63c96e76f9 cmPackageInfoReader: Fix default configurations

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10469
2025-03-14 12:06:40 -04:00
Matthew Woehlke
63c96e76f9 cmPackageInfoReader: Fix default configurations
Fix two minor issues with how default configurations are set from CPS
packages. First, imported configurations were (appropriately) being
converted to upper case, but default configurations weren't. Second,
default configurations were being set only after importing components
from the root package configuration file, resulting in configurations
specified in the root file preceding the default configurations.
2025-03-13 14:27:58 -04:00
Brad King
41d91387f6 Merge branch 'backport-3.31-file-MAKE_DIRECTORY-result-var' 2025-03-13 11:58:47 -04:00
Brad King
397ec37528 file(MAKE_DIRECTORY): Do not make directories for command keywords
In commit 95323c90a1 (file(MAKE_DIRECTORY): Add optional RESULT keyword
to capture failure., 2024-06-16, v3.31.0-rc1~414^2) we computed an
updated range of arguments, that name directories to be created, before
the `RESULT` keyword.  However, we forgot to use it in the loop.

Fixes: #26768
2025-03-13 11:57:53 -04:00
Brad King
a039a1655d file(MAKE_DIRECTORY): Clarify formatting of unexpected arguments error 2025-03-13 11:57:27 -04:00
Brad King
90d9c79348 file(MAKE_DIRECTORY): Do not make directories for command keywords
In commit 95323c90a1 (file(MAKE_DIRECTORY): Add optional RESULT keyword
to capture failure., 2024-06-16, v3.31.0-rc1~414^2) we computed an
updated range of arguments, that name directories to be created, before
the `RESULT` keyword.  However, we forgot to use it in the loop.

Fixes: #26768
2025-03-13 11:57:25 -04:00
Brad King
f7f8fd59da CMake 4.0.0-rc4 2025-03-11 13:12:16 -04:00
Brad King
9a81fcb8b8 Merge topic 'realpath-windows' into release-4.0
0a5efe8489 cmSystemTools: Fix GetRealPath implementation on Windows
5910bf0b40 cmSystemTools: Restore GetRealPathResolvingWindowsSubst

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10452
2025-03-11 09:42:29 -04:00
Brad King
1150091f61 Merge topic 'curl-opt-netrc' into release-4.0
1b0c92a3a1 cmCurl: Avoid using undocumented type for CURLOPT_NETRC values

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10449
2025-03-11 09:22:43 -04:00
Brad King
0a5efe8489 cmSystemTools: Fix GetRealPath implementation on Windows
In commit 823e1df54c (cmSystemTools: Implement GetRealPath on Windows,
2024-11-04, v4.0.0-rc1~521^2~1) we implemented the POSIX behavior that
resolves symlinks followed by '..' components.  However, Windows just
removes them lexically.  Also, we were not handling all junction types.

Instead, use `GetFinalPathNameByHandleW` via `uv_fs_realpath`.

Note that we previously attempted this in commit 640709e7db
(cmSystemTools: Implement GetRealPath on Windows, 2017-10-02,
v3.11.0-rc1~445^2~1) but reverted it in commit 83630d4918
(cmSystemTools: Revert GetRealPath implementation on Windows,
2018-05-29, v3.11.3~3^2) due to resolving `subst` drives.  This time,
add code to re-`subst`itute the drive in the resolved path.

Fixes: #26750
Issue: #17206
2025-03-10 14:50:09 -04:00
Brad King
5910bf0b40 cmSystemTools: Restore GetRealPathResolvingWindowsSubst
We need it to restore behavior on Windows.  Revert commit 16af27fd42
(cmSystemTools: Drop GetRealPathResolvingWindowsSubst, 2024-11-04,
v4.0.0-rc1~521^2), but with a cleaned up implementation.

Issue: #26750
Issue: #18033
2025-03-10 11:25:23 -04:00
Brad King
1b0c92a3a1 cmCurl: Avoid using undocumented type for CURLOPT_NETRC values
Since upstream curl commit `2ec00372a1` (curl.h: change some enums to
defines with L suffix, 2025-02-25), the `CURL_NETRC_*` constants are
integer literals instead of `enum CURL_NETRC_OPTION`.  It turns out
that `curl_easy_setopt` has always expected a `long` anyway, and
that `CURL_NETRC_OPTION` is not documented for public use.

Fixes: #26754
2025-03-10 11:17:19 -04:00
Brad King
fc5584f9bb cmSystemTools: Fix regression in input path normalization on Windows
Since commit 622596c6b2 (cmSystemTools: Re-implement
ToNormalizedPathOnDisk without translation map, 2024-10-30,
v4.0.0-rc1~528^2~5) we normalize input paths, while resolving symlinks
only if followed by `..` components, by using `cm::PathResolver`'s
`LogicalPath` mode.  However, that approach assumes POSIX semantics for
resolving paths with symlinks and is incorrect on Windows.

On Windows, file system operations naively remove any component
preceding `..` regardless of whether it is a symlink.  Prior to the
above commit, `ToNormalizedPathOnDisk` matched that behavior using
`CollapseFullPath` followed by `GetActualCaseForPath`.  Restore it using
`cm::PathResolver`'s `CasePath` mode.

Issue: #26750
2025-03-07 18:26:14 -05:00
Brad King
8dfc725cdb PathResolver: Add mode to collapse paths naively and look up on-disk case
In CMake 3.31 and below, `CollapseFullPath` did this on Windows.  KWSys
has since stopped looking up the on-disk case in `CollapseFullPath` to
avoid disk access when most callers only need an in-memory operation.
We currently call `GetActualCaseForPath` explicitly when needed.

Add a mode to `cm::PathResolver` to combine these operations and cache
disk access behind the `System::ReadName` callback.  We will use this to
restore the way CMake 3.31 and below normalized input paths on Windows.

Issue: #26750
Issue: #20214
2025-03-07 18:22:46 -05:00
Brad King
75913fe430 PathResolver: Document in comments the on-disk case lookup on macOS
This was added by commit 08040ced86 (cmake: Look up on-disk case of
input paths on macOS, 2024-11-20, v4.0.0-rc1~390^2).  Update relevant
comments.
2025-03-07 18:14:57 -05:00
Brad King
f68bd58c9f Merge topic 'cmake-gui-incidental-errors' into release-3.31
e9c494005c cmake-gui: Fix regression that prints an incidental error on fresh build trees

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10429
2025-03-07 12:14:00 -05:00