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 the library usable with FetchContent #382

Closed
eyalroz opened this issue Jul 9, 2022 · 8 comments
Closed

Make the library usable with FetchContent #382

eyalroz opened this issue Jul 9, 2022 · 8 comments

Comments

@eyalroz
Copy link
Owner

eyalroz commented Jul 9, 2022

I could probably make the library usable with FetchContent, so that this would work:

FetchContent_Declare(cuda_api_wrappers_fc
    GIT_REPOSITORY https://github.com/eyalroz/cuda-api-wrappers.git
    GIT_TAG v12.34.45 # Replace this with a real available version
)
FetchContent_MakeAvailable(cuda_api_wrappers_fc)
@EmmanuelMess
Copy link

Added a bounty of u$d 5 to the issue.

@eyalroz
Copy link
Owner Author

eyalroz commented Jul 10, 2022

Well, that was easy... the library is already usable with FetchContent. I just checked...

@eyalroz eyalroz closed this as completed Jul 10, 2022
@EmmanuelMess
Copy link

Missing include(FetchContent) and the library probably doesnt need to end in _library at the end. And there is a target_link_libraries(Project cuda nvrtc)line that is still required for the build to run.

@eyalroz
Copy link
Owner Author

eyalroz commented Jul 10, 2022

Missing include(FetchContent)

Yes, I'll add that.

and the library probably doesnt need to end in _library at the end.

That's to avoid any potential clashes with stuff within the library; although maybe it's not 100% necessary.

And there is a target_link_libraries(Project cuda nvrtc) line that is still required for the build to run.

No, it's not... if you target_link_libraries(my_tgt runtime-and-driver) (and that's all you need then it works and links against the relevant libraries.

@EmmanuelMess
Copy link

EmmanuelMess commented Jul 10, 2022

target_link_libraries(my_tgt runtime-and-driver)can't get this to work, it doesnt find#include <cuda/api.hpp>` maybe its a mistake in the include path?

Nvm I tried to do target_link_libraries(tgt cuda-api-wrappers_library). works now :)

@eyalroz
Copy link
Owner Author

eyalroz commented Jul 11, 2022

Really? That's weird... Anyway, I'll have another look.

@eyalroz
Copy link
Owner Author

eyalroz commented Jul 11, 2022

So, I'm going to improve things! You will now be able to use the same namespace with find_package and with FetchContent!

eyalroz added a commit that referenced this issue Jul 11, 2022
…proach

* Adopt KitWare's Craig Scott's suggested approach to make CMake projects more compatible with use with `FetchContent`, as detailed [here](https://stackoverflow.com/a/72943178/1593077) (thanks goes to Alex Reinking). Now, projects using this library via `FetchContent` will also get the same namespaced target names as if they had used `find_package()`, plus there will now be much less chance of target name clashing.
* Removing some less-useful comment text from `CMakeLists.txt`
* Adjusting the `README.md` accordingly
eyalroz added a commit that referenced this issue Jul 11, 2022
…proach

* Adopt KitWare's Craig Scott's suggested approach to make CMake projects more compatible with use with `FetchContent`, as detailed [here](https://stackoverflow.com/a/72943178/1593077) (thanks goes to Alex Reinking). Now, projects using this library via `FetchContent` will also get the same namespaced target names as if they had used `find_package()`, plus there will now be much less chance of target name clashing.
* Removing some less-useful comment text from `CMakeLists.txt`
* Adjusting the `README.md` accordingly
@EmmanuelMess
Copy link

@eyalroz Please claim the bounty :)

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

No branches or pull requests

2 participants