mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2025-04-25 17:21:38 +01:00
37 lines
1.1 KiB
CMake
37 lines
1.1 KiB
CMake
# Include directories and libraries
|
|
include_directories(../../../Common)
|
|
|
|
# Source file
|
|
set(SRC_FILES
|
|
simpleDrvRuntime.cpp
|
|
)
|
|
|
|
# Add target for simpleDrvRuntime
|
|
add_executable(simpleDrvRuntime ${SRC_FILES})
|
|
set_target_properties(simpleDrvRuntime PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
|
target_include_directories(simpleDrvRuntime PRIVATE
|
|
${CUDAToolkit_INCLUDE_DIRS}
|
|
)
|
|
|
|
target_link_libraries(simpleDrvRuntime PUBLIC
|
|
CUDA::cudart
|
|
CUDA::cuda_driver
|
|
)
|
|
|
|
# Generate accompanying fatbin
|
|
set(CUDA_FATBIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/vectorAdd_kernel64.fatbin")
|
|
set(CUDA_KERNEL_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/vectorAdd_kernel.cu")
|
|
|
|
add_custom_command(
|
|
OUTPUT ${CUDA_FATBIN_FILE}
|
|
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}
|
|
DEPENDS ${CUDA_KERNEL_SOURCE}
|
|
COMMENT "Building CUDA fatbin: ${CUDA_FATBIN_FILE}"
|
|
)
|
|
|
|
# Create a dummy target for fatbin generation
|
|
add_custom_target(generate_fatbin_simpleDrv ALL DEPENDS ${CUDA_FATBIN_FILE})
|
|
|
|
# Ensure matrixMulDrv depends on the fatbin
|
|
add_dependencies(matrixMulDrv generate_fatbin_simpleDrv)
|