618 Commits

Author SHA1 Message Date
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
2ab900c71b Merge topic 'compile-options-shell'
ce0b983216 target_compile_options: Add syntax to specify shell strings

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1841
2018-03-15 07:55:14 -04:00
Brad King
ce0b983216 target_compile_options: Add syntax to specify shell strings
Options specified via `COMPILE_OPTIONS` and `INTERFACE_COMPILE_OPTIONS`
are deduplicated, but individual options can legitimately be duplicated
when grouped with other options, e.g.

    -D A -D B

After deduplication that becomes `-D A B`.  Therefore we need a way to
treat groups of options as units during deduplication.  A simple approach
is to specify each group as one option, e.g.

    "-D A" "-D B"

However, that conflicts with options that legitimately have spaces.  To
break this ambiguity, add a `SHELL:` prefix syntax to specify that an
option should be parsed like shell command line arguments after
deduplication, e.g.

    "SHELL:-D A" "SHELL:-D B"

These will survive deduplication intact, and then be parsed to produce
`-D A -D B` on the final command line.

Fixes: #15826
2018-03-14 11:10:25 -04:00
Brad King
bdbee54a83 Merge topic 'genex-COMPILE_LANGUAGE-system-include'
1b5e52fd65 Genex: Fix COMPILE_LANGUAGE propagation through try_compile
2deb9b7f34 Genex: Fix COMPILE_LANGUAGE in SYSTEM include directories

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1844
2018-03-13 13:42:45 -04: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
Stephan Szabo
2dc2a3eb15 Identify DLL platforms via CMAKE_IMPORT_LIBRARY_SUFFIX
Use `CMAKE_IMPORT_LIBRARY_SUFFIX` to identify platforms that have DLL
import libraries rather than memorizing a list of platform names.

Fixes: #16801
2018-03-09 08:09:21 -05:00
Brad King
dc38970f83 Merge topic 'object-library-linking'
7776ce98c3 Tests: Add cases for usage requirements of linked object libs
bafe655b11 Help: Document linking behavior of OBJECT libraries
57538224d0 objlib: Link object-files from `OBJECT` libraries.
9a7f039ee7 objlib: Allow `OBJECT` libraries to link to `OBJECT` libraries.
dfb6e84082 objlib: Allow other libraries to link to `OBJECT` libraries.
51249e69ea objlib: Allow `OBJECT` libraries to link to other libraries.
e22c45d4c9 Tests: Teach RunCMake to ignore AIX ld warnings about GNU atexit

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Pavel Solodovnikov <hellyeahdominate@gmail.com>
Acked-by: John Drouhard <john@jmdtech.org>
Merge-request: !1524
2018-03-05 09:01:42 -05:00
Deniz Bahadir
57538224d0 objlib: Link object-files from OBJECT libraries.
Note: This finally links the object-files of the `OBJECT` library from
the right-hand side of `target_link_libraries` to the target on the
left-hand side. However, this will only happen with directly linked
`OBJECT` libraries, not with `OBJECT` libraries "linked" through
property `INTERFACE_LINK_LIBRARIES` of a target on the right-hand side!

Fixes: #14778
2018-03-01 09:24:25 -05:00
Deniz Bahadir
9a7f039ee7 objlib: Allow OBJECT libraries to link to OBJECT libraries.
Note: This still does not link the object-files of the `OBJECT` library
from the right-hand side of `target_link_libraries` to the target on the
left-hand side. (In this particular case of another `OBJECT` library on
the left-hand side this would not make any sense anyway. The target on
the left-hand side has no link-step.)

Issue: #14778
2018-03-01 09:24:25 -05:00
Deniz Bahadir
dfb6e84082 objlib: Allow other libraries to link to OBJECT libraries.
Note: This only allows `OBJECT` libraries to be on the right-hand side
of `target_link_libraries` but still does not link its object-files to
the target on the left-hand side.

Issue: #14778
2018-03-01 09:24:24 -05:00
Brad King
1ac042aa67 Do not generate rules for .def generation where not supported
Our `cmake -E __create_def` helper used for `WINDOWS_EXPORT_ALL_SYMBOLS`
and merging of multiple `.def` files is available only with CMake hosted
on Windows.  However, we may generate use of it on other platforms since
commit v3.9.0-rc1~405^2 (Support WINDOWS_EXPORT_ALL_SYMBOLS with `.def`
files, 2017-03-13) when multiple `.def` files are listed.  This results
in a build error because the tool doesn't exist.

Fix our logic to avoid using the tool on non-Windows platforms.  Instead
silently ignore all but the first `.def` source as we did before.

Issue: #17773
2018-02-28 08:52:19 -05:00
Brad King
f8ca0ab3ac Merge topic 'std-string-apis'
653b8946 Reduce raw string pointers usage.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1729
2018-02-01 08:05:33 -05:00
Ben Boeckel
88ed556d99 cmGeneratorTarget: make keyword strings const 2018-01-31 11:04:36 -05: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
Brad King
a3bba2a5ad Merge topic '17431-iphone-deployment-target'
4017bf40 Darwin: Emit deployment target that matches the SDK
8f4663ff Xcode: rename embedded SDK query function

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1447
2018-01-08 09:58:11 -05:00
Luz Paz
3ab7bf8285 Various typo fixes
Some are user-facing. Others are source comments.
2018-01-04 06:52:01 +11:00
Gregor Jasny
8f4663ffb2 Xcode: rename embedded SDK query function 2017-12-22 21:56:53 +01:00
Pavel Solodovnikov
66c0b36d75 objlib: fix unchecked insertions in cmGeneratorTarget::GetLanguages 2017-12-20 17:37:15 +03:00
Matthias Maennich
85a7eaba5e cmGeneratorTarget: remove dead code
explicitLibraries can never be nullptr at this point
2017-10-05 14:53:51 +02: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
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +03: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
Brad King
bd77717800 Merge topic 'fix-genex-SOURCES'
068cc545 Genex: Fix TARGET_PROPERTY value of SOURCES

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1218
2017-09-01 10:25:08 -04:00
Brad King
068cc545d9 Genex: Fix TARGET_PROPERTY value of SOURCES
Refactoring in commit v3.8.0-rc1~445^2~2 (cmTarget: Move sanity checks
and computed property access to callers, 2016-10-13) exposed a typo in
commit v3.8.0-rc1~445^2~3 (cmGeneratorTarget: Implement
cmTargetPropertyComputer interface, 2016-10-13).  Together they broke
the `$<TARGET_PROPERTY:mytgt,SOURCES>` generator expression in the case
that the `SOURCES` target property is populated in part by the
`target_sources` command.  Add the missing `;`-separator.

Fixes: #17243
2017-09-01 10:23:37 -04:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Daniel Pfeifer
cbcfb79f9c Use C++11 unordered containers 2017-08-22 23:05:27 +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
787017451c Merge topic 'objlib-own-target-objs'
d89e10cd Diagnose object library self-reference

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1053
2017-07-18 11:12:00 -04:00
Brad King
b97878643b Merge branch 'objlib-own-target-objs' into release-3.9 2017-07-17 11:42:18 -04: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
4bafa3922e Android: Always add standard include directories last
The logic added in commit v3.6.0-rc1~30^2 (Add a variable to specify
language-wide system include directories, 2016-05-24) to use
`CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES` incorrectly filters them by
`CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES`.  Rather than recognizing
this, commit v3.8.0-rc1~60^2 (Android: Pass sysroot include directory
explicitly, 2017-01-20) worked around the problem by incorrectly
removing `/usr/include` from `CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES`
so it worked in `CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES`.

By not filtering out `/usr/include` from user-specified include
directories, we allow the code

    include_directories(${CMAKE_SYSROOT}/usr/include)

to place the include directory too early on the command line.

Fix support for standard include directories to not be filtered by
implicit include directories, and do not remove `/usr/include` from the
list of implicit include directories for Android builds.  Add a test
case to verify that an explicit `/usr/include` is ignored in favor
of the standard directory at the end.

Fixes: #17059
2017-07-13 10:03:58 -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
c6ea3f01c3 Merge topic 'lint-function-args'
b1ec5dea Pass large types by const&, small types by value

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !927
2017-06-05 09:44:24 -04:00
Daniel Pfeifer
b1ec5deaf1 Pass large types by const&, small types by value 2017-06-04 00:48:21 +02:00
Daniel Pfeifer
8d7b3ef5d4 Provide and use CM_FALLTHROUGH 2017-06-03 08:38:51 +02:00
Pavel Solodovnikov
db2d46e2dd Remove second arg: npos in substr usages 2017-06-01 14:19:52 -04:00
Pavel Solodovnikov
8b6f439ef2 Access string npos without instance 2017-06-01 14:19:51 -04:00
Ruslan Baratov
469813cce0 CMP0069: Suppress warning if we are in 'try_compile'
Fixes: #16855
2017-05-10 09:41:40 -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
Brad King
fa338c97d7 Merge topic 'clang-tidy'
73020305 clang-tidy: avoid copy
b432e933 clang-tidy: use .empty() to check emptyness
012972a9 clang-tidy: remove reduntant .data() calls
b26577c9 clang-tidy: remove else after break and continue

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !734
2017-04-24 09:27:48 -04: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
Daniel Pfeifer
b26577c92a clang-tidy: remove else after break and continue 2017-04-21 10:44:07 +02: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
44f0d2d991 Merge topic 'objlib-extend'
eec93bce Allow OBJECT libraries to be installed, exported, and imported
93c89bc7 Genex: Allow TARGET_OBJECTS to be used everywhere
ac0cf7ff Genex: Reject TARGET_OBJECTS on non-object libraries earlier
8577978c Tests: ExportImport C code should use explicit (void) in prototypes
26cfd039 cmInstallTargetGenerator: Re-order GenerateScriptForConfig logic
25f3f22a cmGlobalGenerator: Add method to check if object file location is known
d596c550 cmGeneratorTarget: Add method to get the object file directory
930042f2 cmGeneratorTarget: Factor out a GetTargetObjectNames method
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !712
2017-04-19 10:47:31 -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