193 Commits

Author SHA1 Message Date
Brad King
d7e53b4274 Merge topic 'cleanup-gen-lookups'
7ff9ab3b10 Makefile: De-duplicate executable link rule lookup
79f5ef19fe De-duplicate checks for whether a platform uses Windows DLLs
22d3eb5d5e Refactor checks for whether a target has an import library

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3550
2019-07-15 07:41:52 -04:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
Brad King
7ff9ab3b10 Makefile: De-duplicate executable link rule lookup
Use `GetCreateRuleVariable` instead of duplicating the variable lookup.
2019-07-12 17:37:02 -04:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -04:00
Robert Maynard
a4d502a5bf CUDA: Do not device link if CUDA is not an enabled language
Checks added in commit 81b4d10d8f (CUDA: More exhaustive checks to
determine when to do device linking, 2019-05-09, v3.15.0-rc1~82^2)
assumed that CUDA properties would be set only if CUDA is enabled.

We cannot do a device link step if we do not have the CUDA language
enabled.  This was discovered as some projects unconditionally set CUDA
properties such as `CUDA_RESOLVE_DEVICE_SYMBOLS` even when the CUDA
language has not been enabled.

Fixes: #19432
2019-07-01 08:29:10 -04:00
Sebastian Holtermann
006229278b Use cmAppend to append ranges to std::vector instances 2019-05-23 16:19:49 +02:00
Brad King
fc4cbbc2a5 Merge topic 'remove_unneeded_device_link_calls'
81b4d10d8f CUDA: More exhaustive checks to determine when to do device linking
3205c7c950 cmNinjaLinkLineDeviceComputer now lives in the correct source file

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3320
2019-05-22 10:30:00 -04:00
Robert Maynard
81b4d10d8f CUDA: More exhaustive checks to determine when to do device linking
Previously CMake used fairly naive logic to determine when to do
device linking which caused unnecessary device linking to occur
frequently. We now use a more exhaustive algorithm to determine
when we have a need for device linking.

Fixes: #19238
2019-05-21 11:40:07 -04:00
Brad King
3020354f7c Merge topic 'string-cleanup'
23e8364aed Source: std::string related cleanup

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Sebastian Holtermann <sebholt@web.de>
Merge-request: !3324
2019-05-17 09:26:05 -04:00
Vitaly Stakhovsky
23e8364aed Source: std::string related cleanup 2019-05-15 10:20:05 -04:00
Sebastian Holtermann
7c8c18b1e6 Makefiles: Sort clean files by using a std::set<std::string> container
By using a `std::set<std::string>` container instead of a
`std::vector<std::string>` container, the clean files list becomes sorted and
unique.  The clean target in Makefiles beomes nicer and better readable this
way.  Also double clean entries won't appear anymore.
2019-05-14 17:50:13 +02:00
Saleem Abdulrasool
9ecb3f8d5c Ninja,Makefile: use unique_ptr for memory management
Use a `unique_ptr` to manage the lifetime of the `MacOSXContentGenerator`
and 'OSXBundleGenerator` rather than manually handling the lifetime.
2019-04-18 11:05:25 -04:00
Vitaly Stakhovsky
9dd255548d cmSystemTools::Error: consolidate parameters into single std::string 2019-02-20 11:18:11 -05:00
Saleem Abdulrasool
fc8b90af2c Create and use cmGeneratorTarget::Names
Rather than taking a number of out parameters for the various names,
create a structure that is reused for both `GetLibraryNames` and
`GetExecutableNames`.  Replace uses according to the new interface.
2019-02-11 10:44:24 -08:00
Robert Maynard
850ef90a66 CUDA: Honor CUDA_RESOLVE_DEVICE_SYMBOLS for more target types
`CUDA_RESOLVE_DEVICE_SYMBOLS` can be used with shared, module, and
executable target types.  This relaxation is to allow for better
interoperability with linkers that automatically do CUDA device symbol
resolution and have no way to disable it.
2019-02-05 11:09:48 -05:00
Bruno Manganelli
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h 2019-01-21 15:34:16 +00:00
Brad King
cd0881be61 IWYU: Update CMake code for IWYU built with Clang 6
IWYU now correctly requires `<utility>` for `std::move`.  It also
requires a container header when used via a range-based for loop.
2019-01-15 10:00:50 -05:00
Brad King
7b74213461 CUDA: Fix crash on linking to a CUDA target without CUDA enabled
Do not try to device link or add CUDA runtime libraries if the language
is not enabled.

Fixes: #18673
Issue: #18614
2018-12-05 14:45:19 -05:00
Vitaly Stakhovsky
50fbfee3a0 cmLocalGenerator: return directories as const std::string& 2018-08-27 15:48:57 -04:00
Marc Chevrier
cc9f88af53 LINK_DEPENDS: add support for property INTERFACE_LINK_DEPENDS
Fixes: #17997
2018-06-27 18:38:36 +02:00
Marc Chevrier
c1f5a44b28 LINK_OPTIONS: Add new family of properties
This family enable to manage link flags

Three new properties:
* directory property: LINK_OPTIONS
* target properties: LINK_OPTIONS and INTERFACE_LINK_OPTIONS

Two new commands
* add_link_options(): to populate directory property
* target_link_options(): to populate target properties

