1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-21 20:11:22 +08:00

492 Commits

Author SHA1 Message Date
Brad King
c2f79c9867 Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language.  By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags.  Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`COMPILE_DEFINITIONS` to match the selected language.

This is not exactly the same as for other generators, but is the best VS
and Xcode can do.  It is also sufficient for many use cases since the
set of definitions for C and C++ is frequently similar but may be
distinct from those for other languages like CUDA.

Issue: #17435
2018-01-12 14:27:37 -05:00
Brad King
0795d25b78 cmVisualStudio10TargetGenerator: Factor out include dir computation 2018-01-11 15:03:02 -05:00
Vitaly Stakhovsky
d09af94619 VS: Modernize 'for' loops in cmVisualStudio10TargetGenerator to C++11
'auto' used for complex types
2017-12-21 14:55:30 -05:00
Brad King
4bc5c08476 Merge topic 'per-source-COMPILE_LANGUAGE-genex-support'
10f58b27 Genex: Per-source $<COMPILE_LANGUAGE:...> support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1575
2017-12-14 08:21:52 -05:00
Marc Chevrier
10f58b27ac Genex: Per-source $<COMPILE_LANGUAGE:...> support
Fixes: #17542
2017-12-13 16:35:22 +01:00
Vitaly Stakhovsky
c62ffdcd4f cmIDEOptions: use std::string instead of const char*
Revise method signatures to save a few c_str() conversions.
2017-12-08 22:30:16 -05:00
Marc Chevrier
9432f686e6 Add generator expression support to per-source COMPILE_DEFINITIONS
This allows users to specify different genex-based compile definitions for each file in a target.

Fixes: #17508
2017-12-05 14:47:39 +01:00
Brad King
729dda5420 Merge topic 'src-genex-refactoring'
6bffc13e Refactor per-source generator expression evaluation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1550
2017-12-05 08:15:40 -05:00
Brad King
21541bb5cc Use CM_FALLTHROUGH in Windows-specific code
Some cases were missed by earlier sweeps due to not compiling
Windows-specific code.
2017-12-04 10:58:15 -05:00
Marc Chevrier
6bffc13ef1 Refactor per-source generator expression evaluation
Prepare to add generator expression support to more source properties.
Factor out some duplicated code into a helper to avoid further
duplication.
2017-12-04 09:10:09 -05:00
Michael Stürmer
8e654a3785 VS: Enable generation of CSharp projects without initial .cs files
fixes #17388
2017-11-29 18:06:08 +01:00
Brad King
f26009dde6 VS: Order .vcxproj.filters files deterministically
Sort source groups by name rather than arbitrary pointer values.

Fixes: #17446
2017-11-15 10:52:33 -05:00
Brad King
c871446abc cmSourceGroup: Return strings from GetName and GetFullName 2017-11-15 10:47:07 -05:00
Yoshinori Tahara
15892aa3c0 VS: Fix warnings in generated references to '.settings' files
According to MSDN docs [1], LastGenOutput is just a file name.

[1] https://msdn.microsoft.com/en-us/library/bb629388.aspx
2017-11-09 11:48:38 -05:00
Jeremiah van Oosten
025221df2a VS: Add source file property to set hlsl debug and optimization flags
Add `VS_SHADER_DISABLE_OPTIMIZATIONS` and `VS_SHADER_ENABLE_DEBUG`
source file properties to control these settings on `.hlsl` files in the
VS generator.

Fixes: #17406
2017-10-30 09:52:10 -04:00
Matthias Maennich
57132765e0 Replace cmArray{Begin,End,Size} by their standard counterparts
std::{begin,end} are part of C++11, std::{cbegin,cend} are part of C++14
and an standard compliant implementation has been introduced within the
'cm' namespace: cm::{cbegin,cend}.

std::size is only part of C++17, hence exposing a compliant implementation
within namespace cm (cm::size).

where possible, the standard implementations are reused.
2017-10-23 17:51:35 +02:00
Brad King
344d149ae4 VS,Xcode: Add CMakeLists.txt sources without mutating targets
Rather than injecting `CMakeLists.txt` files into each target's
`SOURCES`, teach the generators to add them during generation using
dedicated code.  This avoids mutating the original targets, and avoids
polluting `$<TARGET_PROPERTY:foo,SOURCES>` with generator-specific
content.

This also avoids listing the `CMakeLists.txt` sources in the results of
`CMAKE_DEBUG_TARGET_PROPERTIES==SOURCES` so the `RunCMake.TargetSources`
test no longer needs a separate case for IDEs.
2017-10-18 14:24:07 -04:00
Brad King
fd90a14f1b VS: Set CUDA TargetMachinePlatform explicitly on x64
The `TargetMachinePlatform` setting tells CUDA what `--machine {32,64}`
flag to pass to nvcc.  While CUDA automatically chooses the proper
default for the target architecture, it does not reflect this in the
user-visible IDE settings.  Set it explicitly to fix the user-visible
setting.

