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

Cuda: Configuring fails with CMake 3.28.4 and later #6902

Open
masterleinad opened this issue Mar 27, 2024 · 1 comment
Open

Cuda: Configuring fails with CMake 3.28.4 and later #6902

masterleinad opened this issue Mar 27, 2024 · 1 comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) CMake InDevelop Enhancement, fix, etc. has been merged into the develop branch;

Comments

@masterleinad
Copy link
Contributor

With CMake 3.28.4, we are getting

CMake Error at /app/kokkos-install/lib/cmake/Kokkos/KokkosConfig.cmake:41 (SET_TARGET_PROPERTIES):
  The link interface of target "CUDA::cudart" contains:

    CUDA::cudart_static_deps

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  CMakeLists.txt:10 (find_package)

when trying to link against Kokkos::kokkos. Kitware/CMake@4a3cafe to fix https://gitlab.kitware.com/cmake/cmake/-/issues/25665 seems responsible. Basically, FindCUDAToolkit.cmake now adds more dependencies to targets that we don't export. More precisely it's

  if(NOT TARGET CUDA::cudart_static_deps)
    add_library(CUDA::cudart_static_deps IMPORTED INTERFACE)
    if(UNIX AND (CMAKE_C_COMPILER OR CMAKE_CXX_COMPILER))
      find_package(Threads REQUIRED)
      target_link_libraries(CUDA::cudart_static_deps INTERFACE Threads::Threads ${CMAKE_DL_LIBS})
    endif()

    if(UNIX AND NOT APPLE AND NOT (CMAKE_SYSTEM_NAME STREQUAL "QNX"))
      # On Linux, you must link against librt when using the static cuda runtime.
      find_library(CUDAToolkit_rt_LIBRARY rt)
      mark_as_advanced(CUDAToolkit_rt_LIBRARY)
      if(NOT CUDAToolkit_rt_LIBRARY)
        message(WARNING "Could not find librt library, needed by CUDA::cudart_static")
      else()
        target_link_libraries(CUDA::cudart_static_deps INTERFACE ${CUDAToolkit_rt_LIBRARY})
      endif()
    endif()
  endif()

which means that we need to export CUDA::cudart_static_deps, and Threads::Threads as well (and refind Threads).

@masterleinad
Copy link
Contributor Author

#6902 provides a hotfix but we should revisit in #6164.

@ajpowelsnl ajpowelsnl added CMake Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) InDevelop Enhancement, fix, etc. has been merged into the develop branch; labels Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) CMake InDevelop Enhancement, fix, etc. has been merged into the develop branch;
Projects
None yet
Development

No branches or pull requests

2 participants