1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-18 09:48:41 +08:00

666 Commits

Author SHA1 Message Date
Brad King
f10682b796 Merge topic 'ispc_lang_support'
5ece12b7e4 gitlab-ci: add ISPC to the Fedora CI image
8976817d6d ISPC: Update help documentation to include ISPC
2368f46ba4 ISPC: Support building with the MSVC toolchain
e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds
34cc6acc81 Add ISPC compiler support to CMake
419d70d490 Refactor some swift only logic to be re-used by other languages

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5065
2020-09-01 09:15:39 -04:00
Robert Maynard
e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds 2020-08-28 11:21:31 -04:00
Kyle Edwards
3ef0c40962 WIN32_EXECUTABLE: Add support for generator expressions 2020-08-21 09:17:27 -04:00
Kyle Edwards
2e42651dff Add option to optimize link dependencies for static libraries
Add an `OPTIMIZE_DEPENDENCIES` target property and supporting
`CMAKE_OPTIMIZE_DEPENDENCIES` variable to optionally enable pruning and
flattening of outgoing dependencies from static libraries.  Since they
do not actually link, they only depend on side effects of their
dependencies.  Therefore we can drop dependencies that contribute no
side effects.
2020-08-12 11:31:07 -04:00
Brad King
9a27e803d4 Merge topic 'osx-archs-apple-only'
70ce1ad64a PCH: Avoid Apple-specific architecture flags on other platforms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5118
2020-08-11 08:54:15 -04:00
Brad King
70ce1ad64a PCH: Avoid Apple-specific architecture flags on other platforms
Since commit f593b354da (PCH: Add support for multi architecture iOS
projects, 2020-04-02, v3.18.0-rc1~414^2) the `OSX_ARCHITECTURES` target
property (and corresponding `CMAKE_OSX_ARCHITECTURES` variable) affects
flags on non-Apple platforms by accident.  Add a missing condition to
avoid this.

Fixes: #21072
2020-08-10 13:29:29 -04:00
Robert Maynard
419d70d490 Refactor some swift only logic to be re-used by other languages
The logic in AddSwiftInterfaceIncludeDirectories is something
that other languages will want going forward
2020-08-07 12:35:20 -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
afb998704e Remove filtering of allowed INTERFACE library properties
Previously we disallowed use of arbitrary properties on INTERFACE
libraries.  The goal was to future-proof projects using them by not
allowing properties to be set that may affect their future inclusion in
the generated buildsystem.  In order to prepare to actually include
INTERFACE libraries in the generated buildsystem, drop the filter and
allow arbitrary properties to be set.

Issue: #19145
2020-08-03 10:04:23 -04:00
Vitaly Stakhovsky
f37c14e930 Source: use cmNonempty() 2020-07-28 08:31:31 -04:00
Brad King
ef796cc743 cmGeneratorTarget: Skip computing link implementation for custom targets
Targets created by `add_custom_target` cannot be used with
`target_link_libraries` and so have no link implementation.
2020-07-27 10:26:07 -04:00
Brad King
45158b2afe cmGeneratorTarget: Simplify logic in ComputeLinkInterfaceLibraries
Also check the result of `GetLinkImplementationLibrariesInternal`
before using it.
2020-07-23 13:31:45 -04:00
Brad King
d6b1f5704e cmGeneratorTarget: Add missing nullptr checks
Check the result of `GetLinkImplementationLibraries` before using it.
2020-07-23 13:31:45 -04:00
Brad King
95b5df8646 cmGeneratorTarget: Skip computing languages for custom targets
Targets created by `add_custom_target` do not compile any sources
and therefore have no languages.
2020-07-23 13:31:45 -04:00
Brad King
2f0790df50 Factor out generator checks for filtering on non-compiling targets
Add a `cmGeneratorTarget::CanCompileSources` helper method to tell
generators whether a target might compile anything.
2020-07-23 13:31:45 -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
bce82df0aa cmGeneratorTarget: Remove unnecessary target type check in dependency tracing
Since commit 2600e923a6 (Disallow INTERFACE libraries with
add_custom_command(TARGET)., 2014-03-19, v3.0.0-rc3~1^2), we do not
trace dependencies of INTERFACE libraries that do not participate in the
build system.  Therefore we can remove a check of the target type from
the implementation that had been added by commit 9db9c1fc8b (cmTarget:
Don't try to get sources of an INTERFACE_LIBRARY., 2014-02-14,
v3.0.0-rc1~20^2).
2020-07-23 13:31:16 -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
Brad King
beb78ada5e Merge topic 'swift-link-iface'
14a5712447 Swift: Fix regression in linking to interface libraries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5027
2020-07-20 09:56:07 -04:00
Brad King
14a5712447 Swift: Fix regression in linking to interface libraries
Since commit 2026915f8f (Swift: Propagate Swift_MODULE_DIRECTORY as include
directory, 2020-02-03, v3.18.0-rc1~547^2) we internally call
`GetAllConfigCompileLanguages` on all directly linked targets without
checking if they are interface libraries that don't compile at all.
That violates an internal assumption and assertion.

Fixes: #20977
2020-07-17 08:26:40 -04:00
Kyle Edwards
63ecf481da Merge topic 'cmnonempty'
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5017
2020-07-15 10:53:43 -04:00
Vitaly Stakhovsky
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string 2020-07-14 15:18:59 -04:00
Vitaly Stakhovsky
7156911242 cmIsOn: add overload accepting const std::string* 2020-07-14 08:22:24 -04:00
Brad King
35928fa7ca Merge topic 'getfeature-prop'
18726ad634 GetFeature(): return cmProp

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5004
2020-07-14 07:20:15 -04:00
Vitaly Stakhovsky
18726ad634 GetFeature(): return cmProp 2020-07-11 14:03:03 -04:00
Vitaly Stakhovsky
43f7b17816 cmGeneratorExpressionInterpreter::Evaluate: remove const char* overload 2020-07-11 11:51:22 -04:00
Justin Goshi
2f383d852d fileapi: Support multiple backtraces for language standard 2020-07-06 11:40:39 -07:00
Brad King
a4cfc7d03c Merge topic 'refactor-generator-configs'
7a969fe21d cmMakefile: Refactor API to better handle empty config values

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4957
2020-07-06 09:28:11 -04:00
Robert Maynard
7a969fe21d cmMakefile: Refactor API to better handle empty config values 2020-07-03 07:43:18 -04:00
Robert Maynard
dc94b0249e cmStandardLevelResolver: Added to handle standard level queries
Refactored out of cmMakefile
2020-07-01 07:58:58 -04:00
Justin Goshi
ba835874a4 Add backtrace support for language standard 2020-06-22 09:26:23 -04:00
Justin Goshi
e43486a639 cmGeneratorTarget: Clarify name of language property lookup helper 2020-06-22 09:22:38 -04:00
Justin Goshi
742ff97f80 Refactor language standard computation
Instead of mutating the configure-time cmTarget's properties at generate
time, compute and store it in a cmGeneratorTarget field.
2020-06-16 16:32:34 -07:00
Brad King
7fa5ea130b Merge topic 'cuda_clang_toolkit_path' into release-3.18
ec59fb6c31 CUDA: Determine CUDA toolkit location for NVCC
0a056246a1 CUDA: Pass toolkit path to Clang
9c43972127 FindCUDAToolkit: Avoid unnecessary temporary variable computing binary dir
9eebb5b8b2 FindCUDAToolkit: Remove unnecessary checks around searches
8f01fe7bf1 FindCUDAToolkit: Use list(SORT) to sort in natural order
8c144fe9ad FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searching
403f8d31e3 FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOT
6636693134 FindCUDAToolkit: Re-unify with Internal/CUDAToolkit

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4828
2020-06-15 09:25:29 -04:00
Brad King
5d710f2d11 Merge topic 'cuda_clang_toolkit_path'
ec59fb6c31 CUDA: Determine CUDA toolkit location for NVCC
0a056246a1 CUDA: Pass toolkit path to Clang
9c43972127 FindCUDAToolkit: Avoid unnecessary temporary variable computing binary dir
9eebb5b8b2 FindCUDAToolkit: Remove unnecessary checks around searches
8f01fe7bf1 FindCUDAToolkit: Use list(SORT) to sort in natural order
8c144fe9ad FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searching
403f8d31e3 FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOT
6636693134 FindCUDAToolkit: Re-unify with Internal/CUDAToolkit

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4828
2020-06-15 09:25:29 -04:00
Raul Tambre
877a92e968 CUDA: Add support for disabling CUDA_ARCHITECTURES
The ability to disable adding architectures completely for packaging purposes
and cases requiring passing the architectures flags explicitly has been
requested.
Support a false value for CUDA_ARCHITECTURES and CMAKE_CUDA_ARCHITECTURES
for this purpose.

Implements #20821.
2020-06-15 09:13:32 -04:00
Raul Tambre
0a056246a1 CUDA: Pass toolkit path to Clang
Clang isn't very good at finding the installed CUDA toolkit.
The upstream recommendation is that we should pass the toolkit explicitly.

Additionally:
* Avoids Clang having to search for the toolkit on every invocation.
* Allows the user to use a toolkit from a non-standard location by simply
  setting CUDAToolkit_ROOT. The same way as with FindCUDAToolkit.

Clang wants the directory containing the device library and version.txt as the
toolkit path.
We thus pass the newly introduced CUDAToolkit_LIBRARY_ROOT as the toolkit path.

We save CUDAToolkit_ROOT_DIR and CUDAToolkit_LIBRARY_ROOT on Clang to have them
available in try_compile() and avoid unnecessary re-searching or a possibly
different installation being found in FindCUDAToolkit.
This however means that the selected toolkit can't be changed after the initial
language enablement.

We now determine CUDA compiler ID before doing actual detection, as we don't
want to spend time finding the CUDA toolkit for NVIDIA.

Implements #20754.
2020-06-12 21:50:05 +03:00
Brad King
a432b1075c Merge topic 'getdef-expand'
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4819
2020-06-02 08:02:24 -04:00
Brad King
855a7158ed Merge topic 'target_link_libraries-self-link-is-an-error'
9436ad35df target_link_libraries: self-link through ALIAS is an error

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4826
2020-06-02 07:53:40 -04:00
Brad King
3020decbff Merge topic 'pch-fix-bad-ClearSourcesCache'
902858367f Merge branch 'backport-3.16-pch-fix-bad-ClearSourcesCache'
fa7b041eca PCH: Fix logic error that incorrectly clears sources during VS generation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4815
2020-06-01 07:44:35 -04:00
Brad King
8cf2e1de22 Merge topic 'ninja-multi-export-all-symbols'
6fc4bfa11c Ninja Multi-Config: Fix bug in CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex Reinking <alex_reinking@berkeley.edu>
Merge-request: !4825
2020-06-01 07:36:50 -04:00
Vitaly Stakhovsky
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector
Combines cmMakefile:GetDefinition() and cmExpandList()
2020-05-30 08:59:20 -04:00
Marc Chevrier
9436ad35df target_link_libraries: self-link through ALIAS is an error
Fixes: #19617
2020-05-30 11:47:39 +02:00
Kyle Edwards
6fc4bfa11c Ninja Multi-Config: Fix bug in CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
Fixes: #20775
2020-05-29 15:28:43 -04:00
Brad King
902858367f Merge branch 'backport-3.16-pch-fix-bad-ClearSourcesCache' 2020-05-29 06:14:59 -04:00
Brad King
fa7b041eca PCH: Fix logic error that incorrectly clears sources during VS generation
Since commit 729d997f10 (Precompile Headers: Add REUSE_FROM signature,
2019-08-30, v3.16.0-rc1~101^2), `GetPchFileObject` handles the case that
it is called first for another target's `REUSE_FROM` by calling
`AddSource` to make sure `GetObjectName` can produce the correct object
name.  However, `AddSource` causes `ClearSourcesCache` to be called,
which since commit a9f4f58f0c (cmGeneratorTarget: Clear AllConfigSources
in ClearSourcesCache, 2020-05-15, v3.16.7~2^2) now correctly erases the
`AllConfigSources` structure.  This is okay during `AddPchDependencies`,
but there is another code path in which it is problematic.

When the Visual Studio generator's `WriteAllSources` method is looping
over the sources, the `cmake_pch.cxx` source is encountered first.  This
causes `OutputSourceSpecificFlags` to call `GetPchCreateCompileOptions`,
which calls `GetPchFile`, which under MSVC with `CMAKE_LINK_PCH` calls
`GetPchFileObject`.  That leads to `ClearSourcesCache` erasing the
structure over which `WriteAllSources` is iterating!

This bug is caught by our `RunCMake.PrecompileHeaders` test when run
with the VS generator as of the commit that exposed it by fixing
`ClearSourcesCache`.  However, that change was backported to the CMake
3.16 series after testing only with later versions versions that contain
commit a55df20499 (Multi-Ninja: Add precompile headers support,
2020-01-10, v3.17.0-rc1~136^2).  By adding proper multi-config support
for PCH, that commit taught `cmLocalGenerator::AddPchDependencies` to
call `GetPchFile` with the real set of configurations instead of just
the empty string.  This allows the `GetPchFile` cache of PCH sources to
be populated up front so that the later calls to it in the
`WriteAllSources` loop as described above do not actually call
`GetPchFileObject` or `ClearSourcesCache`.  That hid the problem.

Fix this by re-ordering calls to `AddPchDependencies` to handle
`REUSE_FROM` targets only after the targets whose PCH they re-use.
Remove the now-unnecessary call to `AddSource` from `GetPchFileObject`
so that `ClearSourcesCache` is never called during `WriteAllSources`.
Update the PchReuseFrom test case to cover an ordering of targets that
causes generators to encounter a `REUSE_FROM` target before the target
whose PCH it re-uses.

Fixes: #20770
2020-05-29 05:52:03 -04:00
Brad King
4468acb979 CUDA: Factor runtime library lookup into helper method 2020-05-22 08:15:32 -04:00
Cristian Adam
f6cb1e646c Multi-Ninja: Fix PCHs for Visual C++
Fixes: #20711
2020-05-20 11:20:38 +02: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
3fa3b7a402 cmGeneratorTarget: Remove default config from Get* methods
Ensure all call sites pass an explicit configuration.
2020-05-18 12:56:56 -04:00