Skip to content

Instantly share code, notes, and snippets.

@ashwin
Last active April 20, 2024 04:20
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ashwin/6547060 to your computer and use it in GitHub Desktop.
Save ashwin/6547060 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
)
@ckhire
Copy link

ckhire commented Oct 1, 2021

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment