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

[REVIEW] Refine CMakeLists.txt to make it easy to be imported by external projects #541

Merged
merged 6 commits into from
Sep 8, 2020

Conversation

gigony
Copy link
Contributor

@gigony gigony commented Sep 3, 2020

  • Change CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR
  • Change CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR
  • Add 'project' statement to suppress warning messages
  • Use generator expression to refer the include folder depending on the case (build or install)
  • Ignore error if thrust is already patched

fix #540

@gigony gigony requested a review from a team as a code owner September 3, 2020 23:57
@GPUtester
Copy link
Contributor

Can one of the admins verify this patch?

2 similar comments
@GPUtester
Copy link
Contributor

Can one of the admins verify this patch?

@GPUtester
Copy link
Contributor

Can one of the admins verify this patch?

@gigony gigony changed the title Update CMakeLists.txt for gtest/gbenchmark #540 Update CMakeLists.txt for gtest/gbenchmark Sep 3, 2020
@harrism
Copy link
Member

harrism commented Sep 4, 2020

OK to test

@GPUtester
Copy link
Contributor

Please update the changelog in order to start CI tests.

View the gpuCI docs here.

@harrism
Copy link
Member

harrism commented Sep 4, 2020

@gigony in order for our CI tests to run, you will need to add an entry to CHANGELOG.md.

@harrism
Copy link
Member

harrism commented Sep 4, 2020

@germasch since I know you are helping modernize RMM's cmake, can you take a look at this PR?

Copy link
Contributor

@germasch germasch left a comment

Choose a reason for hiding this comment

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

Looks good to me (the warnings about missing project had annoyed me as well ;)

@harrism
Copy link
Member

harrism commented Sep 4, 2020

Looks good to me (the warnings about missing project had annoyed me as well ;)

Me too, but I had wrongly assumed they stemmed from the underlying googletest cmake!

- Change CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR
- Change CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR
- Add 'project' statement to suppress warning messages
- Use generator expression to refer the include folder
  depending on the case (build or install)
@gigony gigony changed the title Update CMakeLists.txt for gtest/gbenchmark Refine CMakeLists.txt to make it easy to be imported by external projects Sep 4, 2020
@germasch
Copy link
Contributor

germasch commented Sep 4, 2020

BTW, @gigony: Since you're starting to do INSTALL_INTERFACE stuff (which looks correct), I should let you know that I'd been working on making rmm installable together with a cmake config that allows it easily be used from another project via find_package. This has been kinda on hold since the cmake requirement was supposed to be upped to 3.17, but this hasn't happened. In any case, due to how external dependencies are currently handled, that's a bit of a non-trivial undertaking, but I'd be more than happy to discuss the past path forward if that's something you're interested in.

@gigony
Copy link
Contributor Author

gigony commented Sep 4, 2020

BTW, @gigony: Since you're starting to do INSTALL_INTERFACE stuff (which looks correct), I should let you know that I'd been working on making rmm installable together with a cmake config that allows it easily be used from another project via find_package. This has been kinda on hold since the cmake requirement was supposed to be upped to 3.17, but this hasn't happened. In any case, due to how external dependencies are currently handled, that's a bit of a non-trivial undertaking, but I'd be more than happy to discuss the past path forward if that's something you're interested in.

Thanks for sharing the information! I am happy to discuss it though merging this pull request would satisfy my need in the project I am currently working on.

