e9820010b6360e2fa6f1af8286fbe9b9b144015c
[blender.git] / intern / cycles / kernel / CMakeLists.txt
1
2 set(INC
3         .
4         ../util
5         osl
6         svm
7 )
8
9 set(SRC
10         kernel.cpp
11         kernel_optimized.cpp
12         kernel.cl
13         kernel.cu
14 )
15
16 set(SRC_HEADERS
17         kernel.h
18         kernel_accumulate.h
19         kernel_bvh.h
20         kernel_camera.h
21         kernel_compat_cpu.h
22         kernel_compat_cuda.h
23         kernel_compat_opencl.h
24         kernel_differential.h
25         kernel_displace.h
26         kernel_emission.h
27         kernel_film.h
28         kernel_globals.h
29         kernel_light.h
30         kernel_math.h
31         kernel_mbvh.h
32         kernel_montecarlo.h
33         kernel_object.h
34         kernel_passes.h
35         kernel_path.h
36         kernel_qbvh.h
37         kernel_random.h
38         kernel_shader.h
39         kernel_textures.h
40         kernel_triangle.h
41         kernel_types.h
42 )
43
44 set(SRC_SVM_HEADERS
45         svm/bsdf.h
46         svm/bsdf_ashikhmin_velvet.h
47         svm/bsdf_diffuse.h
48         svm/bsdf_oren_nayar.h
49         svm/bsdf_microfacet.h
50         svm/bsdf_reflection.h
51         svm/bsdf_refraction.h
52         svm/bsdf_transparent.h
53         svm/bsdf_ward.h
54         svm/bsdf_westin.h
55         svm/emissive.h
56         svm/svm.h
57         svm/svm_attribute.h
58         svm/svm_bsdf.h
59         svm/svm_camera.h
60         svm/svm_closure.h
61         svm/svm_convert.h
62         svm/svm_checker.h
63         svm/svm_displace.h
64         svm/svm_fresnel.h
65         svm/svm_gamma.h
66         svm/svm_brightness.h
67         svm/svm_geometry.h
68         svm/svm_gradient.h
69         svm/svm_hsv.h
70         svm/svm_image.h
71         svm/svm_invert.h
72         svm/svm_light_path.h
73         svm/svm_magic.h
74         svm/svm_mapping.h
75         svm/svm_math.h
76         svm/svm_mix.h
77         svm/svm_musgrave.h
78         svm/svm_noise.h
79         svm/svm_noisetex.h
80         svm/svm_normal.h
81         svm/svm_ramp.h
82         svm/svm_sepcomb_rgb.h
83         svm/svm_sky.h
84         svm/svm_tex_coord.h
85         svm/svm_texture.h
86         svm/svm_types.h
87         svm/svm_value.h
88         svm/svm_voronoi.h
89         svm/svm_wave.h
90         svm/volume.h
91 )
92
93 set(SRC_UTIL_HEADERS
94         ../util/util_color.h
95         ../util/util_math.h
96         ../util/util_transform.h
97         ../util/util_types.h
98 )
99 # CUDA module
100
101 if(WITH_CYCLES_CUDA_BINARIES)
102         if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
103                 set(CUDA_BITS 64)
104         else()
105                 set(CUDA_BITS 32)
106         endif()
107
108         set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_UTIL_HEADERS})
109         set(cuda_cubins)
110
111         foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
112                 set(cuda_cubin kernel_${arch}.cubin)
113
114                 add_custom_command(
115                         OUTPUT ${cuda_cubin}
116                         COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu --use_fast_math -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" --maxrregcount=24 --opencc-options -OPT:Olimit=0 -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
117                         DEPENDS ${cuda_sources})
118
119                 delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)
120                 list(APPEND cuda_cubins ${cuda_cubin})
121         endforeach()
122
123         add_custom_target(cycles_kernel_cuda ALL DEPENDS ${cuda_cubins})
124 endif()
125
126 # OSL module
127
128 if(WITH_CYCLES_OSL)
129         add_subdirectory(osl)
130 endif()
131
132 # CPU module
133
134 include_directories(${INC})
135
136 add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_SVM_HEADERS})
137
138 if(WITH_CYCLES_OPTIMIZED_KERNEL)
139         set_source_files_properties(kernel_optimized.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_OPTIMIZED_KERNEL_FLAGS}")
140 endif()
141
142 if(WITH_CYCLES_CUDA)
143         add_dependencies(cycles_kernel cycles_kernel_cuda)
144 endif()
145
146 # OpenCL kernel
147
148 #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl)
149 #add_custom_command(
150 #       OUTPUT ${KERNEL_PREPROCESSED}
151 #       COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -o ${KERNEL_PREPROCESSED}
152 #       DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS})
153 #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
154 #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
155
156 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
157 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
158 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
159 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
160 delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
161