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 target with namespace #1234

Open
xkszltl opened this issue Nov 2, 2020 · 4 comments
Open

CMake target with namespace #1234

xkszltl opened this issue Nov 2, 2020 · 4 comments

Comments

@xkszltl
Copy link
Contributor

xkszltl commented Nov 2, 2020

Is your feature request related to a problem? Please describe.

We found a case in our CMake script where jsoncpp, rather than jsoncpp_lib, is mistakenly used in target_link_libraries().
As a result, a system installed jsoncpp is linked by -ljsoncpp, not what we found with find_package().

Describe the solution you'd like

I think the more popular solution is to create namespaced targets like jsoncpp::shared and jsoncpp::static, and maybe also jsoncpp::jsoncpp pointing to the default.

Describe alternatives you've considered

Add a target jsoncpp equivalent to jsoncpp::jsoncpp mentioned above, to shadow the file version of jsoncpp.

@dota17
Copy link
Member

dota17 commented Nov 4, 2020

I don't know much about cmake namespace target, but I'll investigate it late.
And for now, can you see if this PR #1214 can solve your problem?

@xkszltl
Copy link
Contributor Author

xkszltl commented Nov 4, 2020

I mention namespacing because, when people see jsoncpp or jsoncpp_lib in target_link_libraries(), it's hard to tell whether it's a file or target.
Although the intention is to use target, when editing around people can easily make mistakes and write it as jsoncpp, which can still "work" when linker found a file matching the name.
We want to avoid this.

@Andres6936
Copy link

See #1374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants