Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Switch suitable PUBLIC target_link_libraries to PRIVATE #6178

Merged
merged 1 commit into from Nov 16, 2022

Conversation

ryanvolz
Copy link
Contributor

@ryanvolz ryanvolz commented Sep 19, 2022

Description

Declaring a library as PUBLIC in target_link_libraries tells downstream linkers of the target to also need to link to the PUBLIC libraries. This is necessary when the headers of those libraries are required by the public headers of the target library. There were some instances where linked libraries were declared PUBLIC but were not required to use the public headers, so they have been switched to PRIVATE declarations. This will allow OOT modules to reduce their linking and dependencies in some cases.

This could use some scrutiny from people more familiar with the various modules that are affected. I made these changes based purely on searching for every target_link_libraries call and then searching the public headers to see if the linked libraries were #included somewhere. It's very possible I missed things.

Boost::program_options used to be a PUBLIC link of gnuradio-runtime, but I think it makes more sense as something that is linked by individual executables that need it, so I moved that where appropriate.

This also should conform to the new CMake formatting, which resulted in some more formatting changes in files that I guess were missed in that earlier PR.

Related Issue

Fixes #6109.

Which blocks/areas does this affect?

CMake in many modules.

Testing Done

None besides CI build testing. The real effects of this are downstream with building OOTs, so it would be good to try building ones that use affected modules. That might be easiest to do if this were merged just to main first to see if anyone notices problems.

Checklist

@willcode willcode added CMake Hold Backport Hold off on backport labels Sep 19, 2022
@ryanvolz ryanvolz marked this pull request as ready for review September 19, 2022 21:52
Declaring a library as PUBLIC in target_link_libraries tells downstream
linkers of the target to also need to link to the PUBLIC libraries. This
is necessary when the headers of those libraries are required by the
public headers of the target library. There were some instances where
linked libraries were declared PUBLIC but were not required to use the
public headers, so they have been switched to PRIVATE declarations. This
will allow OOT modules to reduce their linking and dependencies in some
cases.

Signed-off-by: Ryan Volz <ryan.volz@gmail.com>
Copy link
Contributor

@mormj mormj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to let this one sit on main. Thanks for all the interface cleanup!

@mormj mormj merged commit 501da23 into gnuradio:main Nov 16, 2022
14 checks passed
@ryanvolz ryanvolz deleted the reduce_public_linking branch November 17, 2022 03:12
@willcode willcode added the Backport-3.10 Should be backported to 3.10 label Nov 17, 2022
@willcode willcode added ported-to-3.10 Has been ported to 3.10 and removed Hold Backport Hold off on backport Backport-3.10 Should be backported to 3.10 labels Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake ported-to-3.10 Has been ported to 3.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gnuradio-blocks should not link publicly to libsndfile
3 participants