Commit Graph

1027 Commits

Author SHA1 Message Date
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
Brad King
f2e52b3124 Merge topic 'vs-cuda'
a9210a0c02 VS: Restore support for CUDA with no optimization flags

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robertjmaynard@gmail.com>
Merge-request: !9666
2024-07-18 08:57:48 -04:00
Brad King
a9210a0c02 VS: Restore support for CUDA with no optimization flags
Since commit 67de5b7b82 (VS: Suppress MSBuild default settings affected
by UseDebugLibraries, 2024-02-13, v3.30.0-rc1~538^2~1) we generate an
empty `Optimization` element for the host compiler when there are no C
or C++ optimization flags enabled.  The CUDA Toolkit Visual Studio
integration fails with an error if an empty string is inherited from the
host compiler's `Optimization` element.  If no CUDA optimization flags
are specified, write an explicit empty `Optimization` element for the
CUDA compiler too.

Fixes: #26144
2024-07-17 11:42:31 -04:00
Brad King
d3088a8eea Merge topic 'vs-dotnet-sdk-custom-command'
c7e5ebd0a8 VS: Support add_custom_command in .Net SDK-style projects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9616
2024-07-08 10:17:28 -04:00
Calum Robinson
0721f9bf0f VS: Add VS_FRAMEWORK_REFERENCES
Fixes: #26082
2024-06-26 16:44:51 +01:00
Calum Robinson
c7e5ebd0a8 VS: Support add_custom_command in .Net SDK-style projects
Fixes: #26048
2024-06-25 13:31:44 +01:00
Brad King
f0b40d451e Merge topic 'vs-filter-props'
56a96d1f1f VS: Add option to import .props in .vcxproj.filters files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9478
2024-05-02 09:43:17 -04:00
Brad King
718f43e7ee Merge topic 'vs-scan-module-deps-settings'
3022f0363f VS: set ScanSourceForModuleDependencies at vcxproj level
dff511ad28 cmGeneratorTarget: add a target-level query for "needs dyndep"

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: AaronRuizMoraUK <aaronruizmora@gmail.com>
Merge-request: !9471
2024-05-02 09:40:04 -04:00
halx99
56a96d1f1f VS: Add option to import .props in .vcxproj.filters files
Adds new target property VS_FILTER_PROPS

Fixes: #25948
2024-05-02 00:30:00 +08:00
Ben Boeckel
3022f0363f VS: set ScanSourceForModuleDependencies at vcxproj level
Implement the target-wide `CXX_SCAN_FOR_MODULES`/`CMP0155` selection
with the `.vcxproj`-wide `ScanSourceForModuleDependencies` setting.
Set the per-source equivalent only when needed for a per-source
`CXX_SCAN_FOR_MODULES` property.

This approach enables Intellisense for interfaces imported from modules.
It is also more consistent with what a user might expect when
investigating the state of module scanning from the VS property panels.

Fixes: #25806
Fixes: #25947
2024-05-01 09:54:50 -04:00
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Brad King
721d8b192a VS: Add UseDebugLibraries to vcxproj files by default
Use heuristics to select a reasonable value.  Add policy CMP0162
to provide compatibility with existing projects.

Fixes: #25327
2024-02-22 08:43:16 -05:00
Brad King
47136b6959 VS: Suppress more MSBuild defaults affected by UseDebugLibraries
Extend commit 67de5b7b82 (VS: Suppress MSBuild default settings affected
by UseDebugLibraries, 2024-02-13) to cover a `Microsoft.Cl.Common.props`
default from VS 2015 and older.
2024-02-22 08:42:58 -05:00
Brad King
f498032141 cmVisualStudioGeneratorOptions: Rename {IsDebug => UsingDebugInfo}
The latter name is more precise.
2024-02-20 10:48:31 -05:00
Brad King
b814641444 VS: Add [CMAKE_]VS_USE_DEBUG_LIBRARIES options to control UseDebugLibraries
This indicates to MSBuild which configurations are considered debug
configurations.  This is useful for reference both by humans and tools.

Issue: #25327
2024-02-19 10:40:41 -05:00
Brad King
67de5b7b82 VS: Suppress MSBuild default settings affected by UseDebugLibraries
`Microsoft.Cl.Common.props` changes some default settings based on
`UseDebugLibraries`.  CMake models its own controls for these settings,
so if the project does not set them, explicitly suppress them to avoid
letting `UseDebugLibraries` affect them.
2024-02-19 10:40:40 -05:00
Brad King
0ae372daee VS: Factor out common MS tool configuration
De-duplicate code writing `PlatformToolset`.
2024-02-19 10:40:40 -05:00