This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
99 lines (91 loc) · 2.37 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
cmake_minimum_required(VERSION 3.17)
project(ERPT_Render_Engine CUDA CXX C)
# Set language standard
set(CMAKE_CXX_STANDARD 14)
# Add FindOptiX and other cmake files
set(CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
${CMAKE_MODULE_PATH})
# Get libraries
find_package(CUDAToolkit REQUIRED)
find_package(CUDA REQUIRED) # To compile ptx code
find_package(OptiX REQUIRED VERSION 7.0)
include_directories(${OptiX_INCLUDE}) # Needed general include for ptx compile
find_program(BIN2C bin2c)
# OptiX device program compile
macro(cuda_compile_and_embed output_var cuda_file)
set(c_var_name ${output_var})
cuda_compile_ptx(ptx_files ${cuda_file})
list(GET ptx_files 0 ptx_file)
set(embedded_file ${ptx_file}_embedded.c)
# message("adding rule to compile and embed ${cuda_file} to \"const char ${var_name}[];\"")
add_custom_command(
OUTPUT ${embedded_file}
COMMAND ${BIN2C} -c --padd 0 --type char --name ${c_var_name} ${ptx_file} > ${embedded_file}
DEPENDS ${ptx_file}
COMMENT "compiling (and embedding ptx from) ${cuda_file}"
)
set(${output_var} ${embedded_file})
endmacro()
cuda_compile_and_embed(embeddedPtxCode src/optixDevicePrograms.cu)
add_executable(
${PROJECT_NAME}
include/main.h main.cpp
include/constants.h
include/communication.h src/communication.cpp
include/kernels.cuh src/kernels.cu
include/transformations.cuh src/transformations.cu
include/drawings.cuh src/drawings.cu
include/raytracing.h src/raytracing.cpp
include/optixLaunchParameters.h
include/CUDABuffer.h
${embeddedPtxCode}
include/types.h)
add_executable(LABS labs/labs.cpp labs/another.h labs/labs.h)
# For project
add_definitions(-D__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__=1)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CUDA_ARCHITECTURES 52 61)
target_include_directories(
${PROJECT_NAME}
PRIVATE
include
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
${optix_LIBRARY}
CUDA::cudart
CUDA::cuda_driver
CUDA::cublas
CUDA::curand
)
# Copy for Labs
set_target_properties(
LABS
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
)
target_compile_options(
LABS
PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:
-gencode arch=compute_61,code=sm_61>
)
target_include_directories(
LABS
PRIVATE
include
)
target_link_libraries(
LABS
PRIVATE
CUDA::cudart
CUDA::cuda_driver
CUDA::cublas
)