Compiling cuStateVec with CMake #85
-
Hi there, I am incorporating cuStateVec into a C++ project as a dynamic library using CMake, and although it works, I'm apprehensive I'm not using best practice. For context, I've installed
I have an existing CMake project which uses CUDA (without cuStateVec). Since it intends to support (very) older CMake versions, the root find_package(CUDA REQUIRED)
cuda_add_library(myProject mySourceFiles)
target_link_libraries(QuEST ${CUDA_LIBRARIES}) Already inadvisable of course; please forgive me, I'm stuck with it at the moment! I now wish to adapt this to include cuStateVec. I expected it to be as simple as replacing the final line above with: find_library(CUQUANTUM_LIBRARIES custatevec)
target_link_libraries(myProject ${CUDA_LIBRARIES} ${CUQUANTUM_LIBRARIES}) Alas, compiling yields the below error /usr/include/custatevec.h:134:10: fatal error: library_types.h: No such file or directory
134 | #include <library_types.h> indicating that CMake has not included directory target_include_directories(myProject PUBLIC "/usr/local/cuda/include") and everything compiles fine, but I'm doubtful this is really addressing the issue. So; is there an example of compiling cuStateVec with CMake, or additional |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi @TysonRayJones thanks for posting this question. If any of my explanations below are not helpful, please let us know/clarify. Apologies for my long answer. Without seeing exactly what is being compiled or how, it's difficult to comment on best practices. Can we migrate the best-practices question to a discussion, and can you provide more detail, there? One comment on this without knowing anything specific about your use-case, I'd recommend isolating and compiling artifacts that specifically use CUDA separately and linking them to your target executable/library at the end. Regarding your other question about include directories: we intend cuQuantum be used like any other CUDA math library, and dependent projects of that library be compiled with Nvidia's toolchain (e.g.)
If using |
Beta Was this translation helpful? Give feedback.
-
@TysonRayJones let us know if this is still an issue. |
Beta Was this translation helpful? Give feedback.
-
Hi @mtjrider , Sure, feel free to migrate to a discussion if preferred! |
Beta Was this translation helpful? Give feedback.
-
Thanks. I've migrated the issue to a discussion, as nothing is "broken" per se. Ideally, we'd have a minimalistic reproducer to iterate over. |
Beta Was this translation helpful? Give feedback.
Apologies for the profane delay! Oliver Brown managed to get this working in QuEST v4 with a custom
FindCuQuantum.cmake
script, which is used in conjunction with aCMakeLists.txt
containing:I suspect this is as good as it gets until a more official
FindCuQuantum
is prepared!