Skip to content

Commit

Permalink
Add Kokkos::all_libs alias target for compatibility with TriBITS/Tr…
Browse files Browse the repository at this point in the history
…ilinos (kokkos#6157)

* Add Kokkos::all_libs alias target for compatibility with Trilinos

* Add comments and fixup for cmake version less than 3.18
  • Loading branch information
dalg24 committed May 25, 2023
1 parent 2a382b4 commit 2a5c949
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ IF (NOT KOKKOS_HAS_TRILINOS AND NOT Kokkos_INSTALL_TESTING)
#Make sure in-tree projects can reference this as Kokkos::
#to match the installed target names
ADD_LIBRARY(Kokkos::kokkos ALIAS kokkos)
# all_libs target is required for TriBITS-compliance
ADD_LIBRARY(Kokkos::all_libs ALIAS kokkos)
TARGET_LINK_LIBRARIES(kokkos INTERFACE ${KOKKOS_COMPONENT_LIBRARIES})
KOKKOS_INTERNAL_ADD_LIBRARY_INSTALL(kokkos)
ENDIF()
Expand Down
11 changes: 11 additions & 0 deletions cmake/KokkosConfigCommon.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ SET(Kokkos_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
SET(Kokkos_CXX_COMPILER_ID "@KOKKOS_CXX_COMPILER_ID@")
SET(Kokkos_CXX_STANDARD @KOKKOS_CXX_STANDARD@)

# Required to be a TriBITS-compliant external package
IF(NOT TARGET Kokkos::all_libs)
# CMake Error at <prefix>/lib/cmake/Kokkos/KokkosConfigCommon.cmake:10 (ADD_LIBRARY):
# ADD_LIBRARY cannot create ALIAS target "Kokkos::all_libs" because target
# "Kokkos::kokkos" is imported but not globally visible.
IF(CMAKE_VERSION VERSION_LESS "3.18")
SET_TARGET_PROPERTIES(Kokkos::kokkos PROPERTIES IMPORTED_GLOBAL ON)
ENDIF()
ADD_LIBRARY(Kokkos::all_libs ALIAS Kokkos::kokkos)
ENDIF()

# Export Kokkos_ENABLE_<BACKEND> for each backend that was enabled.
# NOTE: "Devices" is a little bit of a misnomer here. These are really
# backends, e.g. Kokkos_ENABLE_OPENMP, Kokkos_ENABLE_CUDA, Kokkos_ENABLE_HIP,
Expand Down

0 comments on commit 2a5c949

Please sign in to comment.