summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetLinkLibrariesCommand.cxx
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Simplify CMake per-source license noticesBrad King2016-09-271-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
* Avoid else after returnDaniel Pfeifer2016-09-161-4/+3
|
* use empty method to check for emptynessDaniel Pfeifer2016-09-151-1/+1
|
* use CM_NULLPTRDaniel Pfeifer2016-06-281-2/+2
|
* Revise C++ coding style using clang-formatKitware Robot2016-05-161-255/+178
| | | | | | | | | | | | | Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * 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.
* Remove `//------...` horizontal separator commentsBrad King2016-05-091-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Modern editors provide plenty of ways to visually separate functions. Drop the explicit comments that previously served this purpose. Use the following command to automate the change: $ git ls-files -z -- \ "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" | egrep -z -v "^Source/cmCommandArgumentLexer\." | egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmDependsJavaLexer\." | egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmExprLexer\." | egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmFortranLexer\." | egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmListFileLexer\." | egrep -z -v "^Source/cm_sha2" | egrep -z -v "^Source/(kwsys|CursesDialog/form)/" | egrep -z -v "^Utilities/(KW|cm).*/" | xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}' This avoids modifying third-party sources and generated sources.
* Fix export of STATIC library PRIVATE non-target dependenciesBrad King2016-02-171-5/+2
| | | | | | | | | | | | | | | | | | | In commit v3.5.0-rc1~43^2 (Fix export of STATIC library PRIVATE dependencies with CMP0022 NEW, 2016-01-15) we taught target_link_libraries to generate `$<LINK_ONLY:$<TARGET_NAME:dep>>` in INTERFACE_LINK_LIBRARIES instead of `$<LINK_ONLY:dep>` so that `dep` can be recognized as a target name and updated during export. However, this approach does not work when `dep` is just a plain library name and not a target because `$<TARGET_NAME:...>` requires the name of a reachable target. Since we do not know during target_link_libraries whether the name will correspond to a reachable target or not, we cannot inject the `$<TARGET_NAME:...>` expression. Revert this change and solve the original problem instead by teaching the export logic to recognize and update target names directly in `$<LINK_ONLY:...>` expressions. Reported-by: Ben Boeckel <ben.boeckel@kitware.com>
* Fix export of STATIC library PRIVATE dependencies with CMP0022 NEWBrad King2016-01-151-2/+5
| | | | | | | | | | | | | | The target_link_libraries command records the PRIVATE dependencies of a STATIC library in INTERFACE_LINK_LIBRARIES as "$<LINK_ONLY:dep>". This hides the target name from export namespacing logic inside a generator expression. When user-written generator expressions reference a target name they must put it inside a "$<TARGET_NAME:dep>" expression to allow the export logic to rename the target. In the case that the private dependency is not already a generator expression, target_link_libraries must use "$<LINK_ONLY:$<TARGET_NAME:dep>>" to allow the export logic to rename the target. Reported-by: Tamás Kenéz <tamas.kenez@gmail.com>
* cmState: Move TargetType enum from cmTarget.Stephen Kelly2015-10-141-5/+5
| | | | | | | Mostly automated: values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType") for i in "${values[@]}"; do git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
* cmTarget: Move link type enum out.Stephen Kelly2015-10-141-13/+13
| | | | Remove a reason for generate time code to depend on the cmTarget header/type.
* cmTarget: Fix diagnostic of target_link_libraries in wrong directory (#15626)Brad King2015-06-251-1/+2
| | | | | | | | | | Since commit v3.3.0-rc1~62^2~5 (cmTarget: Store only cmListFileContext for CMP0023 handling, 2015-05-18) a call to target_link_libraries on a target that was defined in another (non-ancestor) directory crashes because no execution context is left active. Fix this by getting the execution context from the actual cmMakefile where the current target_link_libraries call takes place. Test this by verifying that such calls correctly produce an error diagnostic instead of crashing.
* Port to static cmPolicies API.Stephen Kelly2015-05-041-8/+4
|
* cmake: Remove DebugConfigs member.Stephen Kelly2015-04-121-1/+1
| | | | It adds needless complexity to global property handling.
* Port all cmOStringStream to std::ostringstream.Stephen Kelly2015-01-111-6/+6
| | | | All compilers hosting CMake support the std class.
* Remove default labels from fully covered switch statements.Stephen Kelly2014-04-031-1/+0
| | | | | Allow compilers to warn when new enum values are added, making switches no-longer fully-covered.
* Merge topic 'fix_policy_diagnostics'Brad King2014-04-011-6/+8
|\ | | | | | | | | 77b581c2 Policies: omit warnings about unset policies when they are actually set to NEW
| * Policies: omit warnings about unset policies when they are actually set to NEWNils Gladitz2014-03-311-6/+8
| |
* | Remove some c_str() calls.Stephen Kelly2014-03-111-7/+7
| | | | | | | | | | | | Use the clang RemoveCStrCalls tool to automatically migrate the code. This was only run on linux, so does not have any positive or negative effect on other platforms.
* | cmTargetLinkLibrariesCommand: Use a string argumentBen Boeckel2014-03-081-5/+5
| |
* | cmTarget: Remove the project argument to FindTargetBen Boeckel2014-03-081-1/+1
|/ | | | All callers passed 0 in, so just remove the branch.
* cmMakefile: make some methods take const std::string& instead of const char*Rolf Eike Beer2014-01-161-1/+1
| | | | | | | | Most callers already have a std::string, on which they called c_str() to pass it into these methods, which internally converted it back to std::string. Pass a std::string directly to these methods now, avoiding all these conversions. Those methods that only pass in a const char* will get the conversion to std::string now only once.
* Disallow linking to utility targets (#13902).Stephen Kelly2013-11-071-0/+31
|
* Merge branch 'policy-CMP0022-fixes' into policy-CMP0022-fixes-for-masterBrad King2013-11-031-2/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolve conflict in Source/cmTarget.cxx by integrating the changes to the internal copy constructor from both sides. Also resolve a logical conflict by dropping the special case for INTERFACE_LIBRARY targets. Since cmTarget::SetMakefile already forces CMP0022 to NEW for such targets we need no special handling. Resolve conflict in Source/cmTargetLinkLibrariesCommand.h by dropping the documentation change. We will make the same change in the new location of the same documentation in a separate commit. Resolve conflicts in Tests/RunCMake/CMP0022/CMP0022-WARN-empty-old-stderr.txt Tests/RunCMake/CMP0022/RunCMakeTest.cmake by taking the side from the 'policy-CMP0022-fixes' branch.
| * CMP0022: Plain target_link_libraries must populate link interfaceBrad King2013-11-021-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CMP0022 NEW behavior is that the INTERFACE_LINK_LIBRARIES property exactly defines the link interface. The plain target_link_libraries signature says linking is transitive by default, so it should populate the property. Teach the target_link_libraries plain signature to populate the INTERFACE_LINK_LIBRARIES regardless of the CMP0022 setting. Refactor the cmTarget::ComputeLinkInterface checks that warn when the policy is not set to compare the new property to either the explicitly set old link interface properties or the link implementation fallback for all linkable target types, not just static libraries. This fixes a regression in 2.8.12.0 that caused target_link_libraries to not implement transitive linking in the plain signature once the policy CMP0022 is set to NEW.
* | target_link_libraries: Revert accidental changeBrad King2013-11-021-7/+2
| | | | | | | | | | | | | | | | In commit c4373b33 (cmTarget: Make GetProperty() const, 2013-10-29) we accidentally changed the cmTargetLinkLibrariesCommand.cxx logic in a way that looks like a local experiment leftover that went unnoticed due to the size of the other changes in the commit. Revert it.
* | cmTarget: Make GetProperty() const.Stephen Kelly2013-10-311-2/+7
| | | | | | | | | | | | This has follow-on effects for other methods and classes. Further work on making the use of const cmTarget pointers common can be done, particularly with a view to generate-time methods.
* | Merge topic 'fix-tll-static-private'Brad King2013-10-261-3/+8
|\ \ | |/ | | | | | | 239b0c6 Don't add invalid content to static lib INTERFACE_LINK_LIBRARIES.