summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetLinkLibrariesCommand.cxx
Commit message (Collapse)AuthorAgeFilesLines
* cmGeneratorExpressionNode: implement `COMPILE_ONLY` genexBen Boeckel2023-04-121-0/+1
| | | | | | | | | | | | | | | | This generator expression is the inverse of `LINK_ONLY` and only coveys usage requirements for the purposes of compilation. Its intended use is to avoid needing to export targets that do not have link usage requirements (e.g., header-only libraries) when used by another target. It will also be used to represent private usage requirements on exported C++ module-containing targets in the future. Eventually there should be logic to collapse nesting of `$<COMPILE_ONLY>` and `$<LINK_ONLY>` when generating instances of either. A TODO is left in the code for this case. See: #15415
* Merge topic 'check-library-properties-fix-performances-regression'Brad King2022-09-091-3/+0
|\ | | | | | | | | | | | | | | 985b4c82a6 Check link libraries properties: fix performances regression a47eef32a3 renames method FinalizeTargetCompileInfo() in FinalizeTargetConfiguration(). Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7651
| * Check link libraries properties: fix performances regressionMarc Chevrier2022-09-071-3/+0
| | | | | | | | Fixes: #23939
* | target_*: Fix cross-directory call backtracesBrad King2022-08-221-3/+5
|/ | | | | | | Record the call-site backtrace, not the current backtrace of the target's directory. Fixes: #23873
* cmSystemTools: Fix 'ErrorOccurred' spellingFeRD (Frank Dana)2022-06-131-2/+2
| | | | | | | | Rename the booleans 's_ErrorOccured' and 's_FatalErrorOccured' to 's_ErrorOccurred' and 's_FatalErrorOccurred', respectively. Rename the getters and setters to 'Get[Fatal]ErrorOccurred' and 'Set[Fatal]ErrorOccurred', and fix all uses across the codebase.
* Merge topic 'tll-genex-concat'Brad King2022-03-171-2/+27
|\ | | | | | | | | | | | | | | add64399c5 target_link_libraries: Restore LINK_ONLY for multiple static lib dependencies Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !7078
| * target_link_libraries: Restore LINK_ONLY for multiple static lib dependenciesBrad King2022-03-161-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit c1e812ad4f (target_link_libraries: Improve tolerance of unquoted generator expressions, 2022-02-15, v3.23.0-rc2~11^2) we accumulate consecutive non-keyword arguments to recover an unquoted generator expression as a single entry. When given multiple consecutive non-genex library names, the grouping breaks our logic that expects each entry is either a raw target name or a genex. Revise the logic to only accumulate multiple arguments when they end inside a partial genex. This bug caused `target_link_libraries` to stop wrapping static library private dependencies in `$<LINK_ONLY:...>` for `INTERFACE_LINK_LIBRARIES` when multiple consecutive library names are given. Add a test case covering that behavior. Fixes: #23302
* | Merge topic 'tll-genex-concat'Brad King2022-02-161-102/+138
|\ \ | |/ | | | | | | | | | | | | | | | | c1e812ad4f target_link_libraries: Improve tolerance of unquoted generator expressions 5571a31648 target_link_libraries: Handle keyword arguments in dedicated code path 42590df9f9 target_link_libraries: Remove likely-broken ancient compatibility check Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !6989
| * target_link_libraries: Improve tolerance of unquoted generator expressionsBrad King2022-02-151-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to commit 1d709ea2f5 (cmGeneratorTarget: Propagate backtraces from INTERFACE_LINK_LIBRARIES, 2021-12-15, v3.23.0-rc1~228^2), the value of `INTERFACE_LINK_LIBRARIES` was a single string. If an unquoted generator expression passed to `target_link_libraries` contained `;` and became multiple arguments, they would all accumulate as a single `;`-separated list in the value of `INTERFACE_LINK_LIBRARIES`. Since that commit, each argument to `target_link_libraries` is placed in `INTERFACE_LINK_LIBRARIES` as a separate entry, as has long been the case for `LINK_LIBRARIES`. That behavior change broke projects that were accidentally relying on accumulation in `INTERFACE_LINK_LIBRARIES` to produce complete generator expressions containing `;`. Teach `target_link_libraries` to accumulate consecutive non-keyword arguments into a single entry before placing them in `LINK_LIBRARIES` or `INTERFACE_LINK_LIBRARIES`. For example, treat `a b c` as if they were written as `"a;b;c"`. This restores the previously accidental support for unquoted generator expressions in `INTERFACE_LINK_LIBRARIES`, and also enables it for `LINK_LIBRARIES`. For now, do not drop the `target_link_libraries` documentation that recommends quoting generator expressions. Quoting is still important to populate `LINK_LIBRARIES` in CMake 3.22 and below, and is also good practice to keep generator expressions whole. Fixes: #23203
| * target_link_libraries: Handle keyword arguments in dedicated code pathBrad King2022-02-151-83/+100
| |
| * target_link_libraries: Remove likely-broken ancient compatibility checkBrad King2022-02-151-18/+3
| | | | | | | | | | | | | | | | | | Since commit daa6d2bc04 (ENH: updated handling of debug and optimized target link libraries, 2006-11-29, v2.6.0~2471) the ancient `<lib>_LINK_TYPE` compatibility lookup was done using the name of the dependent target for which `target_link_libraries` is called, rather than the name of the library dependency being considered. This code probably does nothing. Remove it.
* | Genex: Add $<LINK_LIBRARY:...>Marc Chevrier2022-02-071-0/+3
|/ | | | | | | | This generator expression offers the capability, for the link step, to decorate libraries with prefix/suffix flags and/or adding any specific flag for each library. Fixes: #22812, #18751, #20078, #22703
* Source: Fix clang -Wimplicit-fallthrough warningsSean McBride2021-09-281-0/+4
|
* Rename cmProp in cmValueMarc Chevrier2021-09-211-2/+2
|
* cmGeneratorTarget: Refactor link item lookupBrad King2021-05-281-1/+1
| | | | | Look up items individually so the call sites can do something with the result besides appending to a vector.
* cmMakefile: Inline GetExecutionContext at call sitesBrad King2020-09-281-1/+2
| | | | | The method only had one line, and its implementation is more clear at the call sites than the method name.
* cmMakefile::GetDefinition: return cmPropVitaly Stakhovsky2020-09-021-4/+4
|
* Merge topic 'out-of-dir-link-list'Brad King2020-01-171-82/+118
|\ | | | | | | | | | | | | | | | | f0e67da061 target_link_libraries: Fix out-of-dir linking of a list of targets acee629103 cmTargetLinkLibrariesCommand: Move HandleLibrary to helper struct ba675f1ecc Tests: Enable CMP0022 in ExportImport out-of-dir linking case Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4226
| * target_link_libraries: Fix out-of-dir linking of a list of targetsBrad King2020-01-161-27/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In a case like target_link_libraries(targetInOtherDir PUBLIC "$<1:a;b>") then all entries in the list need to be looked up in the caller's scope. Previously our `::@(directory-id)` suffix would apply only to the last entry. Instead surround the entire entry by a pair `::@(directory-id);...;::@` so that the `::@` syntax can encode a directory lookup scope change evaluated as the list is processed. Fixes: #20204
| * cmTargetLinkLibrariesCommand: Move HandleLibrary to helper structBrad King2020-01-161-65/+82
| |
* | cmMakefile: modernize memory managementMarc Chevrier2020-01-141-4/+3
|/
* target_link_libraries: Add FIXME comment for out-of-dir genex listBrad King2020-01-101-0/+4
| | | | Issue: #20204
* cmTarget: add std::string overloadsVitaly Stakhovsky2019-12-141-6/+5
|
* cmTargetLinkLibrariesCommand: Port away from cmCommandRegina Pfeifer2019-09-211-123/+138
|
* Refactor: Use cmStrCat to construct error stringsAsit Dhal2019-09-181-35/+39
| | | | | Replace string construction using std::stringstream with cmStrCat and cmWrap.
* clang-tidy: modernize-deprecated-headersRegina Pfeifer2019-09-161-1/+1
|
* Source sweep: Use cmStrCat for string concatenationSebastian Holtermann2019-08-221-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is generated by a python script that uses regular expressions to search for string concatenation patterns of the kind ``` std::string str = <ARG0>; str += <ARG1>; str += <ARG2>; ... ``` and replaces them with a single `cmStrCat` call ``` std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...); ``` If any `<ARGX>` is itself a concatenated string of the kind ``` a + b + c + ...; ``` then `<ARGX>` is split into multiple arguments for the `cmStrCat` call. If there's a sequence of literals in the `<ARGX>`, then all literals in the sequence are concatenated and merged into a single literal argument for the `cmStrCat` call. Single character strings are converted to single char arguments for the `cmStrCat` call. `std::to_string(...)` wrappings are removed from `cmStrCat` arguments, because it supports numeric types as well as string types. `arg.substr(x)` arguments to `cmStrCat` are replaced with `cm::string_view(arg).substr(x)`
* Merge topic 'out-of-dir-linking-private-deps'Brad King2019-05-011-2/+2
|\ | | | | | | | | | | | | 3d3713121b target_link_libraries: Fix static library private deps in other dirs Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3276
| * target_link_libraries: Fix static library private deps in other dirsBrad King2019-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | In commit a1ad0a699b (target_link_libraries: Allow use with targets in other directories, 2018-09-07, v3.13.0-rc1~94^2) we accidentally broke the logic that adds `$<LINK_ONLY:...>` to private dependencies of static libraries in their `INTERFACE_LINK_LIBRARIES` in the case that the dependency is added from outside the directory creating the library. The check for a valid target name should apply to the original name specified by the caller and not the encoded cross-directory reference. Fixes: #19197
* | Factor out enum MessageType into dedicated headerBruno Manganelli2019-01-161-26/+27
| | | | | | | | Reduce the number of files relying on `cmake.h`.
* | target_link_libraries: Propagate dependencies of object librariesKyle Edwards2018-12-101-1/+2
| | | | | | | | | | | | | | | | | | Prior to this commit, linking against an object library did not propagate private link dependencies of object libraries to their consuming targets. This change implements the correct behavior. Fixes: #18692 Co-Author: Brad King <brad.king@kitware.com>
* | clang-tidy: Fix readability-static-accessed-through-instanceRegina Pfeifer2018-11-211-3/+5
|/ | | | Enable the check in .clang-tidy and fix all warnings.
* target_link_libraries: Allow use with targets in other directoriesBrad King2018-09-121-22/+58
| | | | | | | | | | | | | | | | | | | | | Previously the command did not allow naming targets on the LHS that were not created in the calling directory. Lift this restriction to enable more flexible use by projects. Targets named on the RHS will need to be looked up during generation in the scope of the call site rather than the scope of the LHS target. Introduce an internal syntax in `[INTERFACE_]LINK_LIBRARIES` properties to specify target names that need to be looked up in a directory other than that containing the target on which the property is set. Add minimal documentation of the syntax to help users that encounter it. Unfortunately CMake previously did allow such calls in the case that only `INTERFACE` libraries are specified, but those libraries would be looked up in the target's directory rather than the caller's. Add policy `CMP0079` to enable the new behavior with new lookup scope in a compatible way. Fixes: #17943
* Revert "target_link_libraries: Allow use with targets in other directories"Brad King2018-07-031-9/+2
| | | | | | | | | Revert commit v3.12.0-rc1~82^2 (target_link_libraries: Allow use with targets in other directories, 2018-05-11). The RHS target scoping and visibility rules are not clear and will need further investigation before the feature can be added. Issue: #17943
* Revise C++ coding style using clang-format-6.0Kitware Robot2018-06-011-2/+3
| | | | | | | | | | | | 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.
* target_link_libraries: Allow use with targets in other directoriesPatrick Stotko2018-05-151-2/+9
| | | | | | | | Previously the command did not allow naming targets on the LHS that were not created in the calling directory. Lift this restriction to enable more flexible use by projects. Fixes: #17943
* objlib: Allow other libraries to link to `OBJECT` libraries.Deniz Bahadir2018-03-011-2/+3
| | | | | | | | 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
* objlib: Allow `OBJECT` libraries to link to other libraries.Deniz Bahadir2018-03-011-10/+0
| | | | | | | | | | The proper way to use libraries is now through `target_link_libraries` for things such as usage requirements, compile definitions, include directories, etc. To facilitate this, allow `OBJECT` libraries to "link" to other libraries. Co-Author: Ben Boeckel <ben.boeckel@kitware.com> Issue: #14778
* Various typo fixesLuz Paz2018-01-031-1/+1
| | | | Some are user-facing. Others are source comments.
* target_link_libraries: Simplify implementation and add comments.Deniz Bahadir2017-11-301-54/+67
| | | | | | | | The implementation of `target_link_libraries` did grow over the years when new features where added. This commit cleans up the implementation and adds comments to better document its intention. The behavior of `target_link_libraries` itself is left untouched.
* target_link_libraries: Slightly fix some error-messages.Deniz Bahadir2017-11-291-13/+13
| | | | | Some error-messages are slightly adjusted to better tell what invocation would be correct instead. Tests are adjusted accordingly.
* target_link_libraries: Return earlier on some error.Deniz Bahadir2017-11-291-17/+17
|
* Teach target_* commands to set INTERFACE properties of IMPORTED targetsDeniz Bahadir2017-10-261-1/+29
| | | | | | | | | | | Now, several `INTERFACE_*` properties can be set on `IMPORTED` targets, not only via `set_property` and `set_target_properties` but also via `target_compile_definitions`, `target_compile_features`, `target_compile_options`, `target_include_directories`, `target_sources` and `target_link_libraries`. Fixes: #15689 Issue: #17197
* Meta: modernize old-fashioned loops to range-based `for`.Pavel Solodovnikov2017-09-121-6/+4
| | | | | | Changes done via `clang-tidy` with some manual fine-tuning for the variable naming and `auto` type deduction where appropriate.
* target_link_libraries: Allow linking to UNKNOWN IMPORTED GLOBAL libsBrad King2017-08-311-0/+1
| | | | | | This combination was accidentally rejected. Allow it and add a test. Fixes: #17245
* Use C++11 nullptrDaniel Pfeifer2017-08-241-2/+2
|
* Include necessary headers in commandsDaniel Pfeifer2016-10-261-0/+10
|
* Separate compilation for commands included in cmBootstrapCommands2Daniel Pfeifer2016-10-211-0/+3
|
* cmState: Move TargetType enum to separate namespaceStephen Kelly2016-10-191-8/+8
|
* cmMakefile: Inline method into callerStephen Kelly2016-10-071-1/+29
| | | | | The various uses of AddLinkLibraryForTarget are going away. This is the only remaining non-deprecated use.