Skip to content

Commit

Permalink
Resolve root of cuda toolkit not found2
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasReutelsterz committed Jul 9, 2024
1 parent 037b6c0 commit ab2aa0a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/code-gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,17 @@ foreach(EXAMPLE ${EXAMPLES})
# GPU specific code generation
set(GENERATED_GPU_SRC ${GEN_DIR}/gpulike_subroutine.cpp)
enable_language(CUDA REQUIRED)
include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include)
link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
# Attempt to find the CUDA Toolkit path from an environment variable
if(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR)
if(DEFINED ENV{CUDA_TOOLKIT_ROOT_DIR})
set(CUDA_TOOLKIT_ROOT_DIR $ENV{CUDA_TOOLKIT_ROOT_DIR})
else()
message(FATAL_ERROR "CUDA_TOOLKIT_ROOT_DIR is not set. Please define the environment variable CUDA_TOOLKIT_ROOT_DIR pointing to your CUDA Toolkit installation.")
endif()
endif()

# Now that CUDA_TOOLKIT_ROOT_DIR is set, you can proceed to find the CUDA package
find_package(CUDAToolkit REQUIRED)
set(CMAKE_CUDA_STANDARD 17)
add_library(${EXAMPLE}-target-gpu SHARED ${GENERATED_GPU_SRC})
target_link_libraries(${EXAMPLE}-target PUBLIC ${EXAMPLE}-target-gpu)
Expand Down

0 comments on commit ab2aa0a

Please sign in to comment.