1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-18 01:38:44 +08:00

791 Commits

Author SHA1 Message Date
Kyle Edwards
3ef0c40962 WIN32_EXECUTABLE: Add support for generator expressions 2020-08-21 09:17:27 -04:00
Brad King
4391913133 Add INTERFACE libraries to generated buildsystem if they have SOURCES
INTERFACE libraries were created with the intention of collecting usage
requirements for use by other targets via `target_link_libraries`.
Therefore they were not allowed to have SOURCES and were not included in
the generated buildsystem.  In practice, this has become limiting:

* Header-only libraries do have sources, they just do not compile.
  Developers should be able to edit those sources (the header files)
  in their IDE.

* Header-only libraries may need to generate some of their header
  files via custom commands.

Some projects work around these limitations by pairing each interface
library with an `add_custom_target` that makes the header files and
custom commands appear in the generated buildsystem and in IDEs.

Lift such limitations by allowing INTERFACE libraries to have SOURCES.
For those with sources, add a corresponding build target to the
generated buildsystem.

Fixes: #19145
2020-08-07 08:46:32 -04:00
Brad King
261a2585d9 Merge topic 'cleanup-target-types'
ef796cc743 cmGeneratorTarget: Skip computing link implementation for custom targets
45158b2afe cmGeneratorTarget: Simplify logic in ComputeLinkInterfaceLibraries
d6b1f5704e cmGeneratorTarget: Add missing nullptr checks
7695b67500 cmComputeTargetDepends: Add missing nullptr check
95b5df8646 cmGeneratorTarget: Skip computing languages for custom targets
2f0790df50 Factor out generator checks for filtering on non-compiling targets
422d9a0ab2 Factor out generator checks for filtering out interface libraries
bce82df0aa cmGeneratorTarget: Remove unnecessary target type check in dependency tracing
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kyle Edwards <kyle.edwards@kitware.com>
Merge-request: !5038
2020-07-28 08:26:23 -04:00
Brad King
422d9a0ab2 Factor out generator checks for filtering out interface libraries
Add a `cmGeneratorTarget::IsInBuildSystem` helper method to tell
generators whether a target should participate in the generated build
system.
2020-07-23 13:31:44 -04:00
Brad King
a33a4ec68b Merge branch 'backport-vs-lang-flags' into vs-lang-flags 2020-07-23 10:58:11 -04:00
Brad King
c4109a1bc8 VS: Restore toleration of target-wide -TP flag with MSVC
Since commit 3b547e2e4b (VS: Simplify logic adding source file C/C++
language flag to MSVC, 2020-05-15, v3.18.0-rc1~139^2~1) we only add a
per-source language selection flag when the source file extension does
not match the compiler's default.  This approach breaks when a project
adds a target-wide `-TP` flag.

Although such projects likely did not work with non-VS generators, we
did support them before in Visual Studio generators.  Add a special case
to tolerate such flags again.

Fixes: #21005
2020-07-23 10:54:35 -04:00
Jean-Christophe Fillion-Robin
207373802e Fix typos identified using codespell
See https://github.com/codespell-project/codespell#readme

The following command was used:

```
codespell -q6 --skip="\
.git,\
*.json,\
./Copyright.txt,\
./Help/command/foreach.rst,\
./Help/prop_test/REQUIRED_FILES.rst,\
./Help/variable/CTEST_COVERAGE_COMMAND.rst,\
./Modules/CMakeCheckCompilerFlagCommonPatterns.cmake,\
./Modules/CMakeRCInformation.cmake,\
./Modules/Internal/CPack/NSIS.template.in,\
./Modules/FindMatlab.cmake,\
./Modules/MatlabTestsRedirect.cmake,\
./Modules/Platform/Windows-Clang.cmake,\
./Modules/Platform/Windows-Intel-Fortran.cmake,\
./Modules/Platform/Windows-MSVC.cmake,\
./Source/CMakeVersion.cmake,\
./Source/cmConvertMSBuildXMLToJSON.py,\
./Source/cmCreateTestSourceList.cxx,\
./Source/cmGlobalVisualStudio10Generator.cxx,\
./Source/cmExportBuildFileGenerator.cxx,\
./Source/cmExportInstallAndroidMKGenerator.cxx,\
./Source/cmExportInstallFileGenerator.cxx,\
./Source/cmExportSet.cxx,\
./Source/cmExportTryCompileFileGenerator.cxx,\
./Source/cmFindPackageCommand.cxx,\
./Source/cmInstallCommand.cxx,\
./Source/cmGeneratorExpressionLexer.cxx,\
./Source/cmLocalVisualStudio7Generator.cxx,\
./Source/cmOrderDirectories.cxx,\
./Source/cmTarget.cxx,\
./Source/kwsys/*,\
./Source/QtDialog/CMakeSetupDialog.ui,\
./Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx,\
./Source/CTest/cmParseCoberturaCoverage.h,\
./Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in,\
./Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf,\
./Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt,\
./Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt,\
./Tests/RunCMake/GoogleTest/xml_output.cpp,\
./Tests/RunCMake/Make/TargetMessages*,\
./Utilities/*,\
" \
-L "\
dependees,\
endwhile,\
fo,\
filetest,\
helpfull,\
nd,\
objext,\
stoll,\
supercedes,\
superceded,\
vas,\
varn,\
"
```
2020-07-22 12:44:47 -04:00
Vitaly Stakhovsky
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string 2020-07-14 15:18:59 -04:00
Robert Maynard
7a969fe21d cmMakefile: Refactor API to better handle empty config values 2020-07-03 07:43:18 -04:00
Rahul Gottipati
27b03281e2 configure_file: Add option to control file permissions transfer to copy
Issue: #20866
2020-06-30 11:20:41 -04:00
Brad King
ab83a21933 Merge topic 'visual-studio-android'
6051a49c78 Visual Studio: Add Android support
bbcaf9689e Refactor: Add IsAndroidGuiExecutable() method to cmTarget
14456923bd cmGlobalVisualStudio10Generator: Move variable initialization to header
d5b5c19278 cmGlobalGenerator: FindMakeProgram() before CMakeDetermineSystem

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4898
2020-06-26 09:35:31 -04:00
Kyle Edwards
6051a49c78 Visual Studio: Add Android support 2020-06-24 08:41:09 -04:00
Robert Maynard
c4cc21d20b cmVisualStudio10TargetGenerator: Do not segfault on empty config
The VS generator should error out earlier when no configurations
are specified, but for now cover this symptom.
2020-06-24 08:38:02 -04:00
Kyle Edwards
bbcaf9689e Refactor: Add IsAndroidGuiExecutable() method to cmTarget 2020-06-18 15:35:26 -04:00
Brad King
5c04e77e07 VS: Restore compilation of '.C' sources as C++
Refactoring in commit 3b547e2e4b (VS: Simplify logic adding source file
C/C++ language flag to MSVC, 2020-05-15, v3.18.0-rc1~139^2~1) failed to
account for MSVC's treatment of `.C` extensions as C.  Add this special
case to the logic to restore use of `-TP` for `.C` extensions.

Fixes: #20822
2020-06-11 14:15:18 -04:00
Justin Goshi
e219527a72 VS: Use StdOutEncoding for VS 16.7 Preview 3 and above
VS 16.6 added a `StdOutEncoding` setting for custom commands to tell
MSBuild that the output is encoded as UTF-8.  In commit bc877a7e94 (Add
support to indicate UTF-8 custom command pipe output encoding,
2020-04-08) CMake learned to add the setting in anticipation of the VS
16.6 release.  However, when 16.6 was released it had a bug in the
implementation of custom tasks with StdOutEncoding enabled that was
exposed by our test suite.  In commit 5058fb5401 (VS: Drop
StdOutEncoding with VS 16.6 pending investigation, 2020-05-29) we
disabled the setting pending investigation.

The problem is fixed in VS 16.7 Preview 3, so restore use of the
setting when a VS instance of at least that version is detected.

Fixes: #20769
2020-06-03 09:00:41 -04:00
Brad King
5058fb5401 VS: Drop StdOutEncoding with VS 16.6 pending investigation
The `StdOutEncoding` added to `.vcxproj` files since commit bc877a7e94
(Add support to indicate UTF-8 custom command pipe output encoding,
2020-04-08) breaks custom commands with symbolic outputs on VS 16.6.0.
Disable it pending further investigation and possibly a fix in VS.

Issue: #20769
2020-05-29 08:24:14 -04:00
Brad King
5c7ca6f8a8 CUDA: Move VS CudaRuntime selection to be with rest of CUDA options 2020-05-22 08:15:37 -04:00
Brad King
3b547e2e4b VS: Simplify logic adding source file C/C++ language flag to MSVC
Do not add a target-wide language flag.  We need a flag on an individual
source file to explicitly specify the C or C++ language if and only if
the source file extension does not imply it.
2020-05-18 15:34:17 -04:00
Brad King
27ead9d4b7 VS: Compute managed type from an existing configuration
It is not clear how multiple configurations should be handled here, but
using an existing configuration is at least better than the empty
configuration.
2020-05-18 15:34:15 -04:00
Brad King
1222327c89 VS: Write custom commands for sources from all configurations 2020-05-18 15:33:16 -04:00
Brad King
65fe58a4b4 cmVisualStudio10TargetGenerator: Adopt Windows Store and Phone infrastructure
Move support for Resx, Xaml, Certificate, and AppManifest file handling
out of cmGeneratorTarget.
2020-05-18 12:56:56 -04:00
Brad King
eb2a554b12 Merge topic 'vs-pch-compile-opts'
6b2fb4ffd2 VS: Fix using PCH from source with COMPILE_OPTIONS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4734
2020-05-12 06:53:41 -04:00
Brad King
6b2fb4ffd2 VS: Fix using PCH from source with COMPILE_OPTIONS
If a source file gets per-source flags from both PCH and custom
`COMPILE_OPTIONS`, combine them correctly.

Fixes: #20694, #20456
2020-05-11 11:58:41 -04:00
Vitaly Stakhovsky
53675adbcf GetSafeProperty: return std::string const& 2020-04-30 10:27:16 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -04:00
Julien Jemine
197b4cbe18 VS: Add option for per-target PlatformToolset
Add a `VS_PLATFORM_TOOLSET` target property to set `PlatformToolset` in
the `.vcxproj` file for specific targets.  Document that this is safe
only when the named toolset uses the same underlying compiler as the
primary toolset.

Fixes: #17429
2020-04-29 07:35:57 -04:00
Marc Chevrier
4248bb452a CUDA: Device linking use now link options
properties LINK_OPTIONS and INTERFACE_LINK_OPTIONS are propagated
to the device link step.

To control which options are selected for normal link and device link steps,
the $<DEVICE_LINK> and $<HOST_LINK> generator expressions can be used.

Fixes: #18265
2020-04-19 15:53:11 +02:00
Marc Chevrier
aacd4e4a90 Refactoring: add cm::contains to <cmext/algorithm> 2020-04-17 10:00:03 +02:00
Brad King
156196938c Merge topic 'cmprop-source'
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp
fc223f9860 cmGlobalXCodeGenerator: Fix genex interpreter overloads

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4603
2020-04-15 09:49:46 -04:00
Vitaly Stakhovsky
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp 2020-04-14 10:57:17 -04:00
Justin Goshi
bc877a7e94 Add support to indicate UTF-8 custom command pipe output encoding
Adds a flag to indicate that pipe output from a custom command should be
interpreted as UTF-8 encoded. This change does not introduce a public
way to set the flag, but generators that create internally-generated
commands know if they are calling cmake, which uses UTF-8 pipes.

MSBuild added support for interpreting output of PreBuildEvent,
PreLinkEvent, PostBuildEvent, and CustomBuildStep as UTF-8. This change
will appear in Visual Studio 16.6 Preview 3. It is opt-in, and you need
to add the StdOutEncoding tag. MSBuild treats these as property bags so
if we emit the tag for earlier versions of Visual Studio it would be
safely ignored. This change emits the StdOutEncoding tag and sets it to
UTF-8 whenever the custom command UTF-8 pipe flag is set. This fixes
globalization issues when the output from cmake contained characters
that required MSBuild to interpret as UTF-8 before displaying them.
2020-04-13 12:54:47 -07:00
Brad King
25a920e827 cmLocalGenerator: Convert GetStaticLibraryFlags to take original-case config
Move upper-case conversion of the configuration into the implementation.
2020-04-01 10:55:59 -04:00
Vitaly Stakhovsky
3eec21a01c cmTarget::GetProperty: return cmProp 2020-03-30 15:00:14 -04:00
Brad King
ad22d0c1d0 Merge topic 'vs-non-built-file-item-metadata'
0723e04f7a VS: Add documentation for VS_SETTINGS and VS_SOURCE_SETTINGS_<tool>.
2ca1102f83 VS: Test VS_SETTINGS and VS_SOURCE_SETTINGS_<tool> properties.
f00e1b816d VS: Add VS_SOURCE_SETTINGS_<tool> target property
2ce42f281f VS: Add VS_SETTINGS source file property
53116d3942 VS: Use unordered_map to write HLSL settings.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4498
2020-03-30 13:28:19 -04:00
Rolf Eike Beer
94de927cab VS10Generator: avoid many string allocations 2020-03-24 17:50:42 +01:00
Rolf Eike Beer
48adc29721 replace "std::string::find(x) == 0" with cmHasPrefix() 2020-03-23 22:41:43 +01:00
Matt Davies
f00e1b816d VS: Add VS_SOURCE_SETTINGS_<tool> target property
VS_SOURCE_SETTINGS_<tool> is a list of key value pairs that get written as item
metadata for any file associated with <tool> for that target. The entire value
of VS_SOURCE_SETTINGS_<tool> is evaluated as a generator expression. VS_SETTINGS
can override settings specified in this property.
2020-03-20 16:16:58 +00:00
Matt Davies
2ce42f281f VS: Add VS_SETTINGS source file property
VS_SETTINGS is a list of key value pairs that get written as item
metadata for the associated non-built file. The entire value of
VS_SETTINGS is evaluated as a generator expression.
2020-03-20 16:16:58 +00:00
Matt Davies
53116d3942 VS: Use unordered_map to write HLSL settings. 2020-03-20 16:16:44 +00:00
Vitaly Stakhovsky
60f57d0dcc cmPropertyMap: Introduce cmProp as return type for GetProperty() functions
Currently properties are usually stored internally as `std::string`.
However, family of GetProperty() functions return them as `const char *` using `c_str()`.
The proposed `cmProp`, typedef'ed as `const std::string *` will expose properties
more naturally.
2020-03-13 13:32:17 -04:00
Kinan Mahdi
ac6b18cd90 CSharp: Add support for source groups with out-of-source builds
This also fixes support for multiple sources of the same name in
different directories.  Add a test for both problems.

Issue: #19505
2020-02-28 11:42:01 -05:00
Brad King
8752c1bd64 Merge branch 'backport-3.16-link-line-backtrace' 2020-02-10 16:17:03 -05:00
Brad King
e756328434 Propagate backtraces from LINK_LIBRARIES through to link line items
Since commit d4d0dd0f6a (cmLinkLineComputer: Add ComputeLinkLibs
overload with backtraces, 2019-09-13, v3.16.0-rc1~87^2~4), backtraces
have been collected by `ComputeLinkLibs` by looking back through the
link implementation libraries for one matching the text of the link line
item.  This is slow in projects with long link lines.

Instead, teach `cmComputeLinkDepends` and `cmComputeLinkInformation` to
carry backtrace information explicitly along with the text of each item.

Fixes: #20322
2020-02-10 16:11:38 -05:00
Brad King
4b1a6a4722 Merge topic 'vs-version-for-unity' into release-3.16
9135954e2f VS: Do not use native unity builds on VS 2017 versions less than 15.8

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4324
2020-02-05 08:33:50 -05:00
Brad King
4b062c77b3 Merge topic 'vs-version-for-unity'
9135954e2f VS: Do not use native unity builds on VS 2017 versions less than 15.8

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4324
2020-02-05 08:33:50 -05:00
Brad King
9135954e2f VS: Do not use native unity builds on VS 2017 versions less than 15.8
VS 2017 version 15.8 introduced support for unity builds implemented
in part by the `$(VCTargetsPath)/Microsoft.Cpp.Unity.targets` file.
Do not enable unity builds on VS 15 versions that do not have that file.

Fixes: #20284
2020-02-04 11:46:18 -05:00
Brad King
f972b929d6 Merge topic 'vs-16.4-custom-command-inputs' into release-3.16
58b0674687 VS: Tell VS 16.4 not to verify SYMBOLIC custom command inputs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4297
2020-01-29 10:36:40 -05:00
Brad King
92f04d3790 Merge topic 'vs-16.4-custom-command-inputs'
58b0674687 VS: Tell VS 16.4 not to verify SYMBOLIC custom command inputs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4297
2020-01-29 10:36:40 -05:00
Brad King
58b0674687 VS: Tell VS 16.4 not to verify SYMBOLIC custom command inputs
Extend the fix from commit 0578239d3a (VS: Tell VS 16.4 not to verify
SYMBOLIC custom command outputs, 2019-09-23, v3.15.4~2^2) to apply to
SYMBOLIC *inputs* too.  This is needed when there is a chain of custom
commands that use symbolic paths for ordering.

Fixes: #20179
2020-01-28 13:52:05 -05:00