Fixes: #16543
2018-06-06 17:22:39 +02:00
Marc Chevrier
8e28d2630a Makefile generator: link flags management refactoring 2018-06-06 17:02:33 +02:00
Michael Stürmer
fb433ff283 cmGeneratorTarget: Make import library checks config-aware 2018-04-05 06:36:49 +02:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Pavel Solodovnikov
c85bb007df Reduce allocation of temporary values on heap.
- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
2018-01-26 13:24:45 +03:00
Yurii Batrak
7ab9a62572 Makefiles: Drop 'requires' step and its supporting infrastructure
The 'requires' step was used to provide implicit dependencies between
the generated Fortran module files and a Fortran target that needs these
module files to ensure the correct compilation order.  After recent
refactoring to resolve all dependencies explicitly through `.mod.stamp`
make targets, the separate 'requires' step is not needed anymore.
2017-12-14 08:22:07 -05: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
Brad King
c0c5f924fe Merge topic 'refactor-iwyu-code'
3bbe95f5 Clean up iwyu code to not be one big if statement.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1247
2017-09-15 08:54:32 -04:00
Bill Hoffman
3bbe95f58a Clean up iwyu code to not be one big if statement.
This commit changes the internal -E__run_iwyu to be -E__run_co_compile. This
is used for co-compile commands. These are tools that want to mirror the
compiler. For each compiler invocation the tool will be invoked first. This
started as a way to implement include what you use (iwyu), but has expanded
to include cpplint, cppcheck and others. Likely there will be more in the
future as well. This commit implements each one in its own function and
provides a way to add additional ones in the future with less work.
2017-09-13 17:44:49 -04:00
Pavel Solodovnikov
7d5095796a Meta: modernize old-fashioned loops to range-based for.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-12 16:22:47 +03:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Brad King
d037be122e cmLocalGenerator: Add a hook for compiler flags used at link time
When using a compiler to drive linking we add compiler flags from
`CMAKE_<LANG>_FLAGS` in case they affect the way the compiler invokes
the linker, but we don't add flags from other places that are meant only
for compiling sources.  Rather than calling the `AddLanguageFlags`
method (which is used to add flags for compiling sources) directly, add
an intermediate method that is used when adding the flags for linking.
This will give us a way to add language-specific compiler flags needed
when driving the linker in the same place on the command line as other
compiler flags go.
2017-05-01 10:33:05 -04:00
Ruslan Baratov
7d057b2738 Clang IPO (LTO) support 2017-04-28 17:13:56 +03:00
Brad King
47990f9fef Inline and remove AddFeatureFlags method
The method implementation is now only one call of another method, so
inline it at call sites and remove it.
2017-04-27 16:21:59 -04:00
Robert Maynard
8fb85c68bb CUDA: Makefile uses relative path for device linking status messages 2017-04-26 11:41:22 -04:00
Gregor Jasny
cf320f7cd7 Replace boolean implib parameters with enum
Named enumeration values are much clearer at call sites and add more
type safety.
2017-04-20 10:22:33 -04:00
Brad King
f36eaf6a6e Refactor WINDOWS_EXPORT_ALL_SYMBOLS implementation
Use `cmGeneratorTarget::ModuleDefinitionInfo` to combine the
implementation of `WINDOWS_EXPORT_ALL_SYMBOLS` with that of using a
`.def` file as a source.  Only one of these could be used within a
single target before anyway.
2017-03-09 16:25:15 -05:00
Daniel Pfeifer
ee72803e9f fix some include-what-you-use diagnostics 2017-02-17 22:12:21 +01:00
Robert Maynard
05dbc940b7 CUDA: Don't use module definition .def files for device linking
These files are meaningful only to the host linker.
2017-01-12 15:07:10 -05:00
Brad King
02582b91ad CUDA: Populate compiler PDB placeholder during device linking
The device link step runs the host compiler internally so we need to use
the proper compiler PDB file with MSVC.
2017-01-12 10:39:03 -05:00
Brad King
d470cb7007 CUDA: Use .obj object file extension on Windows 2017-01-12 10:39:02 -05:00
Robert Maynard
d038559e49 CUDA: Add separable compilation support to the makefile generator. 2016-11-14 16:40:49 -05:00
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Stephen Kelly
e6eecec761 cmListFileCache: Remove cmState header include
Include it in dependents which have previously relied on it
transitively.
2016-10-19 15:41:00 +02:00
Stephen Kelly
b59b6dd9d2 cmRulePlaceholderExpander: Port clients to direct-use
Add a factory function to cmLocalGenerator so that variableMappings can
be provided from it, and so that Ninja can always have a hard-coded
TargetImpLib.
2016-10-15 11:25:12 +02:00
Stephen Kelly
c75a9d6601 cmLocalGenerator: Use strings instead of a Target in rule replacement
Don't rely on the cmGeneratorTarget type needlessly.
2016-10-15 11:25:12 +02:00
Stephen Kelly
46ad0d2183 cmLocalGenerator: Use a converter in rule replacement API
The rule replacement API should not really be in cmLocalGenerator, but
it was historically, and this coupled many other things together here
too, such as output conversion.  Make the output converter a parameter
so that rule replacement can be removed from cmLocalGenerator.
2016-10-15 11:25:12 +02:00
Stephen Kelly
425cd1670f cmLocalGenerator: Remove the launcher from RuleVariables
This one is not like the others as it doesn't participate in
substitutions.  Keep ExpandRuleVariables doing only one thing and make
callers responsible for inserting a launcher prefix, simplifying the
code all-around.

Remove now-obsolete InsertRuleLauncher method.
2016-10-15 11:25:12 +02:00
Jamie Snape
33cb0173d5 Honor LINK_WHAT_YOU_USE when set to OFF
Explicitly setting variable CMAKE_LINK_WHAT_YOU_USE or property
LINK_WHAT_YOU_USE to OFF should not cause LWYU to run.  Fix the
property lookup to use GetPropertyAsBool.
2016-10-13 13:34:35 -04:00
Stephen Kelly
f03d446e96 cmLinkLineComputer: Move FrameworkPath computation from cmLocalGenerator
Add UseWatcomQuote state, and remove corresponding method parameters.
2016-10-10 20:38:59 +02:00