234 Commits

Author SHA1 Message Date
Brad King
9fc3024f62 Merge topic 'fix-csharp-target-type'
375b420fdf CSharp: Fix regression in VS project type selection
8b21aa0af0 VS: Fix CSharp flag selection when linking to a static C++ library

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2427
2018-10-03 08:04:35 -04:00
Brad King
375b420fdf CSharp: Fix regression in VS project type selection
A that target contains only `.cs` sources should be generated as a
`.csproj` project even if it links to non-CSharp static libraries.
The latter case was broken by refactoring in commit v3.12.0-rc1~160^2~7
(remove TargetIsCSharpOnly() and use methods from cmGeneratorTarget,
2018-03-19).  The reason is that the `HasLanguage` method added by
commit v3.12.0-rc1~239^2~6 (cmGeneratorTarget: add HasLanguage() as
wrapper for GetLanguages(), 2018-03-19) enforces its "exclusive" check
on the combined set of source file languages and the link language.
To restore the original `TargetIsCSharpOnly` semantics, update
`HasLanguage` to enforce exclusiveness only on the list of sources.

Fixes: #18239
2018-10-02 14:58:11 -04:00
Marc Chevrier
a71caab46b LINK_DIRECTORIES: Add new properties and commands
These new capabilities enable to manage link directories

Two new properties:
* target properties: LINK_DIRECTORIES and INTERFACE_LINK_DIRECTORIES

One new command
* target_link_directories(): to populate target properties

Fixes: #17215
2018-09-25 23:59:58 +10:00
Brad King
18441a6269 cmGeneratorTarget: Factor target name resolution out of link item resolution 2018-09-12 12:46:51 -04:00
Brad King
fc7e4d1ed8 cmLinkItem: Convert to a "sum type" over a string and target pointer
Avoid exposing the item name implicitly as std::string.  When the item
is a target, avoid storing a second copy of its name.

Most link item construction is paired with calls to `FindTargetToLink`
to get the possible target pointer.  Rename these methods to
`ResolveLinkItem` and refactor them to construct the entire item.
2018-09-07 08:57:51 -04:00
Marc Chevrier
974de0e199 static library: add property STATIC_LIBRARY_OPTIONS
issue: #18251
2018-08-15 15:20:18 +02:00
Sebastian Holtermann
86b332c25d Return std::string from cmGeneratorTarget::ImportedGetLocation 2018-07-11 16:58:48 +02:00
Brad King
4330f10186 Merge topic 'safe_property'
42cc0644d5 Autogen: Use default and remove custom GetSafeProperty functions
127094f2f0 Add GetSafeProperty method to cmTarget, cmGeneratorTarget and cmSourceFile

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2185
2018-07-03 10:56:31 -04:00
Sebastian Holtermann
127094f2f0 Add GetSafeProperty method to cmTarget, cmGeneratorTarget and cmSourceFile 2018-07-02 12:39:54 +02: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
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Michael Stürmer
fb433ff283 cmGeneratorTarget: Make import library checks config-aware 2018-04-05 06:36:49 +02:00
Michael Stürmer
4c1f33961f cmGeneratorTarget: add GetManagedType() and CheckManagedType() methods 2018-04-05 06:36:48 +02:00
Michael Stürmer
6c517a9f8d cmGeneratorTarget: add HasLanguage() as wrapper for GetLanguages() 2018-04-05 06:35:01 +02:00
Brad King
2deb9b7f34 Genex: Fix COMPILE_LANGUAGE in SYSTEM include directories
When evaluating `INTERFACE_SYSTEM_INCLUDE_DIRECTORIES`, or evaluating
`INTERFACE_INCLUDE_DIRECTORIES` on an imported target, thread the
compile language through to the generator expression evaluator so
that it can support `$<COMPILE_LANGUAGE:...>`.

Fixes: #17811
2018-03-12 11:45:01 -04:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Sebastian Holtermann
952fc65d14 Autogen: Clear sources meta data cache
Adds cmGeneratorTarget::clearSourcesCache() which clears the cache
of precomputed sources lists and object names. The cache gets
recomputed on demand.

Clearing the cache is necessary in case an OBJECT library
gets a source added after a target (ORIGIN) that includes it
computed it's external sources cache.
This may happen in AUTOMOC when ORIGIN is processed before the
OBJECT library which gets a mocs_compilation.cpp file added.

Closes #17152
Closes #17139
Closes #17085
Closes #15967
2017-08-10 18:33:02 +02:00
Brad King
d89e10cd58 Diagnose object library self-reference
The code

    add_library(A OBJECT a.c)
    target_sources(A PRIVATE $<TARGET_OBJECTS:A>)

used to crash CMake via infinite recursion while evaluating the
generator expression.  Then the change in commit v3.9.0-rc1~266^2~1
(cmGeneratorTarget: Replace source classifier implementation,
2017-04-07) avoided the infinite recursion because GetKindedSources now
creates a map entry and initializes it once.  If it is called again on
the same target during that initialization, the partially computed
results are returned.  This is still wrong but does not crash.
Detect and diagnose this case instead.

Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
Fixes: #16578
2017-07-14 14:05:22 -04:00
Brad King
ba247ccaba IPO: Consider support for each language separately
We only define `INTERPROCEDURAL_OPTIMIZATION` behavior for C, CXX, and
Fortran languages.  Do not try to enable support for other languages.
Furthermore, each language builds with a different compiler, so check
for support by CMake and the compiler for each language independently.

Fixes: #16944
2017-06-14 10:36:57 -04:00
Brad King
b115bc49ff Features: Refactor <LANG>_STANDARD update
In order to support generator expressions in target COMPILE_FEATURES
we apply them at generate time.  Move this step to the beginning of
generation instead of doing it on demand while collecting flags.
This avoids repeating the process unnecessarily, and will then allow
`cmLocalGenerator::AddCompilerRequirementFlag` to be used any time
during generation.
2017-05-01 10:33:05 -04:00
Daniel Pfeifer
d6f0006c0b Use CM_DISABLE_COPY 2017-04-24 22:03:06 +02:00
Daniel Pfeifer
e6c606c7ba cmGeneratorTarget::SourceFileFlags: remove custom copy ctor 2017-04-22 00:48:19 +02:00
Brad King
1d8f0f9181 Merge topic 'enable_ptx_compilation'
23691d78 CUDA: Allow sources to be compiled to .ptx files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !725
2017-04-21 08:57:59 -04:00
Robert Maynard
23691d789e CUDA: Allow sources to be compiled to .ptx files
When the target property `CUDA_PTX_COMPILATION` is enabled CUDA OBJECT
libraries will generate ptx files instead of object files.
2017-04-20 13:25:38 -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
d596c5504e cmGeneratorTarget: Add method to get the object file directory
Add a `GetObjectDirectory` method to get the target's object file
directory for a specific configuration.
2017-04-18 09:03:33 -04:00
Brad King
930042f2d9 cmGeneratorTarget: Factor out a GetTargetObjectNames method 2017-04-18 09:03:32 -04:00
Brad King
3ab4681efa cmGeneratorTarget: Drop default GetLinkerLanguage config argument
Update one remaining call site to avoid using the default.
2017-04-17 10:54:00 -04:00
Brad King
ca697bfc26 cmGeneratorTarget: Drop obj libs from GetConfigCommonSourceFiles
Call sites such as those in the VS global generator that are used only
to reject per-config sources will now allow per-config object library
objects.  The corresponding generators have already been taught to deal
with per-config object library files.  Remaining call sites do not need
object library files anyway.

This will later allow `$<TARGET_OBJECTS:...>` generator expressions to
evaluate to values that vary by configuration (e.g. because each
configuration has its own object files).
2017-04-13 16:10:33 -04:00
Brad King
40aa6c059c cmGeneratorTarget: Add method to collect all sources for all configs
Multi-config generators like VS and Xcode need to loop over all the
source files first and then handle per-config information within
each one.  Teach cmGeneratorTarget to provide such a view.
2017-04-13 16:10:31 -04:00
Brad King
e155fba644 Merge topic 'xcode-remove-UseObjectLibraries'
229abfc8 cmGeneratorTarget: Drop unused UseObjectLibraries method
63fbf587 Xcode: Inline relevant parts of UseObjectLibraries
1afacebe Xcode: Do not add Object Libraries source group on Xcode >= 5

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !698
2017-04-13 08:15:25 -04:00
Brad King
8456ec833a Merge topic 'include-style'
1d829c86 Use quotes for non-system includes
26ee9e42 CPack: drop CPack prefix for includes
5afac50f cmConfigure: Ensure separate include block in headers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !691
2017-04-13 08:12:40 -04:00
Brad King
229abfc8f9 cmGeneratorTarget: Drop unused UseObjectLibraries method 2017-04-12 15:38:54 -04:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
Automate with:

git grep -l '#include <cm_' -- Source \
  | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g'

git grep -l '#include <cmsys/' -- Source \
  | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g'

git grep -l '#include <cm[A-Z]' -- Source \
  | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
2017-04-11 22:35:21 +02:00
Brad King
a2e91af99d cmGeneratorTarget: Drop unused GetIDLSources method 2017-04-11 13:36:40 -04:00
Brad King
60307c5056 cmGeneratorTarget: Replace source classifier implementation
Compute and memoize the list of sources with their kinds for each
configuration just once.
2017-04-07 15:35:48 -04:00
Brad King
c791fb1254 Merge topic '16733-bundle-genex'
d1dac1ac Xcode: Execute RunCMake.Framework also for Xcode generator
d02709d7 Genex: Add `TARGET_BUNDLE_[CONTENT_]_DIR` generator expressions
013ffe76 cmGeneratorTarget: Call GetFrameworkDirectory in GetFullNameInternal
32e9d0ca cmGeneratorTarget: Use enum to describe bundle directory query level

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Craig Scott <craig.scott@crascit.com>
Merge-request: !635
2017-03-31 10:40:02 -04:00
Brad King
8772fc81c4 Merge topic 'ipo-policy-CMP0069'
dfa8263f Implement interprocedural optimization for GNU compilers
1588a577 Add policy CMP0069 to enforce INTERPROCEDURAL_OPTIMIZATION
a7575700 Refactoring: s,GetFeatureAsBool,IsIPOEnabled,
e05835c3 CheckIPOSupported: Visual Studio and Xcode generators do not support IPO

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Brad King <brad.king@kitware.com>
Reviewed-by: Nils Gladitz <nilsgladitz@gmail.com>
Merge-request: !568
2017-03-31 10:38:08 -04:00
Gregor Jasny
d02709d7f7 Genex: Add TARGET_BUNDLE_[CONTENT_]_DIR generator expressions
Closes #16733
2017-03-30 22:24:54 +02:00
Gregor Jasny
32e9d0ca23 cmGeneratorTarget: Use enum to describe bundle directory query level 2017-03-30 22:24:54 +02:00
Ruslan Baratov
dfa8263f4b Implement interprocedural optimization for GNU compilers
Honor the `INTERPROCEDURAL_OPTIMIZATION` target property for GNU
compilers by activating their link-time-optimization (LTO) flags.
2017-03-30 14:56:52 -04:00
Ruslan Baratov
1588a577d1 Add policy CMP0069 to enforce INTERPROCEDURAL_OPTIMIZATION
Previously the `INTERPROCEDURAL_OPTIMIZATION` target property was
honored only for the Intel compiler on Linux and otherwise ignored.  In
order to add support for more compilers incrementally without changing
behavior in the future, add a new policy whose NEW behavior enforces the
`INTERPROCEDURAL_OPTIMIZATION` property.  Add flags for supported
compilers and otherwise produce an error.
2017-03-30 14:56:46 -04:00
Ruslan Baratov
a75757004b Refactoring: s,GetFeatureAsBool,IsIPOEnabled,
Method 'GetFeatureAsBool' is used only with 'INTERPROCEDURAL_OPTIMIZATION'
feature. Substituting 'GetFeatureAsBool' with 'IsIPOEnabled'.
2017-03-30 10:16:30 -04:00
Gregor Jasny
060be58c6f Xcode: Properly handle Bundle Resources with more than one hierarchy level
Issue: #16680
2017-03-22 23:36:11 +01:00
Brad King
075f645409 Support WINDOWS_EXPORT_ALL_SYMBOLS with .def files
The `WINDOWS_EXPORT_ALL_SYMBOLS` target property exports all symbols
found in object files explicitly given to the linker.  However, the
linker may also find additional symbols in dependencies and copy them
into the linked binary (e.g. from `msvcrt.lib`).  Provide a way to
export an explicit list of such symbols by adding a `.def` file as a
source file.

Fixes: #16473
2017-03-21 10:02:34 -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
Brad King
25d261efa7 Refactor module definition file selection
Create a `ModuleDefinitionInfo` structure for each configuration of a
target to hold corresponding information about the selected module
definition file (`.def` source).
2017-03-09 16:25:14 -05:00