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

411 Commits

Author SHA1 Message Date
Marc Chevrier
5a2a275bb4 Refactor: reduce cmToCStr usage 2021-08-19 10:49:30 +02:00
Brad King
c9cd039e5f Merge topic 'LWYU-externalization'
14e57e9637 LINK_WHAT_YOU_USE feature: externalize configuration
9c5132a586 PGI: Fix "LINKER:" prefix generated separator
8a93de080c cmGeneratorTarget: Add method for LINKER: prefix translation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6306
2021-07-12 08:43:32 -04:00
Marc Chevrier
14e57e9637 LINK_WHAT_YOU_USE feature: externalize configuration
Currently, this feature is only supported on ELF platforms. So, the property
LINK_WHAT_YOU_USE will be ignored for other plateforms.
Moreover, flags and commands are now controled by CMake variables.

Fixes: #20174
2021-07-09 14:50:50 +02:00
Alexander Grund
c00f928ce1 Do not exclude include directory symlinks to entries of CPATH
Extend the fix from commit 2d0b0e2b9d (Do not exclude include
directories made implicit by CPATH, 2019-05-29, v3.14.5~2^2) to cover
include directories that are symlinks to paths listed in `CPATH`.

Compare resolved paths against resolved entries of `CPATH`.
Resolve the entries as late as possible in case symlinks change.

Fixes: #22383
2021-07-07 08:04:59 -04:00
Brad King
8526756b61 cmOutputConverter: Adopt relative path conversion helpers
Move them up from cmLocalGenerator and out of cmStateDirectory.
2021-05-17 10:04:01 -04:00
Brad King
013ec595c8 cmLocalGenerator: De-duplicate StateSnapshot member
We have the member from the cmOutputConverter parent.
2021-05-17 10:03:43 -04:00
Brad King
24bfdbcffb cmLocalGenerator: Remove unused MaybeRelativeToCurSrcDir method
With the recent update to `GetObjectFileNameWithoutTarget`, we no longer
have any call sites for `MaybeRelativeToCurSrcDir`.  It does not make
sense for the generator to produce paths relative to the source tree in
general, so remove the method.
2021-05-17 10:03:43 -04:00
Brad King
15fa320071 cmLocalGenerator: Factor out relative path conversion helpers
Most calls to `MaybeConvertToRelativePath` use one of our common work
directories (e.g. top of the build tree) as the local path.  Add helpers
for each of the common cases to simplify and clarify call sites.
2021-05-13 12:47:25 -04:00
Brad King
a133a583d4 cmLocalGenerator: Clarify GetIncludeFlags signature
Make the `config` argument non-optional so all callers must be explicit.
Convert the path style argument to an enumeration to make its role clear
at call sites.

The path style argument is implemented by `ConvertToIncludeReference`,
which was introduced with the Ninja generator by commit 5b114c9bee
(Introduce a cmLocalGenerator::ConvertToIncludeReference function,
2011-09-07, v2.8.7~187^2~4).  Its only purpose is to allow the Ninja
generator to use relative paths in `-I` flags.  Add a comment explaining
this role.
2021-02-25 13:24:45 -05:00
Kyle Edwards
f01f10e8fb cmCustomCommand: Record value of CMP0116 at time of creation 2021-02-23 09:14:31 -05:00
Brad King
cab99f7dba Merge topic 'xcode12-ios_install_combined'
0110aa018d IOS_INSTALL_COMBINED: Support Xcode 12 (command line only)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5785
2021-02-09 08:23:30 -05:00
Craig Scott
0110aa018d IOS_INSTALL_COMBINED: Support Xcode 12 (command line only)
Xcode 12 doesn't allow nested builds within the same build directory.
That means we can no longer do an install by building the install target
when IOS_INSTALL_COMBINED is true. We can, however, still do an install
by running the cmake_install.cmake script or executing cmake --install,
since there is no outer build and therefore the associated SDK can be
built as a sub-build.

The non-build methods previously didn't work when
IOS_INSTALL_COMBINED was true because the generated install script
and the CMakeIOSInstallCombined script both made certain assumptions
that relied on being part of a build. Those assumptions are now
removed. A side-effect of this work is that cpack now also works from the
command line when IOS_INSTALL_COMBINED is true.

Relates: #21282
Fixes: #20023
2021-02-08 18:02:46 +11:00
Ben Boeckel
808b17b120 clang-tidy: fix readability-make-member-function-const warnings 2021-01-27 08:45:45 -05:00
Craig Scott
ee9da76972 Unity: Generate reproducible unity IDs for anonymous namespaces
Fixes: #21564
2021-01-23 07:14:05 +11:00
Kyle Edwards
dcf9f4d2f7 Ninja Multi-Config: Add support for cross-config custom commands
Co-Author: Brad King <brad.king@kitware.com>
2020-12-15 07:01:21 -05:00
Brad King
15467f12f7 cmLocalGenerator: Adopt custom target 'force' output name generation 2020-12-15 07:00:53 -05:00
Brad King
7b64b0cd5a cmLocalGenerator: Refactor custom command generator construction
Add support for constructing and using multiple generators for one
custom command.  cmGeneratorTarget contains a code path that needs this
behavior when used with Ninja but not other generators, so use virtual
dispatch through cmLocalGenerator.
2020-12-15 07:00:52 -05:00
Brad King
d29da8ed3e cmMakefile: Simplify custom target 'force' output name generation
Remove unnecessary check of policy CMP0049.  The policy can never
trigger on our internally-generated name because it has no variable
references.

The rename in commit 0ed5ce4cd8 (cmTarget: Rename AddSource method for
backward compatibility., 2014-03-17, v3.1.0-rc1~688^2~17) made it look
like this code path depended on CMP0049.  Then commit 0e1faa28cb
(cmMakefile: Separate custom command setup from actual creation,
2019-09-14, v3.16.0-rc1~85^2) and commit ea1bed34b2 (cmMakefile: Extract
utilities used for creation of custom commands, 2019-09-21,
v3.16.0-rc1~52^2~1) built additional infrastructure to thread that
dependence through the call stack.  Remove it all.
2020-12-15 07:00:52 -05:00
Brad King
f36af9228b cmLocalGenerator: Evaluate generator expressions in custom command outputs
Custom commands with generator expressions in their OUTPUTs or
BYPRODUCTS are still attached to a single `.rule` file.  We use an
internal map to look up the source file holding the custom command for a
given output.  Populate this map using the outputs and byproducts from
all configurations after evaluating the generator expressions for each
configuration.

Issue: #12877
2020-12-11 08:24:06 -05:00
Brad King
c887cefd9a cmLocalGenerator: Simplify custom command output cmSourceFile creation
Move calls to `CreateGeneratedSource` over to `UpdateOutputToSourceMap`,
which is called for all generated outputs and byproducts.
2020-12-10 07:06:21 -05:00
Brad King
947ba01bf9 cmLocalGenerator: Factor out helper to expand custom command output paths 2020-12-10 07:06:21 -05:00
Brad King
1902d28ebc cmLocalGenerator: Refactor UpdateOutputToSourceMap to avoid boolean trap 2020-12-10 07:06:20 -05:00
Marc Chevrier
a97c41bf8b Refactoring: Makefiles Generators: Add support for various depends scanners 2020-11-28 16:02:58 +01:00
vvs31415
f808f27919 cmLocalGenerator::GetRuleLauncher: return cmProp 2020-11-02 13:07:46 -05:00
Cengizhan Pasaoglu
bd705788f6 Constify some code as suggested by clang-tidy 2020-10-20 00:04:04 +03:00
Brad King
0090a11a42 cmLocalGenerator: Migrate custom command output lookup from cmMakefile
Since commit 777ceaea94 (cmMakefile: Delay custom command creation,
2019-10-17, v3.17.0-rc1~352^2) we process custom command declarations at
generate time.  Therefore we do not need to look up what source file
holds the custom command producing a given output until generate time.
2020-10-08 12:20:33 -04:00
Raul Tambre
c63fe01835 CUDA: Clang separable compilation
For NVCC the compiler takes care of device linking when passed the "-dlink"
flag.
Clang doesn't support such magic and requires the buildsystem to do the work
that NVCC does behind the scenes.

The implementation is based on Bazel's device linking documentation:
7cabcdf073/third_party/nccl/build_defs.bzl.tpl (L259)

Closes: #20726
2020-09-24 15:19:54 -04:00
Brad King
d0ccc7cf2a Merge topic 'ispc_improvements'
a020787a9b ISPC: Support generation for multiple instruction sets
5a1750017e ISPC: Add compiler launcher support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5173
2020-09-08 11:19:28 -04:00
Robert Maynard
a020787a9b ISPC: Support generation for multiple instruction sets 2020-09-04 08:37:07 -04:00
Kitware Robot
bdca8b01d2 Modernize: Use #pragma once in all header files
#pragma once is a widely supported compiler pragma, even though it is
not part of the C++ standard. Many of the issues keeping #pragma once
from being standardized (distributed filesystems, build farms, hard
links, etc.) do not apply to CMake - it is easy to build CMake on a
single machine. CMake also does not install any header files which can
be consumed by other projects (though cmCPluginAPI.h has been
deliberately omitted from this conversion in case anyone is still using
it.) Finally, #pragma once has been required to build CMake since at
least August 2017 (7f29bbe6 enabled server mode unconditionally, which
had been using #pragma once since September 2016 (b13d3e0d)). The fact
that we now require C++11 filters out old compilers, and it is unlikely
that there is a compiler which supports C++11 but does not support
#pragma once.
2020-09-03 09:30:21 -04:00
Robert Maynard
e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds 2020-08-28 11:21:31 -04:00
Vitaly Stakhovsky
18726ad634 GetFeature(): return cmProp 2020-07-11 14:03:03 -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
Cristian Adam
1f791eb160 Multi-Ninja: Fix reusable PCHs for MSVC
Fixes: #20721
2020-05-27 14:19:03 -04:00
Marc Chevrier
2faa3f6c55 Refactoring: Third-parties public headers are under cm3p prefix
Fixes: #20666
2020-05-07 12:06:08 +02:00
Brad King
5a57cec2f4 Merge topic 'apple-merge-same-sysroot'
3a7d1e9592 Apple: Merge per-arch sysroot parameters if all are the same

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4647
2020-04-22 08:32:02 -04:00
Gregor Jasny
3a7d1e9592 Apple: Merge per-arch sysroot parameters if all are the same
Since commit a9b41195d2 (Handle multi-arch sysroots on Apple platforms,
2019-07-26, v3.17.0-rc1~287^2), CMake supports "fat" builds with
different sysroots. Those are passed to the compiler with the
`-Xarch_<xyz>` parameter.

Unfortunately this breaks the Compiler Cache (ccache) because
it does not support those compiler flags:

    https://github.com/ccache/ccache/blob/v3.7.9/src/ccache.c#L2700-L2705

Restore the caching ability for certain "fat" build configurations (e.g.
`arm64` and `armv7`) where the sysroot is the same for all selected
architectures and thus a plain `-isysroot` parameter could be used.
2020-04-21 11:18:12 -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
Brad King
a67565751f Merge topic 'msbuildUtf8Support'
bc877a7e94 Add support to indicate UTF-8 custom command pipe output encoding

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4587
2020-04-15 09:44:48 -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
da25220d83 Merge branch 'backport-3.17-apple-arch-sysroots' into apple-arch-sysroots 2020-04-08 13:44:42 -04:00
Brad King
84a1e67380 Apple: Fix mapping CMAKE_APPLE_ARCH_SYSROOTS to custom OSX_ARCHITECTURES
The `CMAKE_OSX_ARCHITECTURES` value is not used directly by generators.
It is used to initialize a per-target `OSX_ARCHITECTURES` property, but
that property can also be set explicitly by project code to a subset of
the full list of architectures.  In order to handle this case, construct
a mapping from each `CMAKE_OSX_ARCHITECTURES` entry to the corresponding
`CMAKE_APPLE_ARCH_SYSROOTS` entry by name.  Use the mapping to find the
sysroot for each entry in `OSX_ARCHITECTURES` for a given target.

If `CMAKE_APPLE_ARCH_SYSROOTS` does not have the same length as
`CMAKE_OSX_ARCHITECTURES`, error out early rather than risking a crash
or assertion failure.

Fixes: #20534
2020-04-08 13:40:09 -04:00
Cristian Adam
f593b354da PCH: Add support for multi architecture iOS projects
Fixes: #20497
2020-04-02 11:51:19 -04:00
Vitaly Stakhovsky
bbc07e4561 Source: use std::string in place of const char* 2020-01-29 14:31:01 -05:00
Kyle Edwards
5a8a9f7229 Ninja: Add multi-config variant
Co-Authored-by: vector-of-bool <vectorofbool@gmail.com>
2019-12-13 10:51:46 -05:00
Daniel Eiband
777ceaea94 cmMakefile: Delay custom command creation
Move custom command creation to cmLocalGenerator and dispatch custom
commands in cmMakefile to generate time.  Generators add custom commands
using the new methods provided by cmLocalGenerator.

Issue: #12877
2019-11-24 20:32:43 +01:00
Marc Chevrier
f93385283f cmLocalGenerator: modernize memory management 2019-11-11 16:41:13 +01:00
Cristian Adam
36ded610af PCH: Generate sources during Compute step 2019-10-09 13:50:25 +02:00
Brad King
f1fb63b306 file(GENERATE): Create output file structures even earlier
Since commit b80557c7bd (file(GENERATE): Evaluate early to allow
generating source files, 2014-11-04, v3.2.0-rc1~398^2) we create the
`cmSourceFile` instances marked with a `GENERATED` source file property
before tracing source dependencies.  Move it to even earlier so that
steps in `cmGlobalGenerator::AddAutomaticSources` can operate on all
sources.  This also avoids the accidental `O(n^2)` calls for `n` local
generators that we had previously.

This is also needed since commit 83c1657ff7 (Unity build: Generate
sources during Compute step, 2019-10-03) to support `file(GENERATE)`
outputs as sources in a target with `UNITY_BUILD` enabled.
2019-10-07 15:22:12 -04:00
Brad King
83c1657ff7 Unity build: Generate sources during Compute step
The unity build sources need to be added for all generators.  Create
them during `cmGlobalGenerator::Compute` to avoid duplicating the calls
in every generator.  We already handle Qt autogen there too.

Issue: #19789
2019-10-03 14:55:22 -04:00