STYLE: Add PUBLIC to target_link_libraries and elastix_link_itk calls - #1457
Merged
Conversation
Using Notepad++, Replace in Files, doing
Find what: `(target_link_libraries\([^ \r\n]+) `
Replace with: `\1 PUBLIC `
Find what: `(target_link_libraries\([^ \r\n]+)$`
Replace with: `\1 PUBLIC`
Find what: `(elastix_link_itk\([^ \r\n]+) MODULES`
Replace with: `\1 PUBLIC MODULES`
Filters: `CMakeLists*.txt`
(*) Regular expression
It appears clearer, and more modern, to explicitly specify the scope (by adding the `PUBLIC` keyword).
Doing so would prevent a CMake error when having multiple target_link_libraries calls on the same target, saying:
The plain signature for target_link_libraries has already been used with
the target "...". All uses of target_link_libraries with a target must
be either all-keyword or all-plain.
As experienced with CMake 4.3.2
N-Dekker
force-pushed
the
target_link_libraries-PUBLIC
branch
from
July 9, 2026 13:34
ce8d0de to
7fcad33
Compare
Contributor
|
Look good. Ideally further work would include more specific specification on which dependencies libraries are using in the header ( PUBLIC ) vs the libraries whose headers are only used in compiled files ( PRIVATE ). And there is also the potential case where a header/library is only used in a header file but not compiled by the library ( INTERFACE ). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using Notepad++, Replace in Files, doing
Find what:
(target_link_libraries\([^ \r\n]+)Replace with:
\1 PUBLICFind what:
(target_link_libraries\([^ \r\n]+)$Replace with:
\1 PUBLICFind what:
(elastix_link_itk\([^ \r\n]+) MODULESReplace with:
\1 PUBLIC MODULESFilters:
CMakeLists*.txt(*) Regular expression
It appears clearer, and more modern, to explicitly specify the scope (by adding the
PUBLICkeyword).Doing so would prevent a CMake error when having multiple target_link_libraries calls on the same target, saying:
As experienced with CMake 4.3.2
@blowekamp Please check! Do you agree that the
PUBLICkeyword is preferred over leaving the scope unspecified (implicitly transitive)?