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

Make Yato a library type target in cmake #2

Open
ckorikov opened this issue Feb 6, 2021 · 5 comments
Open

Make Yato a library type target in cmake #2

ckorikov opened this issue Feb 6, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@ckorikov
Copy link

ckorikov commented Feb 6, 2021

Why not to use

add_library(Yato INTERFACE)

instead of add_custom_target ?

https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries

@agruzdev
Copy link
Owner

agruzdev commented Feb 6, 2021

As I see the INTERFACE target doesn't compile the provided source files (since 3.19 it can contain them), but the Yato library can be either header-only or contain .cpp files depending on build flags. So I would like to build it as a separate target, when it has sources.

@agruzdev agruzdev added the question Further information is requested label Feb 7, 2021
@ckorikov
Copy link
Author

ckorikov commented Feb 9, 2021

I see. Actually, I asked because it could be pretty convenient to use the library in the following way.

add_library(MyLib)
target_link_libraries(MyLib PRIVATE Yato)

According to cmake specification it seems to be impossible for custom targets.

https://cmake.org/cmake/help/latest/command/target_link_libraries.html

@agruzdev
Copy link
Owner

agruzdev commented Feb 9, 2021

If you use only the core headers, then you dont need to add link to the Yato at all, since it is header-only library, just include_directories( ) would be enough.
If you use the config or actors module, the link the YatoConfig or YatoActors libraries directly, like this:

add_library(MyLib)
target_link_libraries(MyLib PRIVATE YatoConfig)

Let me know if you think it is still inconvenient

@ckorikov
Copy link
Author

ckorikov commented Feb 9, 2021

Right, but target_link_libraries also enables usage requirements propagation from a child to a parent target. It can be only headers in the header-only library or something else in other cases. From the user side, it looks like a general way to connect a dependency that hides its compilation details.

@agruzdev
Copy link
Owner

agruzdev commented Feb 9, 2021

I got your point now. I'll think how I can improve this...

@agruzdev agruzdev added enhancement New feature or request and removed question Further information is requested labels Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants