-
Notifications
You must be signed in to change notification settings - Fork 8
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
next-release. Use CMAKE_PROJECT_DIR or CMAKE_CURRENT_SOURCE_DIR instead of CMAKE_SOURCE_DIR to be able to use HIPRT as a submodule? #13
Comments
Hi @TomClabault here is a preview of it, in case you want to test it: will be included in our next release. |
I tested it on Windows with the VS2022 generator. I could configure my project using HIPRT as a submodule with the new CMake but:
Here the CMakeLists.txt I used for my testings along with the very simple main.txt for the testing the linking with the library (that's a .cpp file but Github doesn't want attached CPP files). |
After further testing, it seems that the reason why HIPRT isn't automatically built alongside the project that adds it as a dependency with I added these two lines to the HIPRT CMakeLists.txt:
below add_library(${HIPRT_NAME} SHARED) and I linked my TestProject (from the CMakeLists in my previous comment) against
Now HIPRT compiles and generate a .lib file under So maybe in the end what's needed is just a "public" name to link against outside of HIPRT's CMakeLists.txt. |
Thanks Tom. |
Maybe this is already planned but just in case:
Suppose I have this project structure:
If I want to use HIPRT in one of my project as a subdirectory, I would use
add_subdirectory(HIPRT)
. However, theCMakeLists.txt
of HIPRT currently uses${CMAKE_SOURCE_DIR }
to refer to theHIPRT/
directory:HIPRT/CMakeLists.txt
Line 244 in d14726e
In the case where HIPRT's
CMakeLists.txt
is called fromadd_subdirectory(HIPRT)
,${CMAKE_SOURCE_DIR }
refers to theMyProject/
directory instead ofHIPRT/
as expected.A solution would be to use either
${CMAKE_CURRENT_SOURCE_DIR }
or${CMAKE_PROJECT_DIR}
The text was updated successfully, but these errors were encountered: