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

namespace with multiple project #34

Open
OlivierLDff opened this issue Oct 22, 2022 · 4 comments
Open

namespace with multiple project #34

OlivierLDff opened this issue Oct 22, 2022 · 4 comments

Comments

@OlivierLDff
Copy link
Contributor

OlivierLDff commented Oct 22, 2022

Hi I would like to know if a use case is possible.
I want to create 2 targets : projectname_target1 & projectname_target2. When I install them, I want them to be available with an alias: projectname::target1 & projectname::target2.
Can packageProject achieve this result? Right now I'm have projectname::projectname_target2.

Thank you for the library.

@ClausKlein
Copy link
Contributor

I have experimented with something like that: https://github.com/ClausKlein/cmake-example-component-lib#readme

@OlivierLDff
Copy link
Contributor Author

Can you point me to the relevant part in the code?

@ClausKlein
Copy link
Contributor

Can you point me to the relevant part in the code?

see ClausKlein/cmake-example-component-lib#5

@LXYan2333
Copy link

I tried @ClausKlein 's solution. It works!

short version:

suppose you have exported projectname_target1 in

packageProject(NAME projectname_target1 ……)

then for other targets you want to export:

add_library(projectname::projectname_target2 ALIAS projectname_target2)

……

install(TARGETS projectname_target2
        EXPORT  projectnameTargets)

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