Commit Graph
1072 Commits
Author SHA1 Message Date
Tom Osika 72ae7352d5 get_property: Refactor logic to shared function 2026-08-10 17:29:13 -04:00
Brad King 697df9a12a Merge topic 'vs-clangcl-modules'
027b962a81 VS: Avoid unsupported ScanSourceForModuleDependencies under ClangCl

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Vito Gamberini <vito.gamberini@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !12301
2026-07-22 09:55:45 -04:00
Tyler Yankee 027b962a81 VS: Avoid unsupported ScanSourceForModuleDependencies under ClangCl
As of commit ed48feeae8 (clang-cl: Add support for C++ modules,
2026-03-27, v4.4.0-rc1~428^2) CMake tries to support modules for
clang-cl, which can mostly be accomplished, except for the ClangCl VS
toolset, where the /scanDependencies flag is not yet supported.

Amend commit 3022f0363f (VS: set ScanSourceForModuleDependencies at
vcxproj level, 2024-04-27, v3.28.5~3^2) to only emit this setting when
scanning is supported by the toolchain.

Fixes: #27957
Issue: #27977
2026-07-21 17:02:29 -04:00
Matthew Woehlke a5a9ec9113 TargetTypes: Extract target-related types to dedicated header
Move some target related enumeration types from `cmStateTypes.h` to a
new header, as these really aren't "state" types. Also, make
`TargetType` a strongly-typed enumeration.
2026-07-01 14:44:11 -04:00
Marc Chevrier 6043014d1d source_group(): Add file set support 2026-06-23 14:55:26 +02:00
Marc Chevrier c06d409f12 FILE_SET: add SKIP_PRECOMPILE_HEADERS property support 2026-06-01 18:39:23 +02:00
Marc Chevrier 7d892786d8 FILE_SET: manage unity build exclusions based on file set type
This complements commit 5f7a7aa263 (FILE_SET: add SKIP_UNITY_BUILD_INCLUSION property support, 2026-05-11)
2026-05-21 15:23:43 +02:00
Marc Chevrier 5f7a7aa263 FILE_SET: add SKIP_UNITY_BUILD_INCLUSION property support 2026-05-14 10:55:35 -04:00
Brad King ac04c630e9 Merge topic 'vs-fortran'
ec06d16178 cmSourceGroup: Constify clients
f513867bc4 VS: Fix regression causing source accumulation across Fortran projects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11999
2026-05-04 10:10:10 -04:00
Brad King ec06d16178 cmSourceGroup: Constify clients
The generators do not need to modify the groups.
2026-05-01 10:43:32 -04:00
Matthew Woehlke 1309532390 Diagnostics: Use new methods
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
2026-04-16 15:10:35 -04:00
Marc Chevrier 5c5b68f44e FILE_SET: Add support for the SOURCES type
Fixes: #27550
2026-03-31 09:49:59 +02:00
Tyler Yankee 858fdd426b add_custom_command: Disallow exe-suffixed targets in DEPENDS
Two targets whose names differ only in a `.exe` suffix create a
conflict when adding target- and file-level dependencies for a custom
command. Add CMP0212 to provide compatibility with the old behavior.

Issue: #27612
2026-03-23 09:50:46 -04:00
Baudouin Feildel 881faf67e5 Rust: Switch to building .rs files to .rlib instead of native object files
Each Rust source file given to a target is considered a separate crate
root. There's a concept of a "main crate root", which is the `.rs` file
that is given to the final linker phase in CMake. Other Rust source file
in a target are built as rlib separately.

The project can still build `.rs` files into object files by setting the
Rust_EMIT property on the desired source file.
2026-03-20 09:42:44 -04:00
Marc Chevrier dee8799d16 FileSet management: Introduce dedicated classes for generation
To manage the generation step, introduce cmGeneratorFileSet and
cmGeneratorFileSets classes.
These reorganizations of the code are done in preparation of the
implementation of SOURCES file set type as well as user's file set types.

Issues: #27550, #27383
2026-02-19 17:35:56 +01:00
Marc Chevrier c4c84ae0f7 cmFileSet: Enhance type management
Type management is now dynamic to ensure future support of user's types.
2026-02-19 17:03:45 +01:00
John Franklin Rickard 9daa1012d4 cmGlobalGenerator: Avoid string copies by returning view 2026-02-06 12:27:23 -05:00
John Franklin Rickard c3c3b10d60 cmGlobalGenerator: Change parameter to string_view 2026-02-06 12:27:12 -05:00
Brad King 8fc452fc2f Merge topic 'vs-no-dupe-object-filename'
e4f6701ad4 cmVisualStudio10TargetGenerator: use language extension for objects
3b9cd510d7 cmVisualStudio10TargetGenerator: only write a single object filename

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11654
2026-02-05 13:54:05 -05:00
Ben Boeckel e4f6701ad4 cmVisualStudio10TargetGenerator: use language extension for objects
See: #27552
2026-02-04 12:07:53 -05:00
Ben Boeckel 3b9cd510d7 cmVisualStudio10TargetGenerator: only write a single object filename
Fixes: #27552
2026-02-04 12:07:53 -05:00
Tyler YankeeandBrad King 98f9874703 cmake: Add per-language link flags for all target types
Previously, `CMAKE_<LANG>_LINK_FLAGS` was an undocumented variable used
for linking executables only. Re-spell that variable mirroring the
existing spellings for shared and module libraries, and add policy
CMP0210 to preserve compatibility.

Then, repurpose `CMAKE_<LANG>_LINK_FLAGS` to provide a variable to be
used for per-language link flags for all target types, along with a
per-configuration variant. These are added to the `<LINK_FLAGS>` rule
placeholder in the generators.

Fixes: #21934
Relates: #25620

Co-authored-by: Brad King <brad.king@kitware.com>
2026-01-31 19:37:09 -05:00
Tyler Yankee bc1847c70b cmLocalGenerator: De-duplicate target property link flags lookup 2026-01-29 15:30:55 -05:00
Tyler Yankee 33a1fc5693 cmLocalGenerator: De-duplicate linker flags lookup 2026-01-29 15:30:44 -05:00
Brad King 57d544f1af Merge topic 'vs-charset'
4419bf1182 VS: Restore unicode character set for custom targrets on WindowsStore

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11578
2026-01-09 09:48:20 -05:00
Brad King 4419bf1182 VS: Restore unicode character set for custom targrets on WindowsStore
Restore conditions broken by commit 19a61e56cf (VS: Refactor MSVC
character set selection, 2025-10-10, v4.2.0-rc1~12^2~1).  We had misread
the purpose/scope of the `<= cmStateEnums::OBJECT_LIBRARY` condition.
In the original code it was only about safely indexing `ClOptions`,
not about the kinds of targets that can use a unicode character set.

Fixes: #27490
2026-01-08 11:46:11 -05:00
Brad King 756c0757b2 Merge topic 'vs-link-defaults'
46e59b5168 Merge branch 'backport-vs-link-defaults' into vs-link-defaults
b6defd96c9 VS: Restore subsystem link flag for DLLs
91b9db90e5 VS: Restore subsystem link flag for DLLs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex Overchenko <aleksandr9809@gmail.com>
Merge-request: !11524
2025-12-18 10:30:20 -05:00
Brad King b6defd96c9 VS: Restore subsystem link flag for DLLs
In commit 99d09ec45a (VS: Suppress MSBuild default link flags not
specified by project or user, 2025-06-17, v4.1.0-rc1~6^2) we removed our
default `-subsystem:...` link flag from `SHARED` and `MODULE` libraries
in Visual Studio generators for consistency with command-line generators.
However, unlike other flag suppressions for #27004, this change did not
just suppress MSBuild defaults, but actually changed flags the generator
was previously adding itself.

For the linker subsystem flag, consistency across generators should
perhaps achieved by adding the flag in other generators instead of
removing it from Visual Studio generators.  Restore the previous
behavior pending further investigation.

Issue: #27466
Fixes: #27464
2025-12-17 17:41:36 -05:00
Brad King 9c7a261d78 Merge topic 'vs2019-v142'
8c332a3c7f VS: Restore support for VS 2019 with toolset v142 versions before 14.29

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11480
2025-12-08 09:58:57 -05:00
Brad King 7d113b9b84 Merge topic 'vs2019-v142' into release-4.2
8c332a3c7f VS: Restore support for VS 2019 with toolset v142 versions before 14.29

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11480
2025-12-08 09:58:55 -05:00
Brad King 8c332a3c7f VS: Restore support for VS 2019 with toolset v142 versions before 14.29
Since commit 7db3dbddb2 (VS: Suppress MSBuild default flags not
specified by project or user, 2025-06-02, v4.1.0-rc1~69^2) we suppress
the `-Zc:inline` default flag when the project/user does not specify it.
That triggers an apparent bug in VS 2019 with v142 toolset versions
before 14.29 in which MSBuild fails when both `-Zc:inline` and `-nologo`
are suppressed.  This happens when `CMAKE_VERBOSE_MAKEFILE` is enabled,
such as in `try_compile` projects like our builtin compiler inspection.

Since `-nologo` is incidental, avoid suppressing it if `-Zc:inline` is
also suppressed.  Limit this workaround to relevant toolset versions.

Fixes: #27439
2025-12-05 12:47:53 -05:00
Cristiano Carvalheiro a46491d0d3 cmLocalGenerator: Improve performance of source group lookups
Introduce an index from source file to source group in
`cmLocalGenerator` to make lookups significantly more efficient
during the source group generation, which could be particularly
slow when dealing with thousands of source files.
Falls back to the recursive lookup when the source file is not present
on the index, which is more likely to happen when dealing with
regex-based sources.

Fixes: #27359
2025-11-26 20:32:19 +00:00
Cristiano Carvalheiro caf6e782e1 cmSourceGroup: Move FindSourceGroup out of cmMakefile 2025-11-26 18:16:05 +00:00
Cristiano Carvalheiro de2afc5d53 cmMakeFile: Remove source groups argument from FindSourceGroup 2025-11-26 17:39:02 +00:00
Brad King c185998420 VS/CUDA: Forward unknown flags to the host compiler when possible
Extend commit 7f15c99851 (CUDA: forward unknown flags to host compiler
when possible, 2019-11-29, v3.17.0-rc1~326^2~1) to work in VS too.

Fixes: #27210
2025-11-13 18:50:26 -05:00
Ben Boeckel 799bf33c5a VS: do not create ProgramDataBaseFileName entries without a filepath
The logic in commit f78f592b78 (pchreuse: defer target existence
enforcement to generation time, 2025-06-16, v4.2.0-rc1~481^2~4) caused
generator targets to always respond with something for compilation PDB
files. This may be a directory as the flag supports it (the then
compiler chooses the filename). However, one caller was expecting it to
always be a path to a file in order to specify the
`ProgramDataBaseFileName` element. However, this usage cannot be a
directory.

In addition to not having a PDB path at all, also verify that it is not
a path to a directory before creating the `ProgramDataBaseFileName`
element.

This was observed in builds using `import std` in Debug mode.

Fixes: #27320
2025-10-24 17:18:36 -04:00
Brad King 614d295c1e VS: Compute MSVC character set in CUDA-only targets
Fix commit 6874efb592 (MSVC: Always define a character set, 2025-09-24)
for CUDA in Visual Studio.
2025-10-10 17:07:36 -04:00
Brad King 19a61e56cf VS: Refactor MSVC character set selection 2025-10-10 16:55:02 -04:00
AJIOB 83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
Visual Studio defines this automatically for `.dll` targets.
For consistency, define it when compiling for the MSVC ABI
with other generators.  Add policy CMP0203 for compatibility.

Fixes: #27253
2025-09-29 18:26:44 -04:00
Brad King d5d02f80c0 Merge topic 'msvc-flags-fix-for-27177'
9851ddfc11 VS: Check all default suppressed MSBuild flags
7202539fd4 VS: Suppress MSBuild default flags not specified by project or user

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11165
2025-09-12 11:43:16 -04:00
AJIOB 7202539fd4 VS: Suppress MSBuild default flags not specified by project or user 2025-09-11 13:59:19 +03:00
Ben Boeckel 9ef99353cb prop_sf/OBJECT_NAME: support custom object names
Projects which ship object files as artifacts may want to control the
object names as much as possible. Support setting explicit object names
as source file properties to support such use cases.
2025-09-09 09:58:07 -04:00
Brad King d1be722330 Merge topic 'issue-24923-new-cli-tools'
8797912e4d cmake -E: Add copy_if_newer and copy_directory_if_newer

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10957
2025-08-01 11:13:56 -04:00
Benjamin Buch 8797912e4d cmake -E: Add copy_if_newer and copy_directory_if_newer
Fixes: #24923
2025-07-31 10:55:59 +02:00
John Parent f97d1bf7d8 Visual Studio: support shortened object filenames 2025-07-29 09:44:03 -04:00
Yonggang LuoandBrad King 9a720d96eb clang-cl: Add support for C23
Although there is no `cl -std:c23` flag, the underlying Clang compiler
does have a C23 mode we can activate by passing `-std=c23` through a
`clang-cl` wrapper flag.

Also port the fix from commit 30139913e9 (VS: Restore support for mixing
C++23 and C in one target with clang-cl, 2024-12-09, v3.31.3~10^2).

Fixes: #27038
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Co-authored-by: Brad King <brad.king@kitware.com>
2025-07-01 11:20:56 -04:00
AJIOB 99d09ec45a VS: Suppress MSBuild default link flags not specified by project or user
MSBuild adds some `link` flags by default, but for CMake they may not
match what's produced by command-line generators.  If these flags are
not specified by the project or user, suppress them.

Fixes: #27004
2025-06-17 14:12:43 -04:00
Brad King 7db3dbddb2 VS: Suppress MSBuild default flags not specified by project or user
`Microsoft.Cl.Common.props` adds some `cl` flags by default, but for
CMake they may not match what's produced by command-line generators.
If the `-Zc:wchar_t`, `-Zc:forScope`, and/or `-Zc:inline` flags are
not specified by the project or user, suppress them.

Fixes: #26964
2025-06-02 14:59:38 -04:00
Ben Boeckel b82a74d918 generators: use GetSupportDirectory() in more places 2025-05-23 11:39:53 +02:00
Ben Boeckel 23779057fd cmStrCat: combine neighboring arguments where possible
Found using the `cmstrcat-adjacent-literals` rule for `ast-grep`.
2025-05-15 19:11:41 +02:00