summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Windows-MSVC.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Link step: Enable to configure deduplication of librariesMarc Chevrier2023-11-091-0/+2
| | | | | | | | | Some platforms, Apple or Windows for instance, do not require to duplicate static libraries to resolve mutual dependencies. Moreover, Xcode version 15 emits a warning if a library is duplicated. On Windows, enable a better control of libraries order. Fixes: #20722, #25297
* Add options to specify linker toolMarc Chevrier2023-10-131-0/+6
| | | | | | | | | | | | | | | | | | Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as the target property `LINKER_TYPE` to specify which linker must be used. The implementation of this capability is specified by variables specific to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`. Some definitions are provided as part of `CMake`. For example, to select the `LLVM` linker rather than the standard one, the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`. And, on `Apple`, `Linux` and some environments on `Windows`, the variable `CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows` environments based on `MSVC`, where the linker is used directly, the tool `lld-link.exe` will be used rather than `link.exe`. Fixes: #19174, #24254, #24990
* Windows: Add experimental WindowsKernelModeDriver platformKyle Edwards2023-07-171-2/+22
|
* MSVC: Add abstraction for debug information formatGlen Chung2022-09-141-2/+19
| | | | | | | | | | | | | | | | Replace our hard-coded default for `/Zi` with a first-class abstraction to select the debug information format an enumeration of logical names. We've long hesitated to do this because the idea of "debug information format" touches on related concepts on several platforms. Avoid that scope creep by simply defining an abstraction that applies only when targeting the MSVC ABI on Windows. Removing the old default flag requires a policy because existing projects may rely on string processing to edit them and choose a runtime library under the old behavior. Add policy CMP0141 to provide compatibility. Fixes: #10189
* MSVC: Revert "Default to -ZI instead of /Zi for x86 and x64"Brad King2022-06-091-7/+2
| | | | | | | | | | | | | | Revert commit 5fcadc481e (MSVC: Default to -ZI instead of /Zi for x86 and x64, 2022-05-24). The `-ZI` flag is incompatible with the `-GL` flag used for IPO, and so is not an unconditionally better default. Revert the change pending future design of a first-class setting for MSVC debug info format that can be automatically reconciled with IPO settings. That commit introduced policy CMP0138, but we already have later policy numbers used too. Leave placeholder text to avoid policy renumbering. Issue: #23607, #10189
* MSVC: Default to -ZI instead of /Zi for x86 and x64Glen Chung2022-05-261-2/+7
| | | | | | | | | | Add a policy for compatibility. For more information, see [1]. [1] https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=msvc-170 Fixes: #10189
* genex-LINK_LIBRARY: Add feature WHOLE_ARCHIVEMarc Chevrier2022-03-171-0/+9
|
* Merge topic 'cmcldeps-cross'Brad King2022-01-071-1/+1
|\ | | | | | | | | | | | | | | d49e168e1b Ninja: Do not use cmcldeps for RC on non-Windows hosts Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Dmitry Mikushin <dmitry@kernelgen.org> Merge-request: !6843
| * Ninja: Do not use cmcldeps for RC on non-Windows hostsMartin Storsjö2022-01-061-1/+1
| | | | | | | | | | | | | | | | The `cmcldeps` executable is only built on Windows. If running MSVC on a different OS (with various compatibility wrapping), don't try to use `cmcldeps`, as the executable doesn't exist. Fixes: #21760
* | MSVC: update arm64ec default flags and libmoyo19972022-01-061-1/+5
|/ | | | | | | | | | | | Update the support added by commit 4ea3a88625 (MSVC: Add support for targeting ARM64EC, 2020-12-30, v3.20.0-rc1~121^2). Add `softintrin.lib` to `CMAKE_C_STANDARD_LIBRARIES_INIT`. Remove `/D_ARM64EC_WORKAROUND` from the flags as it was only ever needed in preview versions of VS. Issue: #21724
* MSVC: Fix MSVC_TOOLSET_VERSION for VS 2022 v143 toolsetBrad King2021-09-021-1/+4
| | | | | | | | This was forgotten in commit 0c7f918fb1 (VS: Update Visual Studio 17 2022 generator for Preview 2, 2021-07-14, v3.21.1~29^2) when the toolset was first renumbered to `v143`. Fixes: #22585
* Per-language Win32/Console flagsRaul Tambre2021-03-171-4/+8
| | | | | | | | Allows using different compilers with different flags for different languages. For example Clang with GNU-like commandline for CXX and MSVC as host compiler for CUDA. Should help with #21914.
* MSVC: Add support for targeting ARM64ECMoyo Okeremi 😊2021-01-211-3/+15
|
* Ninja Generators: Homogenize configuration with MakefilesMarc Chevrier2020-12-011-2/+1
| | | | | * Use same configuration variables to configure dependencies * Abstract Ninja deps format from compiler one
* Makefiles Generators: use compiler for dependencies generationMarc Chevrier2020-11-291-0/+7
| | | | | | | | | | | Each source compilation generates a dependencies file. These dependencies files are consolidated in one file per target. This consolidation is done as part of command 'cmake -E cmake_depends` launched before evaluation of makefile dependency graph. The consolidation uses the same approach as `CMake` dependencies management. Fixes: #21321
* MSVC: Do not add /GR to CMAKE_CXX_FLAGS by defaultBrad King2020-11-131-1/+7
| | | | | | | | | | | | The `/GR` flag has been on by default since MSVC cl 14.0 from VS 2005. Remove it from the default flags to make it easier for projects to pass `/GR-` themselves to turn it off. Projects may be using string processing to replace `/GR` with another flag, so we cannot simply drop it. Add a policy to drop it in a compatible way. Fixes: #21428
* MSVC: Factor out initialization of /GR flagBrad King2020-11-131-4/+8
|
* Clang: Implement CMAKE_${LANG}_COMPILER_TARGET for all variants on windowsThomas Bernard2020-09-111-5/+0
| | | | Fixes: #21097
* clang-cl: Restore rules to create preprocessed and assembly outputBrad King2020-08-191-2/+2
| | | | | | In commit d993ebd4ca (clang-cl: Add '--' before source file, 2020-07-28) we accidentally replaced these rules with those to compile an object file.
* clang-cl: Add '--' before source fileThomas Bernard2020-08-071-0/+8
| | | | | | | On Linux and macOS, absolute paths start with `/` which may be interpreted by clang-cl as an option. To avoid this, we separate the source file path from preceding options with `--` to tell `clang-cl` it is not an option.
* Detect the correct target architecture for clang compilers.Thomas Bernard2020-07-281-0/+5
| | | | | | During compiler identification, if CMAKE_{C,CXX}_COMPILER_TARGET is defined, the corresponding clang target flag is used to guaranty proper target architecture detection.
* Merge topic 'pch-msvc-pragma'Brad King2020-05-121-7/+5
|\ | | | | | | | | | | | | 6c2514dabe MSVC: Use 'pragma system_header' in PCH only on cl 19.13 and above Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4736
| * MSVC: Use 'pragma system_header' in PCH only on cl 19.13 and aboveBrad King2020-05-111-7/+5
| | | | | | | | | | | | | | VS 2017 15.6 introduced support for this pragma. Older MSVC versions warn that it is unknown. Fixes: #20692
* | MSVC: Use 'lib' instead of 'link /lib' to create static librariesFrancisco Facioni2020-03-031-1/+1
| | | | | | | | | | | | `link.exe /lib` is an undocumented flag and it just calls `lib.exe`. Also `link.exe` doesn't parse the `/lib` option correctly when in a response file.
* | MSVC: Fixed missing import library for Windows 10 ARM64 (Desktop)shibayan2019-12-101-1/+1
|/ | | | | | Add the same import library as x86/x64 by default for Windows 10 ARM64 (Desktop, not UWP). Fixes: #20077
* Precompile Headers: Add REUSE_FROM signatureCristian Adam2019-09-171-3/+10
| | | | | | | Add the ability to share precompiled headers artifacts between targets. Fixes: #19659
* Precompile headers: Add methods to generate PCH sourcesCristian Adam2019-08-281-0/+9
| | | | Co-Author: Daniel Pfeifer <daniel@pfeifer-mail.de>
* Windows-MSVC.cmake: fix disabling of CMAKE_NINJA_CMCLDEPS_RCMarc-André Moreau2019-05-301-1/+3
|
* Modules: Consistently use 2 space indentationKitware Robot2019-05-141-1/+1
|
* MSVC: Do not add /W3 to CMAKE_<LANG>_FLAGS by defaultBrad King2019-04-191-2/+15
| | | | | | | | | | | | | | We do not add default warning flags on other compilers, and having a warning flag in the default flags makes it hard for projects to customize the warning level. They need to use string processing to remove `/W3` from `CMAKE_{C,CXX}_FLAGS`. Therefore we should drop it. However, projects may be using string processing to replace `/W3` with another flag, so we cannot simply drop it. Add a policy to drop it in a compatible way. Fixes: #18317
* MSVC: Add abstraction for runtime library selectionBrad King2019-04-171-8/+30
| | | | | | | | | | | | | | | | Replace our hard-coded defaults for `/MD` and `/MDd` with a first-class abstraction to select the runtime library from an enumeration of logical names. We've long hesitated to do this because the idea of "runtime library selection" touches on related concepts on several platforms. Avoid that scope creep by simply defining an abstraction that applies only when targeting the MSVC ABI on Windows. Removing the old default flags requires a policy because existing projects may rely on string processing to edit them and choose a runtime library under the old behavior. Add policy CMP0091 to provide compatibility. Fixes: #19108
* Merge topic 'vs2019-redist'Brad King2019-04-041-1/+4
|\ | | | | | | | | | | | | | | 33ee779330 IRSL: Fix discovery of VS 2019 v142 toolset redistributables d8cf8380fb MSVC: Fix MSVC_TOOLSET_VERSION for VS 2019 v142 toolset Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3186
| * MSVC: Fix MSVC_TOOLSET_VERSION for VS 2019 v142 toolsetBrad King2019-04-031-1/+4
| | | | | | | | | | | | | | | | This was forgotten in commit 626c51f47b (VS: Update for Visual Studio 2019 Preview 2, 2019-01-24, v3.14.0-rc1~74^2) when the toolset was first renumbered to `v142`. Issue: #19125
* | MSVC: Use -D instead of /D in RC_FLAGSZsolt Parragi2019-03-011-2/+4
|/ | | | llvm-rc can't handle definitions given with /D and without a space.
* MSVC: Respect CMAKE_RC_COMPILER and CMAKE_MT in vs_link_{dll,exe}Mateusz Zych2018-10-291-2/+2
| | | | | | | | | | | | CMake commands vs_link_dll and vs_link_exe, performing linking on MSVC, are responsible for calling resource compiler and manifest tool. Before this commit, both of these tools were called directly, with the expectation that they are available in the `PATH`. This has been fixed by respecting CMake variables `CMAKE_RC_COMPILER` and `CMAKE_MT` defining paths to these tools. Fixes: #17804
* MSVC: Factor out enable_language(RC) call into helper macroBrad King2018-10-291-1/+4
| | | | This will be useful to call from elsewhere later.
* MSVC: Add MSVC_TOOLSET_VERSION variableArkady Shapkin2018-04-041-0/+25
| | | | | | Provide the MSVC toolset version number based on the compiler version. Fixes: #16923
* MSVC,Clang,Flang: Add IPO supportxoviat2018-02-231-0/+28
| | | | Fixes: #17692
* MSVC: Fix MSVC_VERSION when mixing MSVC C/C++ with Intel FortranBrad King2017-11-151-1/+5
| | | | | | | | When using a real MSVC compiler for `C` or `CXX`, use the version of that compiler for `MSVC_VERSION`. This is preferred over the MSVC version that a non-MSVC compiler "simulates". Fixes: #17468
* Merge topic 'MsvcArm64'Brad King2017-09-131-3/+9
|\ | | | | | | | | | | | | bc7c94fe MSVC: Add support for ARM64 architecture Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1215
| * MSVC: Add support for ARM64 architectureMinmin Gong2017-09-121-3/+9
| | | | | | | | | | | | Visual Studio 15.4 adds support for this architecture. Fixes: #17213
* | VS: Update support for LLVM-vs* toolsets from LLVM 5.0Konstantin Ivlev2017-09-111-2/+2
|/ | | | | | | | | Revert commit v3.7.0-rc1~25^2 (VS: Recognize VS/LLVM toolset names as Clang, 2016-09-28). Since at least LLVM 5.0 the VS integration of the LLVM toolchain now mimics cl and accepts MSVC-style command-line arguments (unlike Microsoft Clang/C2). Fixes: #17193, #17235
* Use string(APPEND) in ModulesDaniel Pfeifer2017-05-171-2/+2
| | | | | | | Automate with: find Modules -type f -print0 | xargs -0 perl -i -0pe \ 's/set\(([a-zA-Z0-9_\$\{\}]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
* MSVC: Restore _DEBUG preprocessor definition in RC debug buildsBrad King2017-03-281-0/+3
| | | | | | | | | | | | | | | | | | In commit v3.8.0-rc1~304^2 (MSVC: Do not define _DEBUG explicitly when using /MDd, 2016-11-15) we removed the `_DEBUG` preprocessor definition from MSVC C and C++ flags because the `cl` compiler automatically defines it in Debug builds anyway. However, the VS generators propagate C preprocessor definitions to the RC (Windows Resource Compiler) tool. This means that we used to explicitly define `_DEBUG` for RC debug builds. Therefore existing project code may expect the definition to be there even though the `rc` compiler itself does not implicitly define `_DEBUG` in debug builds. Add the `_DEBUG` flag to the default `CMAKE_RC_FLAGS_DEBUG` instead to restore this definition for RC debug builds. This also makes it available consistently in VS, Ninja, and Makefile generators. Fixes: #16745
* MSVC: Exclude future cl 20+ from MSVC14 variableBrad King2017-03-221-1/+3
|
* CUDA: Detect MSVC architecture idBrad King2017-01-121-0/+2
|
* MSVC: Do not define _DEBUG explicitly when using /MDdBrad King2016-11-151-2/+2
| | | | | | | | With the latter flag the compiler automatically defines `_DEBUG`: https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx Closes: #16430
* Merge topic 'vs-clang-llvm-support'Brad King2016-09-291-2/+2
|\ | | | | | | | | 3f300b84 VS: Recognize VS/LLVM toolset names as Clang
| * VS: Recognize VS/LLVM toolset names as ClangRoman Wüger2016-09-281-2/+2
| | | | | | | | | | | | Update the toolset name matching added by commit v3.6.0-rc1~279^2~10 (VS: in Clang/C2 toolset, setup correct compiler settings, 2016-02-18) to match VS/LLVM toolset names too.
* | Simplify CMake per-source license noticesBrad King2016-09-271-12/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.