Skip to content

Instantly share code, notes, and snippets.

@CRAG666
Forked from ashwin/build-cuda.cmake
Created April 20, 2024 04:20
Show Gist options
  • Save CRAG666/1e6a2e3e0535a55ee6140b7f039638fd to your computer and use it in GitHub Desktop.
Save CRAG666/1e6a2e3e0535a55ee6140b7f039638fd to your computer and use it in GitHub Desktop.
Sample CMakeLists.txt file to build a CUDA program
### CMakeLists.txt for CUDA
cmake_minimum_required(VERSION 2.8)
find_package(CUDA QUIET REQUIRED)
# Pass options to NVCC
set(
CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};
-O3 -gencode arch=compute_22,code=sm_22
)
# Specify include directories
include_directories(
kernels
utility
)
# Specify library paths
link_directories(
/opt/foobar/lib
/opt/joestuff/lib
)
# For compilation ...
# Specify target & source files to compile it from
cuda_add_executable(
hellocuda
hellocuda.cu
hellocuda.h
kernels/hellokernels.cu
kernels/hellokernels.h
utility/wrapper.cpp
utility/wrapper.h
)
# For linking ...
# Specify target & libraries to link it with
target_link_libraries(
hellocuda
-lfoobar
-ljoestuff
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment