Commit Graph

1043 Commits

Author SHA1 Message Date
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
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 Luo
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
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Nikita Nemkin
e5fd973b14 VS: Set the linker image version using the target's VERSION property
This matches the behavior of NMake, Ninja and older Visual Studio
generators.

Fixes: #13130
2025-02-11 17:36:34 +05:00
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Leonid Pospelov
3e88e9b4b3 VS: DOTNET_SDK support for VS_PROJECT_IMPORT target property
Closes: #25119
Issue: #23190
2025-01-08 11:48:24 -05:00
Brad King
85f4fdc000 Merge topic 'debugger-working-directory'
0a9fb88121 fileapi: Report DEBUGGER_WORKING_DIRECTORY in codemodel-v2 target objects
9ed178f9d8 Add generator-agnostic DEBUGGER_WORKING_DIRECTORY target property
200efab4d4 Tests/RunCMake/FileAPI: Improve error on unexpected line numbers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10075
2024-12-11 09:47:03 -05:00
Brad King
27be881b3f Merge topic 'vs-clang-cl-c++23'
30139913e9 VS: Restore support for mixing C++23 and C in one target with clang-cl
57da8712c1 VS: Factor out check for mixed C and C++ target

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10082
2024-12-10 09:12:04 -05:00
Brad King
30139913e9 VS: Restore support for mixing C++23 and C in one target with clang-cl
Since commit 474eafe28c (clang-cl: Add support for C++23, 2024-09-13,
v3.31.0-rc1~97^2) we use a Clang-specific flag to enable C++23 since
`clang-cl` has no `-std:c++23` flag, and `-std:c++latest` may enable an
even newer version of C++.  However, in `.vcxproj` files there is no way
to express a target-wide `-clang:-std=c++23` flag for only C++ sources
when the target also has C sources.  Add a special case to map back to
`-std:c++latest` for targets with C++23 and C together.

Fixes: #26508
2024-12-09 14:57:35 -05:00
Brad King
57da8712c1 VS: Factor out check for mixed C and C++ target 2024-12-09 14:19:51 -05:00
Garrett Campbell
9ed178f9d8 Add generator-agnostic DEBUGGER_WORKING_DIRECTORY target property
Generalize the `VS_DEBUGGER_WORKING_DIRECTORY` property.

Issue: #16478
2024-12-09 10:47:10 -05:00
Joseph Snyder
2709f07b4d VS: Add minimal support for Windows Kernel Mode Drivers
Extend the experimental support for `WindowsKernelModeDriver` to the
Visual Studio generators.  Hard-code some settings for now.
2024-12-03 14:18:52 -05:00
Brad King
fec276e632 cmVisualStudio10TargetGenerator: Use inline member initialization 2024-12-03 09:43:26 -05:00
Marc Chevrier
7907c83175 Link step: Add LINK_WARNING_AS_ERROR target property
Add a way to specify, in a portable way, to raise an error for any
warning during the link step. For that purpose, define:
* CMAKE_LINK_WARNING_AS_ERROR variable
* LINK_WARNING_AS_ERROR target property

Fixes: #25343
2024-11-12 15:11:53 +01:00
Brad King
8353e6ab8d Merge topic 'vs-custom-command-disable-parallel-build'
4ee8705b12 VS: add source property VS_CUSTOM_COMMAND_DISABLE_PARALLEL_BUILD

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9958
2024-11-07 10:07:03 -05:00
Darragh Coy
4ee8705b12 VS: add source property VS_CUSTOM_COMMAND_DISABLE_PARALLEL_BUILD
This boolean setting allows parallel building to be disabled for
individual source files built via `add_custom_command`. Using this
option is equivalent to setting policy `CMP0147` to the `OLD` behavior.

Closes: #26413
2024-11-06 13:29:57 -05:00
Marc Chevrier
2bd4c06c26 Refactoring cmRulePlaceHolderExpander: propagate cmBuildStep information 2024-11-04 17:08:02 +01:00
Marc Chevrier
35350c419d Add support of "LINKER:" prefix for CMAKE_<TYPE>_LINKER_FLAGS variable
The following variables now support the LINKER: prefix:
* CMAKE_<TYPE>_LINKER_FLAGS
* CMAKE_<TYPE>_LINKER_FLAGS_<CONFIG>

Fixes: #26171
2024-11-04 17:07:58 +01:00
Darragh Coy
55831faf5b VS: Honor VS_TOOL_OVERRIDE for known source file types too
Visual Studio Generator: The `VS_TOOL_OVERRIDE` source file property
would previously only be respected for file types that CMake didn't know
how to build out of the box. This change allows the user to override how
any source file is built with a custom build tool, even ones with
standard/recognized extensions such as `.cxx`, `.idl`, etc.

Fixes: #26336
2024-10-01 14:00:00 -04:00
Calum Robinson
55a5094f0e VS: Fix missing <Configurations> property for DOTNET_SDK
Fixes #26325
2024-09-25 16:20:12 +01:00
Calum Robinson
fd66818653 VS: Fix custom commands for DOTNET_SDK builds
Fixes: #23723
2024-09-18 18:26:27 +01:00
Brad King
d68ca050ef Merge topic 'vs-always-restore-net-sdk'
3283ef47d1 VS: Fix DOTNET_SDK builds when no VS_PACKAGE_REFERENCES set

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9807
2024-09-18 09:40:03 -04:00
Calum Robinson
3283ef47d1 VS: Fix DOTNET_SDK builds when no VS_PACKAGE_REFERENCES set
nuget restore always needs to be run for the new DOTNET_SDK style
projects, even when VS_PACKAGE_REFERENCES is empty.

Fixes: #23405
2024-09-16 13:32:19 +01:00
Calum Robinson
66bd326e28 VS: Use OUTPUT_NAME in DOTNET_SDK projects
Fixes: #26285
2024-09-11 12:25:08 +01:00
Brad King
e25f95c4cc Merge topic 'standard-link-directories'
20e9b59d5e Linking: Add CMAKE_LANG_STANDARD_LINK_DIRECTORIES

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9707
2024-08-29 08:31:17 -04:00
Vito Gamberini
20e9b59d5e Linking: Add CMAKE_LANG_STANDARD_LINK_DIRECTORIES
Closes: #18222
2024-08-28 15:54:43 -04:00
Brad King
241f923a6f Drop Visual Studio 12 2013 generator
This generator has been deprecated since CMake 3.28.  Remove it.
2024-08-28 14:13:05 -04:00
Vitaly Stakhovsky
58da4aa47d Source: Avoid comparing pointers to nullptr 2024-08-27 10:56:38 -04:00
Brad King
88e90fcd20 Merge topic 'cuda_unity'
b90ae10dda Add support for unity builds with CUDA sources
c99ff40b21 Unity: refactor unity extension logic to single function

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9655
2024-08-13 11:01:13 -04:00
Robert Maynard
b90ae10dda Add support for unity builds with CUDA sources
Fixes #22750
2024-08-02 13:35:53 -04:00
Patrick H
373b29bd3f Rename {_ => }CMAKE_INCLUDE_SYSTEM_FLAG_${lang}_WARNING
Although not documented publicly, projects may need to override
this variable.  Remove the private `_` prefix from its name.

Issue: #25103
2024-07-29 11:50:02 -04:00