In the recent revision of this pull request, I have addressed another issue (4. in #540) found while importing rmm in my project. Please help review it.
Thanks!

@germasch
Copy link
Contributor

germasch commented Sep 4, 2020

Thanks for sharing the information! I am happy to discuss it though merging this pull request would satisfy my need in the project I am currently working on.

Okay, that's good, so we're basically working on orthogonal things, you want to use rmm via add_subdirectory(), and me via find_package(), both of which are worthwhile supporting.

In the recent revision of this pull request, I have addressed another issue (4. in #540) found while importing rmm in my project. Please help review it.

Whereas I'm not too familiar with what exactly happens there, I think it'll be fixed by #538 as that gets rid of the need to patch in the first place.

Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

LGTM but I would like @kkraus14 to take a look.

@harrism harrism added CMake 3 - Ready for review Ready for review by team labels Sep 8, 2020
@harrism harrism changed the title Refine CMakeLists.txt to make it easy to be imported by external projects [REVIEW] Refine CMakeLists.txt to make it easy to be imported by external projects Sep 8, 2020
@harrism harrism requested a review from kkraus14 September 8, 2020 02:44
@@ -155,8 +155,8 @@ SET_TARGET_PROPERTIES(rmm PROPERTIES BUILD_RPATH "\$ORIGIN")
target_include_directories(rmm PUBLIC
"${THRUST_INCLUDE_DIR}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should really move to using a target for this instead of CMake variables. This path likely won't resolve properly on the importing machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gigony's goal here is to have a consuming project use rmm via add_subdirectory(rmm). For that purpose, I think this will work, since the consuming project will be built at the same time, so the include path will still be there.

You're right that this isn't going to work for a installed version of rmm -- which is my goal (in future PRs). thrust is going to be particularly hasslesome for this, since there may could be three ways of using thrust (from the cudatoolkit, installed elsewhere externally, or included via FetchContent. And in addition, thrust doesn't quite support the usual find_package() way of pulling it in :(

But for now, I believe this PR supports @gigony's use case and shouldn't break anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

And in addition, thrust doesn't quite support the usual find_package() way of pulling it in :(

I believe this was changed as of Thrust 1.9.10, where there's now a nicer CMake target and the like: https://github.com/thrust/thrust/blob/main/thrust/cmake/README.md

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I've seen that, but the "not quite the usual" thing is the thrust_create_target(...) (which does exist for good reasons, though).

I think we'll be able to work with it, but the thing about it is that a find_package(rmm) would pull in thrust and would have to do a thrust_create_target() internally, not exactly knowing what thrust variant the consuming application actually wants. It might not be a problem in the typical use case, but I think I can dream up issues where the application also makes a thrust target and one ends up pulling in thrust twice via different target names and with different configurations...

CMakeLists.txt Outdated Show resolved Hide resolved
@kkraus14 kkraus14 added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for review Ready for review by team labels Sep 8, 2020
@harrism harrism merged commit 6cf7323 into rapidsai:branch-0.16 Sep 8, 2020
rapids-bot bot pushed a commit to rapidsai/cugraph that referenced this pull request Feb 4, 2021
…t cugraph as an external project and other tech debt removal (#1367)

This PR makes cuGraph's cmake files more consistent with other RAPIDS libs by matching the minimum required cmake version, adding `project()` statements to cugraph's thirdparty modules, and using `CMAKE_CURRENT_SOURCE_DIR` appropriately so paths are relative to the CMakeLists.txt file rather than the top-level cmake dir of the project (since that may not be the cugraph cpp dir in the case of cugraph being used as an external project by another application).

This also adds a `CUDA_ARCHITECTURES=OFF` setting to suppress the warning printed for each test target. This setting may be replaced/changed once the findcudatoolkit feature is used in a future cmake version.

This also removes the Arrow and GTest cmake files since Arrow is not a direct dependency and those files were not being used, and GTest is now a build requirement in the conda dev environment and does not need to be built from source (the conda dev env files have been updated accordingly).

This PR also addresses much of #1075 , but not completely since gunrock is still using `ExternalProject` due to (I think) updates that need to be made to their cmake files to support this.

This was tested by observing a successful clean build, however it was **not** tested by creating a separate cmake application to simulate cugraph being used as a 3rd party package.

Note: the changes in this PR were modeled after rapidsai/rmm#541

closes #1137 
closes #1266

Authors:
  - Rick Ratzel (@rlratzel)

Approvers:
  - Chuck Hastings (@ChuckHastings)
  - AJ Schmidt (@ajschmidt8)
  - Brad Rees (@BradReesWork)

URL: #1367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge CMake
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Suppress CMake warning and make CMake files usable for 3rd-party project
5 participants