Fixes: #17355
2017-10-17 10:41:41 -04:00
Brad King
44d0e377f9 Merge topic 'vs-no-empty-link-version'
0b419b99 VS: Do not emit empty linker Version tag

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1332
2017-10-04 07:07:50 -04:00
Vitaly Stakhovsky
0b419b998d VS: Do not emit empty linker Version tag
This empty element does nothing, so simply remove it to simplify
generated `.vcxproj` files.
2017-10-03 08:27:46 -04:00
Brad King
303cd7037a VS,Xcode: Fix TARGET_PROPERTY genex in source COMPILE_FLAGS property
This already worked in other generators.  Also add a test case.

Fixes: #17314
2017-10-03 08:03:33 -04:00
Brad King
59285ee58e Merge topic 'add-vs-shader-properties'
49dab3eb VS: Add VS_SHADER_OUTPUT_HEADER_FILE and VS_SHADER_VARIABLE_NAME properties.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1319
2017-09-29 08:56:04 -04:00
Kevin M. Godby
49dab3ebfb VS: Add VS_SHADER_OUTPUT_HEADER_FILE and VS_SHADER_VARIABLE_NAME properties.
The VS_SHADER_OUTPUT_HEADER_FILE property is the name of the generated
header file containing the object code of the shader.

The VS_SHADER_VARIABLE_NAME property is the name of the variable
containing the object code in the above header file.

Signed-off-by: Kevin M. Godby <kevin@godby.org>
2017-09-27 07:56:09 -04:00
Matthias Maennich
f0489856e3 Retire std::auto_ptr and its macro CM_AUTO_PTR
Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-26 00:07:19 +02:00
Pavel Solodovnikov
37d9387be3 Replace empty-string comparisons with checking against empty(). 2017-09-21 11:23:19 +03:00
Brad King
7c28081c14 Merge topic 'string-clear'
5db3aac1 Meta: replace empty-string assignments with `clear()`.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1276
2017-09-19 08:27:00 -04:00
Brad King
8fee054eca Merge topic 'vs-manifestuac-flag-map'
3232f84c VS: Fix MANIFESTUAC link flag map to .vcxproj elements

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !526
2017-09-19 08:25:22 -04:00
comicfans
3232f84c19 VS: Fix MANIFESTUAC link flag map to .vcxproj elements
Add special parsing of the flags given in `/MANIFESTUAC:"..."` in order
to map them correctly to `.vcxproj` elements.

Keep the old incorrect flag table entries for `uiAccess` and `level`
flags for compatibility even though they do not really exist.

Fixes: #16563
2017-09-18 11:53:22 -04:00
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +03:00
Brad King
7315a46c83 Merge topic 'MsvcArm64'
bc7c94fe MSVC: Add support for ARM64 architecture

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1215
2017-09-13 08:37:02 -04:00
Minmin Gong
bc7c94fe13 MSVC: Add support for ARM64 architecture
Visual Studio 15.4 adds support for this architecture.

Fixes: #17213
2017-09-12 09:54:29 -04:00
Brad King
3ea87bce69 Merge topic 'vs-clang-llvm-support'
8a4755ca VS: Update support for LLVM-vs* toolsets from LLVM 5.0

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1231
2017-09-12 09:39:40 -04:00
Konstantin Ivlev
8a4755ca57 VS: Update support for LLVM-vs* toolsets from LLVM 5.0
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
2017-09-11 09:58:22 -04:00
Brad King
28adf3833c Merge topic 'vs_improve_custom_command'
9ed24280 VS: only add custom command line if it is not empty
34c4108b add HasOnlyEmptyCommandLines() method to cmCustomCommandGenerator

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1050
2017-09-11 07:53:18 -04:00
Brad King
94e70e5329 Merge branch 'backport-vs-csharp-ref-no-asm' into vs-csharp-ref-no-asm 2017-09-05 09:42:16 -04:00
Michael Stürmer
7e57e6ae12 VS: Do not reference output assemblies if not possible for CSharp target
Since commit v3.9.0-rc4~4^2 (Vs: allow CSharp targets to be linked to
CXX targets, 2017-06-20) CSharp targets get `ProjectReference` entries
to their dependencies.  This causes VS to also reference the
dependency's output assembly by default, which is incorrect for
non-managed targets.

Fix this by setting `ReferenceOutputAssembly` to `false` for targets
that can't provide output assemblies.  Unmanaged C++ targets (shared
libs & executables) can still be referenced and a warning will be shown
in the IDE but the build will not break anymore.

Fixes: #17172
2017-09-05 09:41:40 -04:00
Michael Stürmer
9ed2428078 VS: only add custom command line if it is not empty 2017-09-04 11:42:35 +02:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Brad King
ebe436eb97 Merge topic 'cxx11-nullptr'
5962db43 Use C++11 nullptr

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1175
2017-08-25 11:26:24 -04:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Roc Ramon
efd0c01337 VS: Fix VS_SDK_REFERENCES when target is not a Windows 10 app
Close the `<ItemGroup>` element whenever it is opened.
2017-08-23 15:43:46 -04:00
Vitaly Stakhovsky
79064819a6 VS: remove unnecessary c_str() 2017-08-17 14:41:01 -04:00
Michael Stürmer
21ee3309b2 VS: print comment in CSharp target only if it is actually set 2017-07-12 15:45:28 +02:00
Brad King
a9b88ffdfc Merge topic 'vs-link-debug-flags'
7ba27e36 VS: Add v140 and v141 flag table entries for /DEBUG:NONE and /DEBUG:FULL
ae44496e VS: Fix GenerateDebugInformation values for v140 and v141 toolsets
27bef160 VS: Fix GenerateDebugInformation flag map text for v141 toolsets
17a397c2 VS: Split link flag table between v140 and v141 toolsets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1002
2017-06-29 09:49:01 -04:00
Brad King
ae44496e2b VS: Fix GenerateDebugInformation values for v140 and v141 toolsets
When VS 2015 was first released, its new v140 toolset came with a
`link.xml` file that changed the `GenerateDebugInformation` boolean
(`false` and `true`) value from earlier toolsets to an enumeration
consisting of the possible values `No`, `Debug`, and `DebugFastLink`.

We first adapted to this in commit v3.4.2~2^2 (VS: Fix VS 2015 .vcxproj
file value for GenerateDebugInformation, 2016-01-08), but that broke
older toolsets that still expected the boolean.  Then commit
v3.6.0-rc1~295^2~1 (VS: Fix VS 2015 .vcxproj debug setting for older
toolsets, 2016-02-24) added a hack to fix up the value based on the
toolset in use.  Several follow-up commits fixed this for more older
toolsets because our flag table was at the time based on the generator
in use rather than the toolset in use.

Since commit v3.8.0-rc1~396^2 (VS: Choose flag map based on the toolset
name, 2016-10-17) we use a flag table based on the toolset, so the fixup
hack should not be needed.  We had to keep it around only due to our
default value for GenerateDebugInformation (`false` or `No`) still being
based on the generator instead of the toolset.

A VS 2015 update was released that changed the v140 toolset `link.xml`
file back to using `false` and `true` for the `GenerateDebugInformation`
enumeration variants previously known as `No` and `Debug`.  In order to
know which pair to use, we need to parse the `link.xml` file for the
current toolset.

Switch back to using `false` and `true` unconditionally in our
`GenerateDebugInformation` flag table entries and default value.  With
that plus the toolset-based flag table, we now get incorrect values for
`GenerateDebugInformation` only when using a v140 toolset from an older
VS 2015 installation.  Detect this case by parsing `link.xml` and add
special logic to convert `false` and `true` to `No` and `Debug` to
satisfy the older toolset specification.

Inspired-by: Ian Hojnicki <nullref@live.com>
Fixes: #17020
2017-06-28 08:55:40 -04:00
Brad King
126effbb9c Merge topic 'vs_csharp_custom_command'
ec409a11 Vs: fix CSharp custom command by introducing inline MSBuild <Targets>s
dcdab5cf Vs: factor out computation of <Link> tag for CSharp source files
0a8f469a Vs: refactor WriteCustomRule for preparation of CSharp support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !970
2017-06-27 09:21:38 -04:00
Brad King
dc11a20d7b Merge topic 'vs-cuda-fix-flags'
bbc1f364 VS: Fix support for nvcc flags not in our flag table

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1007
2017-06-27 09:18:34 -04:00
Brad King
1d86103846 Merge branch 'vs-cuda-fix-flags' into release-3.9 2017-06-27 09:14:26 -04:00
Brad King
bbc1f3642c VS: Fix support for nvcc flags not in our flag table
The change in commit v3.9.0-rc4~3^2 (VS: Improve workaround for CUDA
-Xcompiler placement bug, 2017-06-21) accidentally appended to the
`AdditionalOptions` as if it were a `;`-separated list, but it is
actually a command-line string.  Append with a space instead.

While at it, fix the same problem for the `AdditionalOptions` added to
`CudaLink` by commit v3.9.0-rc3~1^2 (CUDA: When linking device code
suppress CUDA 8.0+ deprecation warnings, 2017-06-09).

Fixes: #17008
2017-06-27 09:08:50 -04:00
Michael Stürmer
ec409a116f Vs: fix CSharp custom command by introducing inline MSBuild <Targets>s
The custom command implementation is based on the Microsoft support article:

https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-extend-the-visual-studio-build-process

Fixes: #16960
2017-06-22 21:40:48 +02:00